2012-05-05 54 views
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; 
    } 

回答

7
glGetUniformBlockIndex(id, "draw2DQuadVS") 

draw2DQuadsVS均勻塊的名稱。該塊的名稱是CBDraw2DQuadVSdraw2DQuadsVS只是塊範圍的GLSL名稱。

更多信息可在OpenGL Wiki page上找到。