PDA

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



vinaymk
03-13-2009, 04:26 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?

BionicBytes
03-13-2009, 05:49 AM
Fixed point is floating point but clamped to the range -1..+1
Colours and normals are examples where attributes passed via the glNormal and glcolor are normalised.
These legacy API interfaces are fixed and only expect float arguments (although colour does accept bytes - but converts internally to fixed-point).

With the generic attributes (glVertexAttrib) you can specify whether or not the values should be normalised by the GL on upload.