I am embarassed with the follwoing problem. Can someone pick out the bug here. Thanks.
I have assigned this:
glVertexPointer(3, GL_FLOAT, 0, MeshPArray );
MeshPArray[i][3] stores the whole vertexes.
MeshStripIndex[i][j]] stores the index of each vertex in the triangle strips
for(i=0;i<TotalStripNum;i++)
{
glBegin(GL_TRIANGLE_STRIP);
for(j=0;j<MeshStripLength[i];j++)
{
///Why this works
glVertex3fv(MeshPArray[MeshStripIndex[i][j]]);
///Why this wrong
//glArrayElement(MeshStripIndex[i][j]);
}
glEnd();
}
[This message has been edited by foollove (edited 04-09-2003).]
Hi,everyone here,
sorry again.
Whether we can not use vertex array whose memory is allocated dynamicly.
Such as:
float **Mesh instead of
float Mesh[100][3].
In my program I found the traditional vertex array can not work if the vertex data is allocated by “new”.
Am I right?
Thanks a lot.
Did you remember to enable vertex arrays with glEnableClientState?
As with using vertex arrays with data allocated using ‘new’ I’ve never had any problems doing that, and I can’t see why it should be any different from using memory allocated in any other way!
To rgpc:
Thanks a lot.
I tried float Mesh =new float[CtrlNumMeshNum3], it works.
But I wonder why the following dont work.
float *Mesh;—>Mesh[i][j]
Mesh = new float[CtrlNumMeshNum];
for(i=0;i<CtrlNum*MeshNum;i++)
Mesh[i] = new float[3];
Why?
Can someone tell me?
[This message has been edited by foollove (edited 04-10-2003).]
Well… what you were creating are multidimensional arrays. What that means is that you certainly can’t guarantee that all the data is in the same memory space.
For example: if you have a mesh of 30x30 vertices, you can’t guarantee that MeshIndex[1][0] comes right after MeshIndex[0][29]. Multidimensional arrays can be spread all over your memory space!
I already did. You are allocating an array of pointers and hanging your float[3]'s off that array. What you end up passing is not the array of floats that is expected, but you end up passing an array of pointers. They are two completely different things.