[英]OpenGL - Linking two textures doesn't work
我正在嘗試將FBO的深度紋理和顏色紋理鏈接到GLSL着色器(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);
}
我真的不知道這是怎么回事...
終於,我找到了解決方案! 問題是我在設置值之后綁定了程序,應該在設置之前,這也解決了我遇到的許多其他錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.