Wait for output to be displayed on screen

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Wait for output to be displayed on screen

Pepe1
So I already posted this on stackoverflow (http://stackoverflow.com/questions/23763812/opengl-wait-for-output-to-be-displayed-on-screen), but I didn't receive any useful answers, so I'm reposting it here.

I'm trying to draw a few images on a GLWindow and then after they've been drawn, read them into a bytebuffer. The displaying part works fine and the image reading works too, but they don't seem to play nice together.

public void display(GLAutoDrawable drawable)
{
    GL2 gl  = drawable.getGL().getGL2();

    gl.glClear(GL2.GL_COLOR_BUFFER_BIT);

    render.mutate();
    eval.display();     //display images
    drawTexture(gl, loader.getTexture());
    gl.glFlush();       //glFinish() doesn't work either

    eval.evaluate();    //read images
}
What seems to happen is that eval.evaluate() is called before the output is actually on screen. This results in the evaluate function just reading empty images.

I always assumed that when glFlush() is called, everything is output to the screen, but apparently not.

So is there a way to force the program to somehow wait for the output to appear on screen before continuing with the reading?

Also, it's not possible to get the bytebuffer directly from the images, because one of the images is not really an image but rather a collection of triangles drawn with openGL.

As always, thanks in advance!
Reply | Threaded
Open this post in threaded view
|

Re: Wait for output to be displayed on screen

jmaasing
I'm just guessing but maybe the drawable is using double buffering, in that case glFlush might just mean that it should flush to a buffer. Which "later" gets blitted to screen. Maybe getAutoSwapBufferMode can give a hint about that.