views:

453

answers:

3

I'm currently working on a game engine written in pygame and I wanted to add OpenGL support.

I wrote a test to see how to make pygame and OpenGL work together, and when it's running in windowed mode, it runs between 150 and 200 fps. When I run it full screen (all I did was add the FULLSCREEN flag when I set up the window), it drops down to 60 fps. I added a lot more drawing functions to see if it was just a huge performance drop, but it always ran at 60 fps.

Is there something extra I need to do to tell OpenGL that it's running fullscreen or is this a limitation of OpenGL?

(I am running in Windows XP)

+1  A: 

Is this a V-Sync issue? Something about the config or your environment may be limiting maximum frame rate to your monitor's refresh rate.

frou
A: 

If you are not changing your clock.tick() when you change between full screen and windowed mode this is almost certainly a vsync issue. If you are on an LCD then it's 100% certain.

Unfortunately v-sync can be handled in many places including SDL, Pyopengl, your display server and your video drivers. If you are using windows you can adjust the vsync toggle in the nvidia control panel to test, and there's more than likely something in nvidia-settings for linux as well. I'd guess other manufacturers drivers have similar settings but that's a guess.

Pmc
What do you mean by "changin clock.tickf()?" I'm also using the graphics card that came with the computer, so I don't think I can access the vsync settings. Is there a way I can do that with OpenGL?
Brad Zeis
clock.tick() is pygames mechanism for controlling the frequency of screen redraws. http://www.pygame.org/docs/ref/time.html is the doc, and here is and example using it http://www.pygame.org/docs/tut/chimp/ChimpLineByLine.html.
Pmc
@htw if it was a pygame implementation issue wouldn't the results be uniform regardless of the FULLSCREEN state?
Pmc
I am calling clock.tick(), but I was confused about "changing" the clock.tick(). I think I'll just never let the engine run at an fps higher than the screen refresh rate. Since this varies from system to system, is there any way I can find out the refresh rate with python?
Brad Zeis
+2  A: 

As frou pointed out, this would be due to Pygame waiting for the vertical retrace when you update the screen by calling display.flip(). As the Pygame display documentation notes, if you set the display mode using the HWSURFACE or the DOUBLEBUF flags, display.flip() will wait for the vertical retrace before swapping buffers.

To be honest, I don't see any good reason (aside from benchmarking) to try to achieve a frame rate that's faster than the screen's refresh rate. You (and the people playing your game) won't be able to notice any difference in speed or performance, since the display can only draw 60 fps anyways. Plus, if you don't sync with the vertical retrace, there's a good chance that you'll get screen tearing.

htw