# Vertex Arrays

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

Does it draw anything of maybe dose not draw the last Triangle?

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

for(iy=0; iy < 5; iy++) // Process 5 sides
{
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:
[b]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[/b]

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

Why don’t you want to use glDrawElements?

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

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?

Why don’t you post your glDrawArrays code so maybe we can see why it’s not working?

J.

Originally posted by darkbyte:
[b]Why don’t you post your glDrawArrays code so maybe we can see why it’s not working?

J.[/b]

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

Do I have to use glVertexPointer before glDrawArrays? How to call glDrawArrays (what parameters)?

thanks

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.