1
Graphics / Renderimage upside down?
« on: September 28, 2010, 08:43:07 pm »
Ah, yeah that fixed it, thanks for the help.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
using System;
using System.Collections.Generic;
using System.Timers;
using SFML;
using SFML.Window;
using SFML.Graphics;
namespace FrostFire
{
class MainGame : Program
{
public MainRenderBuffer MainBuffer;
public MainGame()
{
Text NewText = new Text();
NewText.Position = new Vector2(200, 200);
NewText.Color = new Color(250, 100, 30);
Text NewText2 = new Text();
NewText2.Position = new Vector2(120, 210);
NewText2.Color = new Color(110, 222, 30);
//sort all the sprites by depth and draw them to a buffer
this.MainBuffer = new MainRenderBuffer(base.MainWindow.Height, base.MainWindow.Width);
while (MainWindow.IsOpened())
{
base.MainWindow.DispatchEvents();
//clear the window so we have a fresh screen to work with
base.MainWindow.Clear();
//Do all the game update logic
MainGame.MainGameStateLoop();
//replace this with the depth drawing array
NewText.DisplayedString = Convert.ToString(base.MainWindow.GetFrameTime());
NewText2.DisplayedString = Convert.ToString(base.MainWindow.GetFrameTime());
this.MainBuffer.RenderBufferImage.Draw(NewText);
this.MainBuffer.RenderBufferImage.Draw(NewText2);
//draw the main buffer image to the screen
base.MainWindow.Draw(new Sprite(this.MainBuffer.RenderBufferImage.Image));
//display drawn buffer to the window
base.MainWindow.Display();
//clear the main buffer for the next frame.
this.MainBuffer.RenderBufferImage.Clear();
}
}
public static void MainGameStateLoop()
{
//switch statement for different room states (title, level, etc.)
}
}
}
using System;
using System.Collections.Generic;
using SFML;
using SFML.Window;
using SFML.Graphics;
namespace FrostFire
{
class MainRenderBuffer
{
public uint Height, Width;
public RenderImage RenderBufferImage;
public MainRenderBuffer(uint Height, uint Width)
{
this.Height = Height;
this.Width = Width;
this.RenderBufferImage = new RenderImage(this.Width, this.Height);
RenderBufferImage.Image.Smooth = false;
}
}
}
using System;
using SFML;
using SFML.Window;
using SFML.Graphics;
namespace SFMLTest
{
class Program
{
public Player MyPlayer;
static void OnClose(object Sender, EventArgs e)
{
RenderWindow Window = (RenderWindow)Sender;
Window.Close();
}
static void Main(string[] args)
{
RenderWindow Window = new RenderWindow(new VideoMode(384,256),"Hello world!");
Window.Closed += new EventHandler(OnClose);
Window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
while(Window.IsOpened())
{
Window.DispatchEvents();
Window.Clear();
Player MyPlayer = new Player();
Player.Initialize(MyPlayer);
Sprite ImageToDraw = MyPlayer.Draw(MyPlayer);
Window.Draw(ImageToDraw);
Window.Display();
}
}
static void OnKeyPressed(object Sender, KeyEventArgs e)
{
RenderWindow Window = (RenderWindow)Sender;
if (e.Code == KeyCode.Escape)
Window.Close();
}
}
}
using System;
using SFML;
using SFML.Window;
using SFML.Graphics;
namespace SFMLTest
{
class Player
{
public int X,Y;
public string ImagePath;
public Player()
{
}
public static void Initialize(Player Player)
{
Player.X = 100;
Player.Y = 100;
Player.ImagePath = "Images/TestImage.png";
}
public Sprite Draw(Player Player)
{
Sprite PlayerImage = new Sprite(new Image(Player.ImagePath));
PlayerImage.Position = new Vector2(Player.X,Player.Y);
return PlayerImage;
}
}
}