开发者

uniform variables same in opengl

I have two variables that I'm getting from shader in open开发者_运维技巧gl. 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!


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.


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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜