Qopenglwidget不能使用超过一个Sampler2d
QOpenGLWidget cannot use more than one sampler2D
我已经创建了一个非常基本的着色器:
static const char *frag_showImage =
"#version 150n"
"uniform sampler2D textureSampler;n"
"in mediump vec2 texc;n"
"out highp vec4 fragColor;n"
"void main() {n"
" fragColor = texture2D(textureSampler, texc.st);n"
"}n";
它可以按预期工作,现在更复杂:
"#version 150n"
"uniform sampler2D textureSampler;n"
"uniform sampler2D maskSampler;n"
"in mediump vec2 texc;n"
"out highp vec4 fragColor;n"
"void main() {n"
" fragColor = texture2D(textureSampler, texc.st);n"
" fragColor.x = texture2D(maskSampler, texc.st).x;n"
" fragColor.y =0;n"
"}n";
它行不通,但没有任何警告:
在这两种情况下,我都将第一个纹理绑定为:
QOpenGLFunctions *f =this->context()->functions();
f->glActiveTexture(GL_TEXTURE0);
glBaseTexture->bind();
m_program->setUniformValue("textureSampler", 0);
,第二个纹理的曲线为:
f->glActiveTexture(GL_TEXTURE1);
glMaskTexture->bind();
m_program->setUniformValue("maskSampler", 1);
请注意,如果我绑定第一个着色器的glmaskTextul
有什么想法吗?预先感谢您!
goblins:将maskSampler重命名为其他名称,我不知道为什么在代码的任何其他部分都没有使用" maskSampler"。
相关文章:
- 如何创建一个CMake变量,除非显式重写,否则使用默认值
- 删除一个线程上有数百万个字符串的大型哈希映射会影响另一个线程的性能
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 运行同一解决方案的另一个项目的项目
- 挂起和取消挂起一个文件DLL
- 用C++中的一个变量定义一个常量
- 函数向量_指针有不同的原型,我可以构建一个吗
- 在c++中用vector填充一个简单的动态数组
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 预处理器:插入结构名称中的前一个行号
- 我在c++代码中生成了一个运行时#3异常
- 我想将一个对T类型的非常量左值引用绑定到一个T类型的临时值
- 从链接列表c++中删除一个项目
- 告诉一个 const char 数组,除了编译时 C 样式的字符串外,它不以 '