Sign in to follow this  
PrestoChung

SDL: SDL_GL_SetAttribute necessary?

Recommended Posts

I had my program running with SDL_GL_DOUBLEBUFFER intialied with the video flags in SDL_SetVideoMode but I was reading about this SDL_GL_SetAttribute and this one was on the list of attributes that 'need to be set before SDL_SetVideoMode is called' I didn't notice any FPS increase if I put about 54,000 GL lines in my scene (not in a display list, in my main loop), i get about the same FPS. (the rest of the time it seems to cap at 60hz, probably something to do with vsync) I thought with double buffering would be faster because one is drawing while the other is filling. Yes/no?

Share this post


Link to post
Share on other sites
not sure, but it's like this, called every frame:

glBegin( GL_LINES );

glColor4f( 0.7, 0.7, 0.8, 1.0 );

for ( int i = -10; i < 10; i++ ) {
for ( int j = -10; j < 10; j++ ) {
for (int k = -10; k < 10; k++ ) {

glVertex3f( i, k, j );
glVertex3f( i + 1, k, j );
glVertex3f( i, k, j );
glVertex3f( i, k, j + 1 );

glVertex3f( k, i, j );
glVertex3f( k, i + 1, j );
glVertex3f( k, i, j );
glVertex3f( k, i, j + 1 );

glVertex3f( i, j, k );
glVertex3f( i + 1, j, k );
glVertex3f( i, j, k );
glVertex3f( i, j + 1, k );
}
}
}

glEnd();

Share this post


Link to post
Share on other sites
Disabling vsync doesn't seem to be an easy thing, it's probably got to be done with openGL but i couldn't understand the explanation i just read. no matter really, but is there another way to tell if double buffering is working properly?

Share this post


Link to post
Share on other sites
If you are running Windows, you can usually force vsync off using the graphics card settings through the control panel. I assume its relatively easy to do on a Mac or Linux, but I've never tried.

Double buffering is more about getting rid of tearing than anything else, I've never heard of it being used as an optimisation (though I'm not a hardcore grahpics programmer).

If you want to improve your frame rate, your time would be better spent looking into how to batch your drawing in a GPU-friendly manner. Immediate mode is the slowest way to talk to the graphics card. Though if you are getting a few hundred FPS right now, it might be something you could leave off until your rendering becomes the bottleneck.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this