Original Post
Greetings! I always have trouble when I try to go back and figure out how VBOs work. I did get them to work for a bit, but in a very non-efficient manner (basically binding/updating data on a per-quad basis in order to transition over from using immediate mode). I was trying to streamline the process, but now I can't even a basic example to work without throwing an unhandled exception. Here's the source code in all its inefficient glory. The 'VBOId's are all valid (1, 2, 3, and 4) after calling glGenBuffersARB(). The client states are all enabled. Is it possible that, through previous erroneous runs of the code, I've put the video driver in a bad state and simply need to reboot? Or am I doing something wrong in my code? Thanks.
int vertex[2][4] = {vertex_x1, vertex_y1,
vertex_x1, vertex_y2,
vertex_x2, vertex_y2,
vertex_x2, vertex_y1};
unsigned char color[4][4] = {255, 255, 255, 255,
255, 255, 255, 255,
255, 255, 255, 255,
255, 255, 255, 255};
float texture[2][4] = {texture_x1, texture_y2,
texture_x1, texture_y1,
texture_x2, texture_y1,
texture_x2, texture_y2};
unsigned int index[4] = {0, 1, 2, 3};
// Vertex
glBindBufferARB(GL_ARRAY_BUFFER, m_VertexVBOId);
glBufferDataARB(GL_ARRAY_BUFFER, sizeof(vertex), &vertex[0], GL_DYNAMIC_DRAW);
// Color
glBindBufferARB(GL_ARRAY_BUFFER, m_ColorVBOId);
glBufferDataARB(GL_ARRAY_BUFFER, sizeof(color), &color[0], GL_DYNAMIC_DRAW);
// Normal
glBindBufferARB(GL_ARRAY_BUFFER, 0);
// Texture
glBindBufferARB(GL_ARRAY_BUFFER, m_TextureVBOId);
glBufferDataARB(GL_ARRAY_BUFFER, sizeof(texture), &texture[0], GL_DYNAMIC_DRAW);
// Index
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, m_IndexVBOId);
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER, sizeof(index), &index[0], GL_DYNAMIC_DRAW);
// Bind the vertex data.
glBindBufferARB(GL_ARRAY_BUFFER, m_VertexVBOId);
glVertexPointer(2, GL_INT, 0, 0);
// Bind the color data.
glBindBufferARB(GL_ARRAY_BUFFER, m_ColorVBOId);
glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0);
// Bind the texture data.
glBindBufferARB(GL_ARRAY_BUFFER, m_TextureVBOId);
glTexCoordPointer(2, GL_FLOAT, 0, 0);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, m_IndexVBOId);
glDrawRangeElements(GL_QUADS,
0,
3,
4,
GL_UNSIGNED_INT,
NULL);