• Advertisement
Sign in to follow this  

Untitled

This topic is 3935 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I just want to ask.. what is the SDL-equivalent of this function in OpenGL? -> glutDisplayFunc(....) <-- thanks :)

Share this post


Link to post
Share on other sites
Advertisement
You can call that from within an SDL application and it'll work fine. I don't believe there would be a counterpart for that function in SDL.

Share this post


Link to post
Share on other sites
SDL uses a slightly different approach. In general you would re-draw the screen every frame. Most fast paced games pretty much require this anyway.

So in your main loop ( as SDL lets you handle the loop, rather than delegating it):


void draw() { /* stuff */ }

int main( int, char ** ) {

// init code

while(running) {
// handle input events
draw();
SDL_GL_SwapBuffers();
}
}



However, if your program is more input or event oriented you may not wish to redraw the screen more often than required, say only when the player moves. You still want to redraw when your application becomes obscured by something and needs refreshing. Handling the SDL_VIDEOEXPOSE event should help in such a program.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement