1

我在程序中使用以下顶点着色器,但由于某种原因,glGetUniformBlockIndex(id, "draw2DQuadVS")返回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;
    }
4

1 回答 1

9
glGetUniformBlockIndex(id, "draw2DQuadVS")

draw2DQuadsVS不是统一块名称。块的名称是CBDraw2DQuadVSdraw2DQuadsVS只是块范围的 GLSL 名称。

更多信息可以在OpenGL Wiki 页面上找到。

于 2012-05-05T16:30:42.833 回答