Opengl Es 2.0 Populating The Vertex And Index Buffer
Solution 1:
not having the whole code is rather complicated to judge where the problem is.
It looks to me that you are working mixing data types.
The float numbers are rather tricky and if you do not handle them as floats you cannot easily "read" the content of a float memory unit.
Float, according to the standard is based on 3 different components, the bit sign (the most significative), the exponent and the mantissa.
Usually floats, on nowadays most common platforms are represented with 32 bit (4 bytes) where:
1 for the sign 8 bits for the exponent 23 bits for the mantissa (which is usually packed, but this would be a long discussion to be taken here)
If you do not "read" or "write" a float as a float (there are ways to handle floats as integer knowing their properties but this would go too much offtopic) your risk to interpret them in an unpredictable manner.
My advice is to read/write those values as float and do not go in a read/write operation byte/integer wise.
Solution 2:
Ok i have finally managed to solve my rendering issue. quick thanks to @MaurizioBenedetti as he has commented and answered some of my questions which has helped me get to where i am.
Firstly what i am putting into the buffers is correct to some extent. My Problem comes because i create a interleaved vertex buffer - this means the data is already in the correct order VVVNNNTT. Then i went and created the index buffer which contained the actual index data which is the indicies for a none interleaved buffer
for example if the faces contained 2/4/6 4/7/9 2/1/3 then my index buffer contained these exact values but because my vertex buffer is interleaved it should have containd an ordered list of the number of indicies.
So this means if the above faces were the only indicies then the index buffer should have contained 0,1,2,3,4,5,6,7,8
to sum up in the above code when i populate the vertex info
I should have said something like this
indicies.add(index++);
Instead of assigning each indicie value
I hope this is clear for anyone who is stuck on this sort of thing and will hopefully help.
Post a Comment for "Opengl Es 2.0 Populating The Vertex And Index Buffer"