Using GLfixed
as my vertex number type the following code draws textures as expected:
GLfixed vertices[] =
{
(int)point.x, (int)point.y + size.height,
(int)point.x + size.width, (int)point.y + size.height,
(int)point.x, (int)point.y,
(int)point.x + size.width, (int)point.y
};
glVertexPointer(2, GL_FIXED, 0, vertices);
I read in the OpenGL docs that GLfixed
is the least efficient type and that I should be using GLfloat
instead. But when I switched my code over to floats nothing gets drawn.
GLfloat vertices[] =
{
point.x, point.y + size.height,
point.x + size.width, point.y + size.height,
point.x, point.y,
point.x + size.width, point.y
};
glVertexPointer(2, GL_FLOAT, 0, vertices);
Is there another flag I need to set in the OpenGL state machine to get this to behave as expected?
Best Answer
When I look at the documentation it looks like
GL_FIXED
is a fixed point16:16
format. That means that the 16 upper bits of aGLfixed
represents the integer part and the fraction is the lower 16 bits divided by 65536 (1 << 16
).To convert this to a float simply divide the number by 65536:
If you're vertex coordinates etc is also in
GL_FIXED
format you'll have to scale them as well.Hope this helps.