2D OpenGL problems on laptops

Started by
2 comments, last by dogblog 16 years, 8 months ago
Hi, I'm experiencing some very strange problems with a 2D OpenGL game I've been working on. It's my first outing into OpenGL and it has been a pleasant experience...upto now. It works fine on all the desktop PC's I've tried it on but on a few laptops the screen flickers between screen garbage and the game screen at the game frame rate. The laptop is a Fujitsu Amilo L6820; Celeron2.4GHz; 512MB; Intel 82845G 64MB graphics. Now the problem maybe my own making as the game only updates the screen for objects that have moved or changed for that frame, minimising drawing to allow the best frame rate for older systems. Is this not permissable or advisable in OpenGL? It appears that the doublebuffering is working against me. Each time SwapBuffers() is called the drawing code draws to a different buffer (one initialised by me, the other full of garbage) rather than consitently drawing to the backbuffer. I've tried some testcode on the laptop where the screen is completely redrawn each time and it renders fine. The only workaround I've found is to turn off graphics hardware acceleration on the laptop. Then everything works fine. Could it be a driver bug? - I updated to the latest driver. I'd really rather not recode the entire game, especially as it works on most machines. I'm just not happy with the thought of offering 'turn off your hardware acceleration' as an acceptable workaround. Can anyone help?
Advertisement
Quote:Now the problem maybe my own making as the game only updates the screen for objects that have moved or changed for that frame

If you mean that you are blanking the objects then redrawing them rather than doing glClear() then I would say that almost certainly isn't worth doing, but to tell the truth I never even tried it with OpenGL. The last time I heard of that technique was 10 yrs ago!
In your current setup, make sure that when you initially draw your background (I assume you do a full background draw before the main rendering loop), that you draw it to both buffers when double buffering is enabled.
It may be that one of the drivers is doing a true SwapBuffers, and the other is doing a copy buffers type flip.
Bottom line is (IMO), don't bother, just completely redraw your screen unless you are targeting an 80286 with no graphics acceleration (or something similar)!
In a modern graphics API such as OpenGL you can never rely on what is in the backbuffer until you fill it with something. You must clear and fill every single frame.

When you draw or clear you are modifying the backbuffer, SwapBuffers copies the contents of the back buffer to the front buffer. This is done to reduce flicker and the technique is known as double buffering. Once the buffers have been swapped the result of what is in the back buffer is undefined - which means on some cards it may be what was in the front buffer, on other cards it may be a new block of memory which has not been cleared for performance reasons.

Also, if you do not draw something in a frame then it will not appear for that frame. If something is visible then it needs to be drawn every frame that it is visible for. You can save CPU cycles by not processing an object if it hasn't changed, but you will still need to spend GPU time drawing it.

Hope this helps!
Thanks for putting me on the right track!

I wrongly assumed that the back buffer was consistent between frames.

Looks like I'm in for a big rewriting session - no pain, no gain! :)

This topic is closed to new replies.

Advertisement