gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > scale float problem

#118423 - perh - Tue Feb 13, 2007 11:25 am

Hi I'm having some weired scale behavior when scaling with values above 16(!).

I've tried scaling with both the glScalef(float,float,float) and glScalef32, with the exact same behavior.
When drawing a simple cube I increase its size and reduce the scale modifier so that it should appear to be constant size.
After the inverted scale value reaches 1/16 the cube starts to reduce in size.

Here is some relevant code from my test:
Code:

...
const int size = 1;    // Cube size
const float step = 0.1f;   // Step to increase scale
const int distance = size*2;  // Distance to draw the cube from

float scale = 1.0f;
f32 scale_i = divf32(inttof32(1),floattof32(scale));
float realSize = size*scale;

while (1)
{
        ...

        glTranslatef(0, 0, -distance);
        glColor3f(1.0f, 0.0f, 0.0f);
        glScalef32(scale_i);
        drawCube(realSize, realSize, realSize);
        glTranslatef(0, 0, distance);

        scale += step;
        scale_i = divf32(inttof32(1),floattof32(scale));
        realSize = size*scale;

        ...
}


This is probably due to some float overflow somewhere, I wonder where?

#118425 - wintermute - Tue Feb 13, 2007 11:42 am

The integer part of the fixed point numbers used in the DS 3D hardware is 4 bits. The co-ordinates can range from -8.0 to 7.999755859375 ( fixed point signed 4.12 )
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#118428 - perh - Tue Feb 13, 2007 12:05 pm

wintermute wrote:
The integer part of the fixed point numbers used in the DS 3D hardware is 4 bits. The co-ordinates can range from -8.0 to 7.999755859375 ( fixed point signed 4.12 )


Ok thanks, should have remembered that.

#118442 - Lick - Tue Feb 13, 2007 2:24 pm

Thought it was 1.19.12 (32bit) or so, read it on GBAtek.
Seems that results are either 32bit or 64bit? http://nocash.emubase.de/gbatek.htm#dsmaths

[edit]Oh, 3D maths. I was looking at that division.
_________________
http://licklick.wordpress.com