TheBlob
05-28-2002, 09:26 AM
I´m trying to convert my *working* code for a heightfield from ImmidiateMode to Vertex Arrays, but I encounter problems (would be crazy if it worked without problems *g*).
All data is stored and precalculated in one of my classes.
Then I wanted to copy all data out of the classes into Arrays, so I can use Vertex Arrays:
Here´s my code:
float **pointData;
pointData = new float *[MAP_DIMENSION*MAP_DIMENSION];
for(int y=0; y<MAP_DIMENSION; y++)
{
for(int x=0; x<MAP_DIMENSION; x++)
{
pointData[((y)*field_dim)+(x)] = new float [3];
pointData[((y)*field_dim)+(x)][0] = heightfield[((y)*field_dim)+(x)].point.x;
pointData[((y)*field_dim)+(x)][1] = heightfield[((y)*field_dim)+(x)].point.y;
pointData[((y)*field_dim)+(x)][2] = heightfield[((y)*field_dim)+(x)].point.z;
}
}
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, pointData);
I think it´s quite clear, what I´m doing....
When I´m rendering the scene using no Vertex Arrays I´m just looping through each point with two for-loops, as I have done above.
But the problem for the Vertex Arrays is maybe that OpenGL accesses the indices in a diffrent way.
So nothing is rendered (but the performance goes down, so I guess, you just can´t see the triangles)
Has anybody an idea?? Please!!
Thanks in Advance!
All data is stored and precalculated in one of my classes.
Then I wanted to copy all data out of the classes into Arrays, so I can use Vertex Arrays:
Here´s my code:
float **pointData;
pointData = new float *[MAP_DIMENSION*MAP_DIMENSION];
for(int y=0; y<MAP_DIMENSION; y++)
{
for(int x=0; x<MAP_DIMENSION; x++)
{
pointData[((y)*field_dim)+(x)] = new float [3];
pointData[((y)*field_dim)+(x)][0] = heightfield[((y)*field_dim)+(x)].point.x;
pointData[((y)*field_dim)+(x)][1] = heightfield[((y)*field_dim)+(x)].point.y;
pointData[((y)*field_dim)+(x)][2] = heightfield[((y)*field_dim)+(x)].point.z;
}
}
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, pointData);
I think it´s quite clear, what I´m doing....
When I´m rendering the scene using no Vertex Arrays I´m just looping through each point with two for-loops, as I have done above.
But the problem for the Vertex Arrays is maybe that OpenGL accesses the indices in a diffrent way.
So nothing is rendered (but the performance goes down, so I guess, you just can´t see the triangles)
Has anybody an idea?? Please!!
Thanks in Advance!