Hello everyone,
I have a problem with glMultiDrawElements() that I am unable to resolve. I am testing code as I read the red book. My code is as follows:
static GLint vertices[] = {-250, 0, 0,
0, 250, 0,
250, 0, 0,
0, -250, 0,
-400, -300, 0,
0, -300, 0,
0, -450, 0,
-400, -450, 0};
static GLfloat colors[] = {0.0, 1.0, 1.0,
0.0, 0.0, 1.0,
1.0, 0.0, 0.0,
0.0, 1.0, 1.0,
0.0, 1.0, 1.0,
0.0, 1.0, 1.0,
0.0, 1.0, 1.0,
0.0, 1.0, 1.0};
static GLint edges[] = {1, 1, 1, 1, 1, 1, 1, 1};
glColorPointer(3, GL_FLOAT, 0, colors);
glVertexPointer(3, GL_INT, 0, vertices);
glEdgeFlagPointer(0, edges);
static GLubyte ind1[] = {0, 1, 2, 3};
static GLubyte ind2[] = {4, 5, 6, 7};
static GLsizei count[] = {4, 4};
static const GLvoid * indices[] = {ind1, ind2};
glMultiDrawElements(GL_LINE_STRIP, count, GL_UNSIGNED_BYTE, indices, 2);
In constrast to the example in the book, I had to change the definition of the indices array from just “static” to “static const”, because the drawing function would not accept it otherwise, since it demands an argument of type “const GLvoid **” and not just “GLvoid **”. My change makes the code compile, but it always spits out an access violation. I set up some breakpoints with a debugger and checked the pointer values of indices. They both point correctly to the respective ind1 and ind2 arrays.
Using glDrawElements() in a loop instead works fine for me, but this I simply cannot figure this out. I found another thread on this but the person didn’t describe how they solved the problem in the end, so any help would be appreciated
If it helps, I am using OpenGL version 3.0 and Visual Studio 2010 as my compiler.