PDA

View Full Version : glDrawArrays doesn't work like glDrawElements



WhatEver
11-14-2002, 02: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).]

WhatEver
11-14-2002, 03: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.

Nutty
11-15-2002, 12:21 AM
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.

Nutty

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

Thanks Nutty!