【发布时间】:2015-08-29 11:02:28
【问题描述】:
有没有办法覆盖或清除 OpenGL 中的属性位置? 例如(我正在使用 lwjgl)我渲染这样的东西:
public void render(int vaoID, int vertexCount, int shaderProgramID){
GL30.glBindVertexArray(vaoID);
GL20.glBindAttribLocation(shaderProgramID, 0, "position");
GL20.glBindAttribLocation(shaderProgramID, 1, "normal");
GL20.glEnableVertexAttribArray(0);
GL20.glEnableVertexAttribArray(1);
GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexCount);
GL20.glDisableVertexAttribArray(0);
GL20.glDisableVertexAttribArray(1);
GL30.glBindVertexArray(0);
}
然后我想用相同的 shaderProgramID 运行下一个代码
public void render(int vaoID, int vertexCount, int shaderProgramID){
GL30.glBindVertexArray(vaoID);
//this previously was position
GL20.glBindAttribLocation(shaderProgramID, 0, "normal");
//and this was the normal
GL20.glBindAttribLocation(shaderProgramID, 1, "position");
GL20.glEnableVertexAttribArray(0);
GL20.glEnableVertexAttribArray(1);
GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertexCount);
GL20.glDisableVertexAttribArray(0);
GL20.glDisableVertexAttribArray(1);
GL30.glBindVertexArray(0);
}
如您所见,我从这里更改了以下代码:
GL20.glBindAttribLocation(shaderProgramID, 0, "position");
GL20.glBindAttribLocation(shaderProgramID, 1, "normal");
到这里:
GL20.glBindAttribLocation(shaderProgramID, 0, "normal");
GL20.glBindAttribLocation(shaderProgramID, 1, "position");
但是当我运行这两个代码时,
GL20.glGetAttribLocation(programID, "position");
返回 0 而不是 1
有没有办法清除之前绑定的位置,以便我可以绑定新的位置?
【问题讨论】:
标签: java opengl shader lwjgl vao