glSwapBuffers

Started by
4 comments, last by pupillo 15 years, 2 months ago
Who knows why glSwapBuffers takes as much as some milliSecs to run? What does it do exactly? I expected something like pointers exchange but I'm afraid it moves the content of the buffers. Am I right? Thanks
Advertisement
glSwapBuffers will execute all pending commands, It might wait for vertical retrace. As for the swap itself, it's configurable but most probably something like a pointer exchange.

HTH.
I omitted to say that my scene is totally empty, vertical sync is disabled, I'm using a direct rendering context and my code simply is:
while (1) { glXSwapBuffers(...); }
It can't be just an exchange...
Unless you're shipping this application, don't bother. Profile when you have a real problem.
EDIT:
Quote:
I'm using a direct rendering context


As in single buffered rendering? If so why are you calling glXSwapBuffers?
No, direct rendering means it bypasses the X server fluff and is hw accelerated.
With indirect rendering, you don't get hw accel.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
doubble buffered mode

GLint att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None };
...
vi = glXChooseVisual(dpy, 0, att);

I don't understend why glXSwapBuffers is so slow if hw acc. is enabled ! :S

This topic is closed to new replies.

Advertisement