Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Problem with Shapes.  (Read 4007 times)

0 Members and 1 Guest are viewing this topic.

NimrodsSon

  • Newbie
  • *
  • Posts: 7
    • View Profile
Problem with Shapes.
« 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.

Code: [Select]

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();
        }
    }

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problem with Shapes.
« Reply #1 on: August 07, 2010, 10:39:31 am »
This code works for me.

Do the SDK samples work?
Laurent Gomila - SFML developer

NimrodsSon

  • Newbie
  • *
  • Posts: 7
    • View Profile
Problem with Shapes.
« Reply #2 on: August 07, 2010, 05:58:56 pm »
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problem with Shapes.
« Reply #3 on: August 07, 2010, 06:05:39 pm »
That's weird. Are your graphics drivers up-to-date?
Laurent Gomila - SFML developer

NimrodsSon

  • Newbie
  • *
  • Posts: 7
    • View Profile
Problem with Shapes.
« Reply #4 on: August 07, 2010, 07:04:53 pm »
Just checked again and my ATI Mobility Radeon x1300 is up-to-date as far as I can tell.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Problem with Shapes.
« Reply #5 on: August 07, 2010, 11:37:22 pm »
If you have checked the driver actuality via Windows' device manager, this isn't 100% reliable. Quite recently, 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. ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

NimrodsSon

  • Newbie
  • *
  • Posts: 7
    • View Profile
Problem with Shapes.
« Reply #6 on: August 08, 2010, 04:00:35 am »
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.