PDA

View Full Version : Vertex Arrays



yaro_dup1
02-25-2003, 11:22 AM
Hi,

How to draw the array which I'm drawing that:
glBegin(GL_TRIANGLES);
for (UINT i = 0; i < VertexArraySize[id]; i+=3)
{
glVertex3f(VertexArray[id][i], VertexArray[id][i+1], VertexArray[id][i+2]);
}
glEnd();

using glVertexArray?

I want to draw whole array without using glDrawElements. I've tried glDrawArrays but it doesn't work and I don't know where is the mistake.

thanks

nexusone
02-25-2003, 12:11 PM
Does it draw anything of maybe dose not draw the last Triangle?

Is your VertexArraySize correct?

Here is a little code I used for building prymids from an array:

for(iy=0; iy < 5; iy++) // Process 5 sides
{
glBegin(GL_QUADS);
for(ix=0;ix < 3;ix++) // Process one side
{

glColor3dv( pryamidc[ix +(3 * iy)]);
glVertex3dv( &pryamid[ix + (3 * iy)]);

}
glEnd();


But just from the first look at your code, it looks ok.


Originally posted by glYaro:
Hi,

How to draw the array which I'm drawing that:
glBegin(GL_TRIANGLES);
for (UINT i = 0; i < VertexArraySize[id]; i+=3)
{
glVertex3f(VertexArray[id][i], VertexArray[id][i+1], VertexArray[id][i+2]);
}
glEnd();

using glVertexArray?

I want to draw whole array without using glDrawElements. I've tried glDrawArrays but it doesn't work and I don't know where is the mistake.

thanks

yaro_dup1
02-26-2003, 08:26 AM
Hi,

My first code works OK but if I try to use glDrawArrays it doesn't work. VertexArraySize is OK but nothing is rendered with DrawArrays.

yaro

Punchey
02-26-2003, 08:30 AM
Why don't you want to use glDrawElements?

yaro_dup1
02-26-2003, 12:38 PM
Originally posted by Punchey:
Why don't you want to use glDrawElements?

Because to use glDrawElements I have to make create an array with indices of my VertexArray elements and pass a pointer to this array as an argument in
glDrawElements(enum mode, sizei count, enum type, void *indices),
don't I?
Looking above I have to create array with indices for every VertexArray I use.
I'm searching for way to draw VertexArray
using one function, not creating else arrays.

yaro

W. C. Picker
02-26-2003, 12:56 PM
glDrawArrays() will do, Jaro

by the way, the manual on this site used to cover these topics, but it does not anymore. it was terribly cut. why?

darkbyte
02-26-2003, 02:43 PM
Why don't you post your glDrawArrays code so maybe we can see why it's not working?

J.

yaro_dup1
02-27-2003, 11:12 AM
Originally posted by darkbyte:
Why don't you post your glDrawArrays code so maybe we can see why it's not working?

J.

I've got better idea. Maybe You can post the code for rendering array called
GLfloat VertexArray[n];

with for example GL_TRIANGLES?

I'm searching for the fastest way to draw this array (by one function). I saw the extensions for vertex arrays, are those better then simple glVertexPointer and glDrawArrays?

thanks

yaro_dup1
02-28-2003, 12:02 PM
Do I have to use glVertexPointer before glDrawArrays? How to call glDrawArrays (what parameters)?

thanks

harsman
03-01-2003, 05:04 AM
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer( numComponents, GL_FLOAT, stride_which_probably_is_0_in_your_case, pointer_to_the_first_vertex);
glDrawArrays(...);


You should also check out the NeHe tutorials.