Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I use two QGLShaderProgram 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
262 views
Welcome To Ask or Share your Answers For Others

1 Answer

You don't.

Unless these are separate shaders (and even they don't work that way), each rendering operation will apply a single set of shaders to the rendered primitive. That means a single Vertex Shader, followed by any Tessellation Shaders, followed by optionally a single Geometry Shader, followed by a single Fragment Shader.

If you want to daisy-chain shaders, you have to do that within the shaders themselves.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...