I'm new to all of this, so perhaps I'm overlooking something, but I've been trying to draw some simple shapes to the screen and haven't had much luck. The problem is kind of inconsistant so it's hard to explain, but when I start my app I can see the shapes flash in the window sometimes, but then they just disappear. Other times they don't show up at all. I haven't been able to discern a pattern.
I'm using SFML 1.6. I can't really think what I may be doing wrong.
class Program
{
static RenderWindow mainWindow = new RenderWindow(new SFML.Window.VideoMode(800, 600, 32), "SFML Shapes");
static void Main(string[] args)
{
Shape line = Shape.Line(new Vector2(0, 300), new Vector2(800, 300), 30, new Color(255, 0, 0));
Shape triangle = new Shape();
triangle.AddPoint(new Vector2(400, 100), Color.White);
triangle.AddPoint(new Vector2(700, 500), Color.White);
triangle.AddPoint(new Vector2(100, 500), Color.White);
mainWindow.Closed += new EventHandler(mainWindow_Closed);
while ( mainWindow.IsOpened() )
{
mainWindow.DispatchEvents();
mainWindow.Clear();
triangle.Rotation += .1f;
mainWindow.Draw(line);
mainWindow.Draw(triangle);
mainWindow.Display();
}
}
static void mainWindow_Closed(object sender, EventArgs e)
{
mainWindow.Close();
}
}