1
我在程序中使用了以下頂點着色器,但由於某種原因,glGetUniformBlockIndex(id, "draw2DQuadVS")
返回INVALID_INDEX
。爲什麼glGetUniformBlockIndex()返回INVALID_INDEX?
程序在使用前正確鏈接並傳遞正確的ID。此外,沒有設置opengl錯誤。任何解釋?
#version 410
uniform CBPostProcessVS
{
vec4 f4_Proj2DTo3D;
} postProcessVS;
uniform CBDraw2DQuadVS
{
vec4 f4_PositionOffsetAndScale;
vec4 f4_TexcoordOffsetAndScale;
} draw2DQuadVS;
in vec3 vPosition;
in vec2 vTexcoord0;
in vec4 vColor0;
in vec3 vTangent;
in vec3 vBinormal;
in vec3 vNormal;
out vec2 v_vTexcoord0;
out vec3 vPosFactor;
void main()
{
vec2 pos = (vec2(vPosition) * draw2DQuadVS.f4_PositionOffsetAndScale.zw) + vec2(draw2DQuadVS.f4_PositionOffsetAndScale);
vec2 uv = (vec2(vTexcoord0) * draw2DQuadVS.f4_TexcoordOffsetAndScale.zw) + vec2(draw2DQuadVS.f4_TexcoordOffsetAndScale);
gl_Position = vec4(pos,0,1);
v_vTexcoord0 = uv;
vPosFactor.xy = uv * vec2(postProcessVS.f4_Proj2DTo3D) + postProcessVS.f4_Proj2DTo3D.zw;
vPosFactor.z = 1.0;
}