Reputation: 179
I have two variables that I'm getting from shader in opengl. I do something like this.
vLoc = glGetAttribLocation(progId,"vPosition");
nLoc = glGetAttribLocation(progId,"vNormal");
matViewLoc = glGetUniformLocation(progId,"matView");
matProjLoc = glGetUniformLocation(progId,"matProj");
matTranslateLoc = glGetUniformLocation(progId,"matTranslate");
vLoc and projLoc return the same location. Would anybody know why? Thanks!
Upvotes: 1
Views: 293
Reputation: 56407
The space for uniform locations and attribute locations is different, so you can have same IDs, but they refer to different objects.
You can't pass a attribute location to a glUniform function or a uniform location to a attrib function.
Upvotes: 4
Reputation: 103
did you bind the attrib location when you created the shader program using glBindAttribLocation?
You need something like this:
glBindAttribLocation(progId, 0, "vPosition");
glBindAttribLocation(progId, 1, "vNormal");
Upvotes: 0