Public Group

# SDL: SDL_GL_SetAttribute necessary?

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

## 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 on other sites
How are you drawing your lines? Immediate mode or something batched? You'll want to disable vsync before measuring this kind of thing.

##### 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 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 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.

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 12
• 9
• 12
• 37
• 12
• ### Forum Statistics

• Total Topics
631419
• Total Posts
2999983
×