NOAH IV

02-03-2001, 09:09 AM

Hi, my glDrawArrays is drawing nothing... Please, is this the right

way to implement it?

This is what I'm doing:

// at the inicialization I do this:

glEnableClientState(GL_VERTEX_ARRAY);

// then, first I get the number of memory spaces

int NumberOfElements = ....->Counter();

// each element has 4 vertices and each vertice has 3 coordinates

int NumberOfMemorySpaces = 4*3*NumberOfElements;

VertexArray = (float *)calloc(NumberOfMemorySpaces,sizeof(GL_FLOAT));

int ArrayIndex = 0;

// then I put the coordinates in the array like this:

// ( and this is what I think is wrong... )

for( int i=0; i<NumberOfElements; i++)

{

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex1.x;

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex1.y;

VertexArray[ArrayIndex++] = 0.0;

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex2.x;

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex1.y;

VertexArray[ArrayIndex++] = 0.0;

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex2.x;

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex2.y;

VertexArray[ArrayIndex++] = 0.0;

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex1.x;

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex2.y;

VertexArray[ArrayIndex++] = 0.0;

}

// then I assign the pointer with that:

glVertexPointer(3, GL_FLOAT, 0, VertexArray);

//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

// This is what I do when I want to draw the elements:

glDrawArrays(GL_QUADS, 0, NumberOfElements);

Thanks

way to implement it?

This is what I'm doing:

// at the inicialization I do this:

glEnableClientState(GL_VERTEX_ARRAY);

// then, first I get the number of memory spaces

int NumberOfElements = ....->Counter();

// each element has 4 vertices and each vertice has 3 coordinates

int NumberOfMemorySpaces = 4*3*NumberOfElements;

VertexArray = (float *)calloc(NumberOfMemorySpaces,sizeof(GL_FLOAT));

int ArrayIndex = 0;

// then I put the coordinates in the array like this:

// ( and this is what I think is wrong... )

for( int i=0; i<NumberOfElements; i++)

{

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex1.x;

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex1.y;

VertexArray[ArrayIndex++] = 0.0;

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex2.x;

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex1.y;

VertexArray[ArrayIndex++] = 0.0;

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex2.x;

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex2.y;

VertexArray[ArrayIndex++] = 0.0;

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex1.x;

VertexArray[ArrayIndex++] = (float)Obs[i]->Vertex2.y;

VertexArray[ArrayIndex++] = 0.0;

}

// then I assign the pointer with that:

glVertexPointer(3, GL_FLOAT, 0, VertexArray);

//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

// This is what I do when I want to draw the elements:

glDrawArrays(GL_QUADS, 0, NumberOfElements);

Thanks