proper use of gldrawrangeelements

i want to render only a part of my model. this is from my render routine. it works fine if i use glDrawElements to draw everything, but glDrawRangeElements as shown below doesn’t work. shouldn’t this actually only render from index 12 to 48?! or what am i doing wrong?!

	glEnableClientState( GL_VERTEX_ARRAY );
	glBindBufferARB( GL_ARRAY_BUFFER, Vertices->Id );
	glVertexPointer( 3, GL_FLOAT, 0, 0 );

	glEnableClientState( GL_NORMAL_ARRAY );
	glBindBufferARB( GL_ARRAY_BUFFER, Normals->Id );
	glNormalPointer( GL_FLOAT, 0, 0 );

	glEnableClientState( GL_TEXTURE_COORD_ARRAY );
	glBindBufferARB( GL_ARRAY_BUFFER, Coordinates->Id );
	glTexCoordPointer( 2, GL_FLOAT, 0, 0 );

	glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER, Indices->Id );
	glDrawRangeElements( GL_TRIANGLES, 12, 48, 36, GL_UNSIGNED_INT, 0 );

	glDisableClientState( GL_VERTEX_ARRAY );
	glDisableClientState( GL_NORMAL_ARRAY );
	glDisableClientState( GL_TEXTURE_COORD_ARRAY );

	glBindBufferARB( GL_ARRAY_BUFFER, 0 );
	glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER, 0 );

sry i know there have been ten thousand people asking sth like that before but i searched the forum and didn’t find a hint :stuck_out_tongue:

You have misunderstood start and end. They are the first and last indexed elements (referenced from the index array you specified) in the enabled arrays.

Google is your friend.

thanks, but i read the reference page before i posted. i still don’t get it. what would i have to do instead if i want to render a part of my model? thanks in advance!

You need to pass an offset into the index buffer as the last parameter. The 12 and 48 parameters in your case tells what range within the vertex buffer you’ll access through the indices in this call.

Seems you’ve misunderstood DrawRangeElements’purpose. It does not filter indices; it only informates driver which vertices are referred.

Spec:
glDrawRangeElementsEXT is a restricted form of glDrawElements. All vertices referenced by indices must lie between start and end inclusive. Not all vertices between start and end must be referenced, however unreferenced vertices may be sent through some of the vertex pipeline before being discarded, reducing performance from what could be achieved by an optimal index set. Index values which lie outside the range will cause implementation-dependent results.

d’oh… k thank you now it is clear :slight_smile:

sorry bout hijacking the thread
but i get no speed difference between drawrangeelements + draweleemtns when i use it in combination with VBO, with straight VAs there is an improvement.
btw this is tested in a benchmark