Problems converting to fixed point

Hi. I’m developing a game engine to be used both in Desktops and PDAs… I recently converted the projects vector math and opengles calls to fixed point and I’m experiencing some problems ever since.

If I use floating point, the scene shows up fine in the PDA. If I use fixed point, however, the geometry loads ok, but everything is black (everything but the background, which has the right color). I tried making texture loading fail, and deleted the texture files from the project. That causes everything to be white in floating point, but it’s still black with fixed point (made no difference if the texture files were there).

I’m kinda new to opengl, so I was wondering if you could help me figuring this out. Any ideas on what could the problem be (or a procedure to debug this! I have no clue how to do it)?

Have you also converted your texture coordinates into fixed point format? Since when you are using the commonlite profile and thus fixed point you can not use float for anything ?

If you have converted everything to fixed point you might want to try a simple object like a quad and step through it manually checking all the values (this can be a pain when using fixed point).

Are you using a wrapper system on the desktop such as available here:

Link to PowerVR PC Emulation SDK

Debugging on a PC is usually a lot easier than on an actual device.

Hope this helps,

K-

Yep… I converted everything to fixed point, but I think there’s another problem, not texture related…

When I remove the texture files, the render paints everything the same color, which I chose to be white but could be anything else. When using fixed point, however, everything is black, not white. That must mean the problem is not with the texture mapping, right?

And I can’t think of a reason for this problem…

Is black your clear color ? You might not even be getting the geometry in the right place ?

K-

Could you post some lines of your code? Another thing, the first texel of your texture is black? I say this because if you forgot convert texcoord ‘1’ to ‘1<<16’, you probably will get only the first texel in the whole triangle, because ‘1’ is very very close to 0…

SOLVED!

Hi! I wanted to thank you for the help and to inform the problem, just in case anyone goes through this again. It’s really annoying to waste time with this kind of thing…

My problem was with fixed point representation. I created a Fixed32 class and, for float compatibility, i have many constructors and cast operators. GLfixed is defined as int and the compiler calls the (int) cast operator when the function requires the type GLfixed (I thought it would consider GLfixed as a different type). Because of that, all values were being divided by 2^16.

The geometry was working because when the function received a pointer, the cast operator was not called.

Anyway, thanks again.

GLfixed is a typedef of int, and C++ doesn’t allow to overload any operator (even the casts) of basic types (like int, chat, float, etc) :slight_smile:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.