GLuint vBuffer;
glGenBuffers(1, &vBuffer);
glBindBuffer(GL_ARRAY_BUFFER, vBuffer);
int totalSize = sizeof(tempVertexList);
glBufferData(GL_ARRAY_BUFFER, totalSize, tempVertexList, GL_STREAM_DRAW);
glDrawArrays(GL_TRIANGLE_STRIP, 0, vertexCount);
这个代码在涉及到glDrawArrays时崩溃了,任何明显的原因我都错过了? vertexCount为4,tempVertexList用4个定义为
的顶点结构填充typedef struct
{
float Position[3];
float Colour[4];
} Vertex;
答案 0 :(得分:0)
glVertexAttribPointer(positionSlot, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
glVertexAttribPointer(colorSlot, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)(sizeof(float)*3));
每次更改GL_ARRAY_BUFFER时都需要调用,不知道刚刚发现:)