My GLSL vertex shader works fine, but you if put a for loop inside or rename the uniform xxx to something else, it says the follwoing:

Exception in thread "main" org.lwjgl.opengl.OpenGLException: Invalid operation (1282) at org.lwjgl.opengl.Util.checkGLError(Util.java:59) at org.lwjgl.opengl.GL20.glGetUniformLocation(GL20.java:664)

this is the method causing the problem:

protected void getAllUniformLocations()
    {

        location_transformationMatrix   = super.getUniformLocation("transformationMatrix");
        location_diffuseColor           = super.getUniformLocation("in_color");
        location_projectionMatrix       = super.getUniformLocation("projectionMatrix");
        location_lightPos               = super.getUniformLocation("lightPosition");
        location_lightColor             = super.getUniformLocation("lightColor");
        location_viewMatrix             = super.getUniformLocation("viewMatrix");
        location_specular               = super.getUniformLocation("specularLevel");
        location_boneTransformations    = new int[32]; 
        for(int i = 0; i < location_boneTransformations.length; i++)
            location_boneTransformations[i] = super.getUniformLocation("xxx["+i+"]");
    }

this is my vertex shader:

#version 400 core

//data from VBO
in vec3 position;
in vec2 texture_coordinates;
in vec3 normal;
//bone data
in int bone_pointer;
in float bone_intensity;
//vertex color output
out vec4 color;
//texture coordinates
out vec2 pass_texcoords;
out vec2 texCoord0;
//normal
out vec3 surface_normal;
//vector pointing towards the light
out vec3 to_light_vector;

//position, rotation, scale
uniform mat4 transformationMatrix;
//perspective projection
uniform mat4 projectionMatrix;
//TODO: material color
uniform vec3 in_color;
//camera viewmatrix
uniform mat4 viewMatrix;
//lights
uniform vec3 lightPosition;
uniform vec3 lightColor;
//skeleton data xxx = bone transformations
uniform mat4 xxx[];
uniform int group_indices[];
uniform float group_values[];
void main()
{
    for(int i = 0; i < group_indices.length(); i++)
    {

    }
    mat4 total_transform =  transformationMatrix;
    total_transform = total_transform * xxx[0];

    vec4 worldPosition;

    worldPosition =  total_transform * (vec4(position, 1)) ; // 

    vec4 pos =  projectionMatrix * viewMatrix * worldPosition;
    gl_Position = pos;

    //Texture
    pass_texcoords = texture_coordinates;

    //light
    surface_normal = (total_transform *  vec4(normal, 0)).xyz;
    to_light_vector = lightPosition * worldPosition.xyz; 

    //textures
     texCoord0 = texture_coordinates;

}
  • 1
    What is the question part of your question? – david van brink Mar 1 '15 at 23:52
  • for-loops in shader initialisation aren't even allowed, i think, so that makes perfect sense. – Timothy Groote Mar 2 '15 at 14:01

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.