【发布时间】:2019-04-22 15:23:46
【问题描述】:
我多次尝试重写以下代码,但都失败了,我知道我必须使用 glCreateBuffers、glVertexArrayElementBuffer、glVertexArrayVertexBuffer、glnamedBufferData、glBindVertexArray 等函数,但我在替换 glBindBuffer、glVertexAttribPointer、glEnableVertexAttribArray 和 glGetAttribLocation 的部分有问题。
这是我尝试实现的以下代码:
glCreateBuffers(1, &phong.vbo);
glNamedBufferData(phong.vbo,sizeof(modelVertices),modelVertices,GL_STATIC_DRAW);
glCreateBuffers(1, &phong.ebo); glNamedBufferData(phong.ebo,sizeof(modelIndices),modelIndices,GL_STATIC_DRAW);
glCreateVertexArrays(1, &phong.vao);
glBindVertexArray(phong.vao);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, phong.ebo);
glBindBuffer(GL_ARRAY_BUFFER, phong.vbo);
const GLint possitionAttribute = glGetAttribLocation(phong.program, "position");
glVertexAttribPointer((GLuint) possitionAttribute, 3, GL_FLOAT, GL_FALSE,
sizeof(GLfloat) * 6, (const GLvoid *) 0 );
glEnableVertexAttribArray((GLuint) possitionAttribute);
【问题讨论】: