glDrawPixels for an image sequence

I am wanting to display a video (composed of single images).
Using OpenGL through QT, I have written a class that stores image data and calls the OpenGl functions.
I am calling the glDrawPixels function in a for-loop with a new set of data every time. Unfortunately, only the last picture of my sequence is displayed. Somehow, either glDrawPixels is too slow, is only called after the loop or it isn’t displayed because of QT’s event-loop management. I think the first can’t be the cause, because I have tried to create objects of my class in a loop (each of which calls glDrawPixels), which can be created with a higher frequency than looping glDrawPixels itself.
Is there a way to allow glDrawPixels to paint before going on with the loop?

When do you swapbuffers ?

I haven’t swapped buffers and unfortunately don’t know what you mean by that. (this is the first time I’m using OpenGL)

What would be the best way to swap the buffer?

Right now the procedure is of the type:

create new data_array;
object.paint(unsigned char* data_array); (this function eventually calls glDrawPixels);


For swapping buffers, you can use glutSwapBuffer()…
Give a double buffer mode as glutInitDisplayMode(GLUT_DOUBLE)…

Mukun, as madison54 is using Qt, glut function will not help :slight_smile:

See :
Maybe something like QGLWidget::paintGL() would be better, but I have no experience with QGL.

(a probable better way to display a video would be to draw only one image per Qt event loop, and re-trigger the next redraw at the correct time with a timer, that would allow to display at a fixed speed)

Thanks for the advice!

I have looked through the QGL Widget Class reference and it seems to in fact have been an event loop issue. If I got that right, buffer swapping is automatically done by QT’s paintGL(), but the event had to be updated.
For those who might have the same issue: what I had to add was QGLWidget::updateGL() after the call of paintGL() to update the event.