float[] or int[] as Vertex Buffer

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

float[] or int[] as Vertex Buffer

Postby rHalf » Thu Dec 31, 2009 6:53 am

I'm a little lost when trying to compare float coordinates to int coordinates
I use this method to create a Vertex Buffer and of course I modify it to return a floatBuffer or intBuffer base on the type of array coords is (int[] or float[]).

ByteBuffer tbb = ByteBuffer.allocateDirect(coords.length * 4);
tbb.order(ByteOrder.nativeOrder());
returnBuffer = tbb.asIntBuffer();
returnBuffer.put(coords);
returnBuffer.position(0);

gl.glVertexPointer(3, GL10.GL_FIXED, 0, returnBuffer);

I understand the difference between ints and floats on a bitwise level.
1f = int 65536;
.5f = int 32768;

I don't understand if that is true how come the conversion to float is not simple?
say i have the following which properly renders a plane in the center of the screen:
int ONE = 65536;
int coords = int[]{
-ONE, -ONE ,0,
ONE,-ONE ,0,
-ONE ,ONE ,0
ONE ,ONE ,0}

when i convert to float

float ONE = 1.0f;
float coords = float[]{
-ONE, -ONE ,0,
ONE,-ONE ,0,
-ONE ,ONE ,0
ONE ,ONE ,0}

nothing appears...
Am I misunderstanding something? Any pointers would be useful.
Thanks
rHalf
Junior Developer
Junior Developer
 
Posts: 16
Joined: Sun Dec 20, 2009 1:54 am

Top

Postby Shaka » Mon Jan 04, 2010 4:45 pm

How does your render code look? Did you remember to change from GL_INT(or is it GL_FIXED?) to GL_FLOAT in glVertexPointer?
Shaka
Developer
Developer
 
Posts: 44
Joined: Fri Aug 28, 2009 3:01 pm

Postby rHalf » Tue Jan 05, 2010 4:53 am

That would be the issue
still stuck in GL_FIXED

gl.glVertexPointer(3, GL10.GL_FIXED, 0, mVertexBuffer);

Thanks for the answer
rHalf
Junior Developer
Junior Developer
 
Posts: 16
Joined: Sun Dec 20, 2009 1:54 am

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests