[cells-devel] Re: glutSwapBuffers bug?

Kenneth Tilton ktilton at nyc.rr.com
Sat Nov 13 20:30:04 UTC 2004


On Nov 13, 2004, at 2:57 PM, John Stauffer wrote:

> SwapBuffers absolutely does an implicit glFlush.  It could be that 
> you're running single buffered, which means SwapBuffers does nothing 
> and glFlush pushes the commands to the GPU.  I would check if you are 
> double or single buffered.

Yes, we were single-buffered. I just now switched to double-buffered 
and glutSwapBuffers does manage to cause the drawing to occur as 
desired. Thanks.

I am still puzzled, but there is no need really to pursue this further. 
I had raised an eyebrow over the GLUT_SINGLE, but the glutSwapBuffers 
source seemed to indicate it would not matter. (I should have taken two 
seconds to experiment!)

>
> Calling glFlush after SwapBuffers on a buffered context will do 
> nothing.  This is because there would be no commands to flush.
>
> Calling glFlush before SwapBuffers on a buffered context would be 
> redundant since SwapBuffers has an implicit glFlush.

The code I show in macx_win.m looks like this:

> /* CENTRY */
> void APIENTRY glutSwapBuffers(void)
> {
>    if([__glutCurrentView isTreatAsSingle]) {
>       /* Pretend the double buffered window is single buffered,
>          so treat glutSwapBuffers as a no-op.
>          Well, actually flush any graphic commands queued by
>          the hardware accelerator or we won't see anything in
>          the GLUT window... */
>       glFlush();
>       return;
>    }

I see from other source that isTreatAsSingle seems to align with 
GLUT_SINGLE. Makes me wonder if I am looking at the right source. Why 
would my calling glFlush work better than glutSwapBuffers calling it 
before returning?

>
>    SWAP_BUFFERS_WINDOW(__glutCurrentView);
>
>    if (__glutFPS) {
>       GLint t = glutGet(GLUT_ELAPSED_TIME);
>
>       __glutSwapCount++;
>       if (__glutSwapTime == 0)
>          __glutSwapTime = t;
>       else if (t - __glutSwapTime > __glutFPS) {
>          float time = 0.001 * (t - __glutSwapTime);
>          float fps = (float) __glutSwapCount / time;
> 		
> 		 vLogMsg(__FILE__,__LINE__,
> 				"GLUT: %d frames in %.2f seconds = %.2f fps",
> 				(int) __glutSwapCount, time, fps);
>
>          fprintf(stderr, "GLUT: %d frames in %.2f seconds = %.2f 
> FPS\n",
>                   (int) __glutSwapCount, time, fps);
>          __glutSwapTime = t;
>          __glutSwapCount = 0;
>       }
>    }
>
>    glFlush();

So we get a glFlush here as well. So I am puzzled but happy since I now 
know how to proceed.

Thanks, kenny
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 3449 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cells-devel/attachments/20041113/0d179f79/attachment.bin>


More information about the cells-devel mailing list