OpenGL - 链接两个纹理不起作用
OpenGL - Linking two textures doesn't work
我正在尝试将FBO的深度纹理和颜色纹理链接到GLSL Shader(4.0版)
问题是,同时只有一个链接,这很奇怪,因为其他纹理可以很好地链接在一起(例如:漫反射、法线和镜面反射贴图)
这是我的绑定RT代码:
void RenderTexture::BindRead(GLuint locationColor,GLuint locationDepth,unsigned int unit,unsigned int dUnit)
{
colorUnit = unit;
this->depthUnit = dUnit;
assert(unit >= 0 && unit <= 31);
glActiveTexture(GL_TEXTURE0 + unit);
glBindTexture(GL_TEXTURE_2D,m_rt);
if (hasDepth)
{
assert(depthUnit >= 0 && depthUnit <= 31);
glActiveTexture(GL_TEXTURE0 + dUnit);
glBindTexture(GL_TEXTURE_2D,m_depth);
glUniform1i(locationDepth,dUnit);
}
glUniform1i(locationColor,unit);
}
我真的不知道这里出了什么问题。。。
终于找到了解决方案问题是我在设置值之后绑定了程序,应该在之前,这也修复了我遇到的许多其他错误。
相关文章:
- 如何在C++中从两个单独的for循环中添加两个数组
- 为什么两个不同的未命名名称空间可以共存于一个cpp文件中
- 当在同一名称空间中有两个具有相同签名的函数时,会发生什么
- 如何返回一个类的两个对象相加的结果
- 如何在C++中将一个无符号的 int 转换为两个无符号的短裤?
- 如何将两个不同矢量的同一位置的两个元素组合在一起
- 两个字符串在 c++ 中不相等
- 在两个类中共享相同的函数调用,并在不需要时避免空实例化
- OpenGL 混合两种纹理总是会选择第一个纹理
- 使用两个纹理 SDL2 显示视频
- 基本 GLSL:两个片段着色器彼此相邻,但第一个(绘制纹理)被覆盖
- 使用OpenGL显示两个对象.纹理不像预期的那样行为
- 开放框架,从两个视频采集卡创建视频纹理
- 如何在OpenGL中将两个不同的图像渲染为两个不同图元?2D纹理阵列
- 将两个图像堆栈的非电源加载到 3D 纹理 OpenGL C++
- OpenGL - 链接两个纹理不起作用
- DirectX在C++中如何在两个对象上渲染不同的纹理
- 在片段着色器中组合两个纹理
- 我可以在两个OpenGL上下文之间共享外部纹理吗?
- Android opengl在两个线程上运行的两个上下文之间共享纹理