hi,
i got this opengl/c++ code:
<code>
void render(CMesh *mesh){
...
float *pVertices;
int *pIndices;
//WORKS FINE
pVertices = (GLfloat *)mesh->getVertices( ); // (A)
//PROBLEMS HERE!!!!
pIndices = (int *)mesh->getFaceIndices (); // (B)
...
}
class:
int *CMesh::getFace Indices() const{
return faceIndices;
}
float *CMesh::getVert ices() const{
return vertices;
}
Class CMesh
{
...
float *vertices = new float[numVertices * 3];;
int *faceIndices = new int[numFaces * 3];
...
}
</code>
the two arrays get filled at runtime.
for the the opengl rendering part, i need to have a pointer to a
float-array containing the vertices and a pointer to an int-array
conatining the indices of the triangles.
to get them from my mesh-object i cast them in the render-function.
the floatconversion (A) works. "pVertices" points to the same data as
the member variable "vertices" of the mesh-object. but when i try to
cast the pointer of my integerarray (B), a dataloss occurs. when i
loop through pIndices i get lesser data. only every 3rd integer of the
original array. the last 3 values are correct.
this must be a casting problem. why does it work with floats, but not
with int?
i tried (GLint *) and (int *) casting (they seem to be the same size
anyway, according to sizeof())... no success. any ideas?
TIA
ghostdog