• Announcements

Archived

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

Vertex array/indices problem?

Recommended Posts

Sirveaux    122
I am having trouble generating a vertex array and the indices for it. From what I can tell, my algorithm works right, though. I am trying to create a vert array for a 10x10 grid and then use the indices to point to them and get them to make a grid of 9x9 quads. Is there a mistake in my calculates or am I doing the wrong format? Maybe it's something with my calls to glVertexPointer or glDrawElements that is the problem?

i=0;
for (vy=0;vy<10;vy++)
{
for (vx=0;vx<10;vx++)
{
vertices[i] = (float)vx;
vertices[i+1] = (float)vy;
vertices[i+2] = 0.0;
i+=3;
}
}

for (i=0;i<(9*9*4);i+=4);
{
indices[i] = (i/4);
indices[i+1] = (i/4)+1;
indices[i+2] = (i/4) + 1 + 10;
indices[i+3] = (i/4) + 10;
}

...snip...

//These are how my calls to actually display the data look:

glVertexPointer ( 3, GL_FLOAT, 0, &vertices );
glDrawElements  ( GL_QUADS, (9*9*4), GL_UNSIGNED_INT, indices );



Share on other sites
Wingman    167
Em, what EXACTLY is your problem?

However, this might help (it worked for me):

glDrawElements ( GL_QUADS, (9*9*4), GL_UNSIGNED_BYTE, indices );

[edited by - Wingman on July 8, 2003 11:07:49 AM]

Share on other sites
Sirveaux    122
I can''t get it to display at all. So using my algorithm it works fine for you? Maybe I''m just not doing something right with my transformations to get it into view then. Hmm... I''ll try it as a byte instead of an int and see if that helps any.