GlPopAttrib and glPushAttrib on GLES for rendering fbo to a qquickitem



  • Hi guys,

    I've extended QQuickitem to create an area where I can call open gl calls directly.

    Only problem is on GLES/ANGLE platforms I cant push and pop like so

    This is the preprocess in my QSGSimpleTextureNode extended class

    @void ColorNode::preprocess()
    {
    if(m_fbo == NULL) return; //will happen a few times

    QOpenGLContext::currentContext()->functions()->glUseProgram(0);
    glPopAttrib();
    m_fbo->bind();
    

    //CCDirector::sharedDirector()->mainLoop();
    opengl calls here

    glPushAttrib(GL_ALL_ATTRIB_BITS);
    m_fbo->release();
    

    m_fbo->toImage().save("name.png","png");

    }@

    Any ideas?


  • Lifetime Qt Champion

    Hi,

    If i'm not wrong, your calls are reversed, glPushXXX should be call before glPopXXX, otherwise you will have an "underflow" of what you're trying to push/pop.



  • I didn't write this code.
    I think it is done this way because the qml window is already drawing something to screen via gl.

    This code above works though I've tested it.

    The problem is that the funstions glpush and glpop doesn't exsist on GLES systems so how do we do it?


  • Lifetime Qt Champion

    Sorry, i misread your post, you'll have to handle these attribute yourself (they are part of the fixed pipe which is not there anymore in gles)

    But for normal OpenGL, having pop before push looks wrong even if it works.



  • How do I handle these attributes?

    You are right I thought it was strange also.
    Here is my explanation.

    Lets say we have a text list.
    qt pushes the view of the text list on to the stack.
    It will then draw the surrounding window.
    it will pop it off at the end and draw it to the area we want our qquickitem.
    To ensure the text list is drawn last.

    so what we are doing is popping it off early modify it and push it back for qt to draw it at a later stage.
    At least that's what I can gather from qquickitem

    now my question is how does qt do this for GLES systems because it must do it somehow?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.