有没有办法覆盖或清除 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
有没有办法清除以前绑定的位置,以便我可以绑定新的位置?