glutSwapBuffers: How to execute that in plan GL ?

Hello, (new to openGL)

I’m finding glutSwapBuffers() function a bit slow in some circumstances. I would like to try with equivalent commands in plain GL but I could not find them.

Can someone give me some help/directions on that ?
(I’m using Ruby just in case language implementation became important).

Thank you.

swapping buffers is not slow, check doing a glFlush right before.

Well, glFlush() before glutSwapBuffers() did not improved.

Let me explain my scenario:

  1. The model is a simple 35500 vertex rendered as GL_POINTS.
  2. My machine needs 30 ms to render those points in a non-buffered view (GLUT_SINGLE) using just the CPU.
  3. Needs only 0.15 ms in a non-buffered view but now using the GPU (via glNewList(x, GL_COMPILE).
  4. 30 ms in a buffered view (GLUT_DOUBLE) with CPU.
  5. 17 ms buffered view with GPU.
  6. 17 ms to render nothing in a buffered view (just simple execution of the glutSwapBuffers).

And doing a glFlush right before does not change these numbers.
Am I missing something or doing something wrong ?

Thank you
Marcio

The actual cost of swapping buffers is negligible.
What you see is probably an effect of vsync. Before doing benchmarks, disable it, otherwise you only measure your display refresh rate.
ie : 1 s /60 Hz = 16.667 ms

Bingo! Thank you very much.

Turning off vsync resolved my “issue”.

“swapping buffers is not slow, check doing a glFlush right before”

Yeah, but doesn’t glutSwapBuffers() block until all previously sent data flows out of the rendering pipeline and into the frame buffer before swapping?

My mistake, I meant glFinish().
Normally swapbuffers implies glFlush(), not a glFinish(). Of course the implementation can do a glFinish() instead.
What happens is that the card can buffer a bunch of GL commands before blocking, so you can already have submitted multiple frames without blocking, and before they are actually drawn.