Originally posted by Deiussum:
[b]I just re-read your posts a bit more. You say it works when you cast mesh->getVertices() to a float* but not to an int*?
If that is what you are saying then, duh. The memory layout for ints and floats is totally different so if you just try to cast a float* to an int* and then access the individual elements of the int*, you will get totally different values from the individual elements of the float*. It won’t be a simple truncation/rounding either. Floats are stored in IEEE format for floating point numbers and ints are stored in a more direct manner.
Edit: To clarify, casting a float* to an int* is not like casting a float to an int. It will not cast every element of the float array to an int. Instead, it merely casts the float pointer to an int pointer. It still points to the same memory location, and the memory is still layed out exactly like it was for the float pointer, it’s just interpretted a bit different when reading the array.
[This message has been edited by Deiussum (edited 09-15-2003).][/b]
hmm, i think you get me totally wrong. i don’t want to cast floats to ints nor the other way round. i think you misunderstood something because of the lack of code. sorry, i posted it above.
for using glDrawElements() (for drawing vertex arrays) i need a pointer to the vertex data (which are is an array of sequential floats-coordinates: x,y,z,x,y,z,…) and a pointer to the indices-array.
these data is stored in the member variables of my objectclass “CMesh”.
so my main attempt is to get 2 pointers. one pointing to the int-array (indices)and one to the float-array (vertices). and therefore is my cast. but the cast only works for the float pointer, not for the int.
so when i run my app. the triangles of the mesh are connected wrong because the indices are wrong. but when i draw only the vertex data (with GL_POINTS) i get the correct vertices.
so i conclude there is something wrong with the cast because the data is correct on the CMesh-side, but not with the pointer finally pass to the glDrawElements()-call.
EDIT: now i got, what you misunderstood. sorry for posting such stupid code… damn…
of course those lines are totally separated. hope it’s clear from my new posted, completer code.
sorry if my post before was not at all understandable!
regards,
ghostdog
[This message has been edited by ghostdog (edited 09-15-2003).]