Vertex Array Problem

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!

Are you using glDrawElements or glDrawArrays?

-Lev

Yes!!! g

Your pointData array must be contiguous. Allocate it with

pointData = new float [dimdim3];

and initialize with

pointData [y * dim * 3 + x] = x_coord;
pointData [y * dim * 3 + x + 1] = y_coord;
pointData [y * dim * 3 + x + 2] = z_coord;

Regards,
-velco

[This message has been edited by velco (edited 05-28-2002).]

It sounds logical and I tried your code, but now my program crashes…g

I´ve started to calculate a little and here´s my result:
Let´s imagine a 443 array (dim=4).
So we allocate an array with the size 48.

And now access the 3rd parameter of the last entry with coordinates x=3, y=3.
Teh index would be: (3 * 4 * 3) + 3 + 2 = 41…so 41 is the biggest reachable index with this formula. Something´s wrong here, or am I wrong?

[This message has been edited by TheBlob (edited 05-28-2002).]

Uh, oh, it should be

pointData[ y * dim * 3 + x * 3 + 0] = x;
pointData[ y * dim * 3 + x * 3 + 1] = y;
pointData[ y * dim * 3 + x * 3 + 2] = z;

Originally posted by TheBlob:
Yes!!! g

I was actually asking which one of the two, but well

-Lev

Oh…I´m trying glDrawArrays.