Qt multiple QGLShaderProgram for one texture



  • I use two QGLShaderProgram's for processing the texture.

    @
    ShaderProgram1->bind(); // QGLShaderProgram
    ShaderProgram2->bind();

    glBegin(GL_TRIANGLE_STRIP);
    ...
    glEnd();

    ShaderProgram1->release();
    ShaderProgram2->release();
    @

    The texture should be processed with Shaderprogram1 and then ShaderProgram2. But when I call ShaderProgram2->bind() automatically fires ShaderProgram1->release() and only one shader works. How do I bind both shaders?



  • as long as i know you cannot bind multiple fragment shaders or vertex shaders at once (maybe in some new high performacne GPUs). You have to either combine shaders into one or execute them sequentially.

    ShaderProgram1 is released becouse qt detects that another shader is beeing attached (ShaderProgram2).

    Read more about OpenGL functions:
    "glUseProgram":http://www.opengl.org/sdk/docs/man/xhtml/glUseProgram.xml
    "glAttachShader":http://www.opengl.org/sdk/docs/man/xhtml/glAttachShader.xml


Log in to reply
 

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