View Full Version : glDrawArrays doesn't work like glDrawElements

11-14-2002, 01:58 PM
Shouldn't these two functions produce the same thing? If I used glDrawArrays I get some really screwed up looking scene.

glDrawElements(GL_TRIANGLES, nFaces*3, GL_UNSIGNED_INT, Tris);
glDrawArrays( GL_TRIANGLES, 0, nFaces*3);

My indices are unsigned ints, is that the problem? Is glDrawArrays assuming unsigned shorts?

[This message has been edited by WhatEver (edited 11-14-2002).]

11-14-2002, 02:06 PM
I think I see the problem. glDrawArrays assumes there's a unique vertex for each corner of every triangle. Am I right? I see you can't specify indices so that makes sense.

11-14-2002, 11:21 PM
Yes DrawArrays doesn't use indices, so you need exactly 3 vertices in the aray per triangle.

As a side note, you wont get benefit of the gpu vertex cache if you dont use indexed mode.


11-15-2002, 12:05 PM
Now that I understand, glDrawArrays can't be used efficiently. It's a good thing I used indices then.

Thanks Nutty!