PDA

View Full Version : ARB_compiled_vertex


rogerdv
07-24-2003, 08:11 AM
Can somebody provide a simle example about how to use compiled vertex arrays? I know it is almos tobsolete, but it is the only extension supported by my video card.

anubis
07-25-2003, 02:48 AM
sure, i have some old code flying around... should i just send it to you by email ???

davepermen
07-25-2003, 05:04 AM
bether drop it in here.. so it get "backed up" for the world

anubis
07-25-2003, 06:17 AM
sure !
hm, it might not be able to post it before tonight though... sry...
anyway, i hope it will be helpful

anubis
07-26-2003, 07:19 AM
sorry, i couldn't find the code file. maybe it got deleted during one of the last windows reinstalls i did... sorry that i couldn't help

anubis
07-27-2003, 03:13 AM
well, actually there isn't much code to supply anway... :)
just load the extension and then you just have to wrap your drawing routines with calls to


glLockArraysEXT(first_element, count);

glDrawElemets(...);

glUnlockArraysEXT();

davepermen
07-27-2003, 06:46 AM
and it normally only helps for multipass (means a lot of glDrawElements calls between the lock and unlock)

anubis
07-27-2003, 01:57 PM
right, that would be the only real advantage of this extension. like if you are drawing one object over and over again.

rogerdv
07-28-2003, 05:56 AM
Just that? Seems less clear that vertex buffers. Does it allow to optimize a 3ds model drawing?

UnknownStranger
07-28-2003, 06:00 AM
Well, it's surely faster than calling glVertexXY for every vertex ;)

davepermen
07-28-2003, 06:42 AM
Just that? Seems less clear that vertex buffers. Does it allow to optimize a 3ds model drawing?
as we said yet: if you do multipassing for making fancy material effects or so on your meshes, then yes.

Julio
07-28-2003, 09:50 AM
got some sample code on my site: here (http://julio.programmers-unlimited.com)

davepermen
07-28-2003, 10:55 AM
i forgot!!

on OpenGL on Nutty.org (http://opengl.nutty.org), there is a demo with source as well!!

here (http://opengl.nutty.org/extensions/compiledarrays.zip) is the direct link..

This shows how to use COMPILED VERTEX ARRAYS (CVA's). Using the Lock and Unlock functions, we can tell OpenGL that the vertices will not be modified, so it can cache the transformed vertices from the last pass, in multi pass rendering.

Uses a nice trick to depth sort the transparent object.

Uses Glut.

rogerdv
07-30-2003, 09:39 AM
glDrawElements is any gl drawing function like glVertex?

rogerdv
07-30-2003, 09:46 AM
Another doubt, how can compiled vertex optimize drawing of animated models? I think, as the vertex coordinates changes, you need to *recompile* the vertex list, isnt it?

Ed Mack
07-30-2003, 10:46 AM
Really you'd use vertex lists for complicated stuff you replicate a lot, say like a patch of grass that gets duplicated lots to make a randomish field, or some statue in your game. Animation models are usually not too complicated and tweened/boned in realtime

anubis
07-30-2003, 12:21 PM
rogerdv : usually you store an object's geometry in object space. when you draw the object you simple apply the object's view matrix to scene and render the object. this way you never need to apply all the transformations and rotations to the object's vertices yourself.

yes, glDrawElements is an opengl drawing function it gets passed a list of indices that you want opengl to draw from a set of previously passed vertices. vertex data is passed like this. since you specifically asked for the compiled vertex array extension i assumed that you are familar with regular vertex buffers


glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, your_vertex_data_here);

glDrawElements(GL_TRIANGLES, number_of_indices, GL_UNSIGNED_INT, index_data);


additionally you can also enable and pass the following data to opengl

GL_NORMAL_ARRAY
GL_COLOR_ARRAY
GL_TEXTURE_COORD_ARRAY

the names shuold be self explanatory...

donBerto
07-31-2003, 02:47 PM
off-topic

anubis: well-explained.

simply put, models that don't change are best placed in a vertex array.

:yes:

davepermen
08-03-2003, 02:26 PM
Another doubt, how can compiled vertex optimize drawing of animated models? I think, as the vertex coordinates changes, you need to *recompile* the vertex list, isnt it?
as i said, only for multipass, means drawing the EXACTLY SAME MESH several times A FRAME!

it doesn't even help over different frames.. as locking means transformation, and in every new frame, you transform the mesh slightly different (as your camera moves..)