opengl vertext shader error: Too much data in type constructor

Please, help. What's problem in simple vertex shader code below. 0(12) : error C1068: too much data in type constructor

#version 450

void main()
{   
    const vec2[6] Q = { vec2(-0.5,-0.5),
                        vec2( 0.5,-0.5),
                        vec2(-0.5, 0.5),

                        vec2(-0.5, 0.5),
                        vec2( 0.5,-0.5),
                        vec2( 0,5, 0.5)
    };
    gl_Position = vec4(
        Q[ gl_VertexID ].x,
        Q[ gl_VertexID ].y,
        0.0,
        1.0
    );
}

Upvotes: 0

Views: 569

Answers (1)

Robinson
Robinson

Reputation: 10122

You can initialise an array in glsl like this (similar to C++11):

const vec2 Q[6] = { 
    { -0.5, -0.5 },
    {  0.5, -0.5 },
    { -0.5,  0.5 },
    { -0.5,  0.5 },
    {  0.5, -0.5 },
    {  0.5,  0.5 }
};

Not sure if you noticed the deliberate error in your example. The last line has a comma where it should have a ".".

Upvotes: 3

Related Questions