SFML community forums
Bindings - other languages => DotNet => Topic started by: Xyro on January 01, 2011, 05:57:38 pm
-
For some reason I can't get a polygon to draw, it only shows a blank screen.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFML;
using SFML.Window;
using SFML.Graphics;
namespace MusicSFML
{
class World
{
Shape polygon = new Shape();
public RenderWindow renderWindow = new RenderWindow(new VideoMode(1280, 720, 32), "Look at this it may even work");
public World()
{
renderWindow.Closed += new EventHandler(OnClosed);
renderWindow.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
polygon.AddPoint(new Vector2(10, 10), Color.Black);
polygon.AddPoint(new Vector2(50, 10), Color.Black);
polygon.AddPoint(new Vector2(50, 30), Color.Black);
polygon.AddPoint(new Vector2(10, 30), Color.Black);
polygon.Color = Color.Black;
polygon.EnableFill(true);
polygon.EnableOutline(true);
}
public void Think()
{
// Proccess events
renderWindow.DispatchEvents();
float frameTime = renderWindow.GetFrameTime();
}
public void Draw()
{
renderWindow.Clear(Color.White);
renderWindow.Draw(polygon);
}
void OnClosed(object sender, EventArgs e)
{
RenderWindow window = (RenderWindow)sender;
window.Close();
}
void OnKeyPressed(object sender, KeyEventArgs e)
{
RenderWindow window = (RenderWindow)sender;
if (e.Code == KeyCode.Escape)
window.Close();
}
}
}
-
You need renderWindow.Display() in your Draw()
-
Oke well this is weird, everything worked as expected yesterday. when I wanted to check out if this worked it just stopped working. I managed to find out that it hangs on creating renderwindow
It just opens the console and it goes to the creating of the renderwindow and just hangs there no crash no errors.
Tried removing underthings and just opening a simple window. also tried re downloading. any suggestions ?
-
Recent ATI driver?
-
Fuck just read the other topic, I'll see if it auto updated or something. I'll probably downgrade it otherwise ...
-
Fuck just read the other topic, I'll see if it auto updated or something. I'll probably downgrade it otherwise ...
Works now downgraded !