Hey guys,
I'm just starting with OpenGL and am confused on how to actually use double buffering in OpenGL with SDL. The book I'm reading uses GLUT, so that doesn't really help at all. I've looked on teh intrawebz and haven't found anything useful yet.
Here is some code I've got so far (please note it is poorly structured and very ugly, as I am just beginning:D)
Ginto8 wrote:that's pretty much how you do it =P SDL_GL_SwapBuffers() changes your buffer, and glClear() clears it for the next drawing sequence.
Thanks Ginto, but when I run my program, (which basically is just a red rectangle, bouncing off the edges of the screen) it looks very jumpy and jittery. Am I missing something?
Because you have a 45msec sleep time in there. This is a tremendous amount of time. Assuming the granularity of the timer is decent (which SDL's is NOT), you'd get somewhere around 22fps. Maybe more, maybe less.
My suggestion would be to ditch that and write your own timer to get the app to run at some target rate.
qpHalcy0n wrote:Because you have a 45msec sleep time in there. This is a tremendous amount of time. Assuming the granularity of the timer is decent (which SDL's is NOT), you'd get somewhere around 22fps. Maybe more, maybe less.
My suggestion would be to ditch that and write your own timer to get the app to run at some target rate.
and iirc <ctime> has a number of utilities to do exactly that
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.