qdii
qdii

Reputation: 12983

Why does glGetUniformBlockIndex() return INVALID_INDEX?

I’m using the following vertex shader in a program, but for some reason, glGetUniformBlockIndex(id, "draw2DQuadVS") returns INVALID_INDEX.

The program is linked correctly before being used and the correct id is passed. Furthermore, no opengl error is set. Any explanation?

    #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;
    }

Upvotes: 2

Views: 2127

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 474436

glGetUniformBlockIndex(id, "draw2DQuadVS")

draw2DQuadsVS is not the name of the uniform block. The name of the block is CBDraw2DQuadVS. draw2DQuadsVS is just the GLSL name of the block's scope.

More information can be found on the OpenGL Wiki page.

Upvotes: 9

Related Questions