Problems with glMultiDrawElementsEXT and Vertex Buffer Objects

I’m having problems using glMultidrawElements and Vertex Buffer Objects for indices and vertices. I have read all other posts abouts this, and it didn’t solve anything.
I can only get my application crashing when calling to glMultiDrawElementsEXT.

I won’t ask it again, so:
I would like you to post some peace of code getting that working, of send me the code to mail: jesus.gumbau AT anubis.uji.es.

Thanks in advance.

This is making me crazy:

When I render the geometry as:

glDrawElements(GL_TRIANGLE_STRIP, multidraw_count[0], GL_UNSIGNED_INT, multidraw_offsets[0]);

It works fine!!

But, only changing that line with the following one:

glMultiDrawElementsEXT(GL_TRIANGLE_STRIP,multidraw_count,GL_UNSIGNED_INT,(const void**)multidraw_offsets,1);

It crashes!! Why? Those two lines should be completely equivalent!

Can be a driver issue?

I need some help.

More over:

This works PERFECTLY:

for (i=0; i<TOTAL; i++)
    glDrawElements(GL_TRIANGLE_STRIP, *(multidraw_count+i), GL_UNSIGNED_INT, *(multidraw_offsets+i));

And this crashes:

glMultiDrawElementsEXT(GL_TRIANGLE_STRIP,multidraw_count,GL_UNSIGNED_INT,(const void**)multidraw_offsets,TOTAL);

I’m feeling crazy.

I don’t see any bad thing at first glance. You may have a look at your gl*EXT func (do you load those extensions well ?). According you use VBO without any problem, I might be wrong.

But according that you only use glDrawElements to compare your result, I wonder.

Hope this will help you.

You wrote:

glMultiDrawElementsEXT(GL_TRIANGLE_STRIP,multidraw_count,GL_UNSIGNED_INT,(const void**)multidraw_offsets,1);

glMultiDrawElementsEXT have following params:

void glMultiDrawElementsEXT( 
  GLenum mode,
  GLsizei *count,
  GLenum type,
  const GLvoid **indices,
  GLsizei primcount)

mode - GL_TRIANGLES or GL_TRIANGLE_STRIP or...
count - POINTER to system memory array that contain counts for each pointer in indices
type - GL_UNSIGNED_INT or some other GL type
indices - array of pointers to start pointer of each "subdraw" call.
primcount - number of pointers in batches 

In your case make sure in following:

  1. Count should be a SYSTEM MEMORY pointer to number of primitives for each batch… ie. count.size() MUST BE EQUAL to indices.size() and it EQUAL to primcount;
  2. If you use VBO to store indices pointer count and indices MUST BE in SYSTEM MEMORY but indices[n] MUST BE OFFSET in VBO MEMORY.
  3. Make sure that you really use unsigned int for indices.

btw… this code show how glMultiDrawElementsEXT really works:

  
for(i=0; i<primcount; i++) {
    if (*(count+i)>0) DrawElements(mode, *(count+i), type, *(indices+i));
	}

yooyo

Are you absolutely, definately, 100% sure you’re getting the address of glMultiDrawElementsEXT correctly?

Assuming you’re using Windows, look at All About OpenGL Extensions - particularly section 6 which is about getting function pointers in Windows.

dave j

Done! I have tested the same code on another computer (seems to have another drivers) and now it works! So it seems to be a driver issue.

Thanks to you all…

One question: do you note any kind of permorfance boost using multidrawelements instead of multiple drawelements calls?