SFML community forums
Bindings - other languages => DotNet => Topic started by: NimrodsSon on August 07, 2010, 07:55:14 am
-
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();
}
}
-
This code works for me.
Do the SDK samples work?
-
All of the samples included with the .NET package seem to work. I did a program working with sprites and it seemed to work, though on exit it prints:
Failed to set pixel format for device context-cannot create opengl context
on the console.
This is kind of weird, but I had restarted my computer this morning, tried the program I posted above and it worked several times, then I opened up Visual C# 2010 express (didn't even open the project) and it wouldn't display the shapes again when I tried to run it. I've been getting the same inconsistent behavior since. Whether Visual C# is opened or not.
-
That's weird. Are your graphics drivers up-to-date?
-
Just checked again and my ATI Mobility Radeon x1300 is up-to-date as far as I can tell.
-
If you have checked the driver actuality via Windows' device manager, this isn't 100% reliable. Quite recently (http://www.sfml-dev.org/forum/viewtopic.php?t=2680), I could eliminate a lot of strange behaviour resulting from an outdated driver. I went to the manufacturer's homepage and downloaded the newest version. However, the device manager has told me all the time that the graphic cards drivers would be up-to-date.
So, I'd consider a visit at the ATI homepage. ;)
-
Thanks for the tip, but I actually went to both ATI and Dell. I honestly can't find anything newer. It's a very odd problem, something must be screwed up on my machine. *sigh*
Thanks for the help.