问题描述
我使用了两个 QGLShaderProgram 来处理纹理.
I use two QGLShaderProgram for processing the texture.
ShaderProgram1->bind(); // QGLShaderProgram
ShaderProgram2->bind();
glBegin(GL_TRIANGLE_STRIP);
...
glEnd();
ShaderProgram1->release();
ShaderProgram2->release();
纹理应先使用 Shaderprogram1 处理,然后再使用 ShaderProgram2.但是当我调用 ShaderProgram2->bind() 时会自动触发 ShaderProgram1->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?
推荐答案
你没有.
除非这些是单独的着色器(甚至它们不能那样工作),否则每个渲染操作都会将一组单个着色器应用于渲染的图元.这意味着单个顶点着色器,然后是任何曲面细分着色器,然后是可选的单个几何着色器,然后是单个片段着色器.
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.
这篇关于一个纹理的qt多个QGLShaderProgram的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!