PDA

View Full Version : Question about indexArray types



HopefullyAnUnusedName
05-20-2004, 04:48 AM
Table 2.4 p. 24 of the 1.4 spec lists among others 'int' as a type for index arrays. On p. 26 same doc. it states that drawElements requires indices of type ubyte, ushort or uint.

Can the index arrays be used for something I'm not aware of, or is this simply a minor glitch in the documentation?

J.O.

plasmonster
05-20-2004, 05:38 AM
That table is for source data types in the gl*Pointer() calls, not index types. All the index types for glDrawElements() are unsigned.

HopefullyAnUnusedName
05-20-2004, 06:04 AM
Aha...! So maybe I don't need to define an index array with IndexPointer, and enabling client state INDEX_ARRAY, then, ...?! Maybe something here I've misunderstood all the time...

plasmonster
05-20-2004, 06:13 AM
What exactly are you trying to do?

If you have vertex data, say, then you give the gl a pointer to it using glVertexPointer(...), then DrawElements(...) with your indices. It all depends on what you want to do, and how your data are organized.

HopefullyAnUnusedName
05-20-2004, 07:18 AM
Hi, thanks for the interest... I have a pool of vertices (hence glVertexPointer and NormalPointer to set up corresponding arrays.)

Then I have a list of integer triples which are cursors into these lists, defining a set of triangles.

I thought I should call IndexPointer with this latter array, then enable the three states for vertex, normal and index, and finally issue a call to DrawElements with type TRIANGLES, the number of triangles times 3 (total number of vertices involved in the set of triangles), my "cursor type" (now unsigned, previously just int) and finally the index array (same as last param I used for the indexPointer-call...)

Now you got me realize that I don't need the indexArray for this... Must look up what it's for, then... :-)

My next problem is that even though I include glext.h (from Nvidia) it doesn't declare glBindBufferARB as expected. Sigh.

plasmonster
05-20-2004, 07:26 AM
Your triangle setup seems reasonable to me.

As for the new problem, you can get all the latest headers and extension specs here
http://oss.sgi.com/projects/ogl-sample/registry/

HopefullyAnUnusedName
05-20-2004, 07:54 AM
Thanks for the link. I was attempting to use the ARB_vertex_buffer_object extension, but it seems it isn't supported by Nvidia after all. (Even though they say so on their web. Maybe it's only for Windows drivers, not Linux, I don't know...)

HopefullyAnUnusedName
05-20-2004, 09:45 AM
Ahh... I just needed to wrap the prototypes in an extern "C" {...} and then it worked...

Just pumping out GL_TRIANGLES has been fast enough for a long time, but now I needed some more. From GL_TRIANGLES at 16 fps, to classic vertex arrays at 23 fps, to VBOs at 111 fps is not bad! A sevenfold increase...
:)

plasmonster
05-20-2004, 10:52 AM
A seven fold increase is a bargain at any price. :)