This topic is now archived and is closed to further replies.

glVertexArray vs glVertexArrayEXT

This topic is 5703 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok, so whats the difference? i have been writing aloader for extensions that has been driving me crazy , and i find out that there is a non extension version of it? whats the deal, is this right, or am i nutz? and also, how would i go about using vertex arrays for drawing a terrain patch when the info is stored in a 2d matrix? thankx

Share this post

Link to post
Share on other sites
Original post by razialx
stored in a matrix?


To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post

Link to post
Share on other sites
If you''re talking about something like rendering from a heightmap, you can''t do it directly. What I do is read in the heightmap, and use that to create a vertex array with one element for every point in the heightmap, and then create an index array into that.

Share this post

Link to post
Share on other sites
right, ok, my vertexes are stored in a 2d matrix as such
struct Vec3
float x,y,z;

Vec3 Map[256][256];
and the nodes for my quadtree use an x, y, halfwidth type approach to get the coordinates.
how would i use vertex arrays to render quads from this? because, i know if i set teh pointer to on row, like map[22][22], it doesn''t know to look at map[22][23] to get the other vertexs, and i don''t nkow how to use an index array, cus in a ll the whitepages, it says that the index array is for color? anyway, anything would help, especially a code snippet. thanx

Share this post

Link to post
Share on other sites
you dont need the indexarray but you need an indexarray

well.. to clarify..

you specify your array with the different parts each vector does have

glVertexArray //the position for each vertex
glNormalArray //the normal for each vertex
glIndexArray //the index to a colorarray for each vertex, used for 256-color-modes, 8bit colors with palettes
glColorArray //an array of floats wich represent colors, used for 16bit or 32bit color modes..
glTexCoordArray //texcoords for each vertex


you call glDrawElements

in drawelemtns you say what type of elements, like for example GL_TRIANGLES or GL_QUADS or something
how much
and the indexarray you want to use..

this indexarray will index into all those arrays from above to get the current vertex out..

for your heightmap it works for example like this:

#define SIZE 64

float pos[SIZE][SIZE][3];
float nrml[SIZE][SIZE][3];
float texcoord[SIZE][SIZE][2];

glNormalPointer(GL_FLOAT,0,nrml); //its always 3 components, so they dropped this

now you need indecees for your heightmap.. for every triangle you want to draw 3..

you have (SIZE-1)*(SIZE-1)*2 triangles on your heightmap resulting in (SIZE-1)*(SIZE-1)*6 indecees..

unsigned short indices[SIZE-1][SIZE-1][6];

for(int x=0;x for(int y=0;y indices[x][y][0] = x + SIZE*y;
indices[x][y][0] = (x+1) + SIZE*(y+1);
indices[x][y][0] = (x+1) + SIZE*y;
indices[x][y][0] = x + SIZE*(y+1);
indices[x][y][0] = (x+1) + SIZE*(y+1);
indices[x][y][0] = x + SIZE*y;

why exactly this?
take a shit of paper and you''ll find it out yourself

then you call



"take a look around" - limp bizkit

Share this post

Link to post
Share on other sites
aaahh, thank you so much, see, my problem was i was trying to use DrawArrays, not DrawELements, which can use index thingys, sweet, thanks a hella lot

Share this post

Link to post
Share on other sites