PDA

View Full Version : Q about glDrawRangeElements



V-man
12-26-2003, 10:01 PM
GLuint ind[]={0, 1, 2, 3};
GLfloat vert[]={0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3};
glVertexPointer(3, GL_FLOAT, 0, vert);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawRangeElements(GL_POINTS, 0, 1, 4, GL_UNSIGNED_INT, ind);
glDisableClientState(GL_VERTEX_ARRAY);

-----------------
Shouldn't the above code cause glGetError to return an error.
Notice that start = 0 and end = 1

The spec just says that end should not be smaller than start.

jwatte
12-27-2003, 08:50 AM
No, the indices are not validated. This code may result in undefined behavior, however, similar to passing a bad pointer into VertexPointer().

V-man
12-27-2003, 02:08 PM
Are you sure about the indices not getting validated?

Sounded like Cass was saying they have to validate indices in another thread. It was about glDrawArrays or glDrawElements...

I also tried

start = 0
end= 4000000 (and other large numbers)

on ATI but it wasn't crashing.
I guess it's true that they ignore this extension.

idr
12-27-2003, 07:27 PM
The extension spec (http://oss.sgi.com/projects/ogl-sample/registry/EXT/draw_range_elements.txt) says that "Index values which lie outside the range will cause implementation-dependent results." The spec doesn't require the driver do any validation, but the hardware may. If you give an index out of the range you specify, it may work, it may crash, it may cause a police SWAT team to burst into your house and take you to jail. It's all implementation-dependent. http://www.opengl.org/discussion_boards/ubb/smile.gif