PDA

View Full Version : Converting from GL_FLOAT to GL_INT not working..



vinaymk
03-13-2009, 04:28 AM
Hi,
I've been trying to port a OpenGL, GL_FLOAT based application [skyfly] to OpenGL-ES with fixed point values.
I could convert Open GL calls like:
glBegin(GL_TRIANGLE_STRIP);
for(i = 0; i < 11; i++)
{
glNormal3fv((op + (i * PD_V_SIZE + PD_V_NORMAL)));
glVertex3fv((op + (i * PD_V_SIZE + PD_V_POINT)));
}
glEnd();

to OpenGL-ES only calls like:
float vPPlane[33];
float nPPlane[33];
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, vPPlane);
glNormalPointer(GL_FLOAT, 0, nPPlane);
glDrawArrays(GL_TRIANGLE_STRIP,0,i);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);

This set of API works as long as the type of the variables is float.
When I convert the data-types above from float to int and perform conversion for each value as:
#define F2x(f) (int)(f*65536)

and use GL_INT instead of GL_FLOAT in the above calls. The corresponding objects are not getting rendered. Am I missing anything? Can someone please help on this?

Nicolas Lelong
03-13-2009, 11:18 AM
I don't know OpenGL ES, but I suppose that, as you scale your coordinates, you have to 'unscale' your modelview matrix to get the original coordinates, using glScalef(1.0f/65536.f, ...).

This may leave issues with the normals though.