PDA

View Full Version : single precision floats vs. double precision



BigD
10-30-2001, 12:09 PM
Hello, I'm using an orthographic projection using glOrtho(). I have set up my transformation (eye, at, up) using gluLookAt(). Everything seems to work fine until I have very large coordinates ( > 10 million).

Even though I use glVertex3d(), and I specify double precision values, gl seems to be losing the precision. It's as if gl is converting everything to single precision floating point values. Is this what gl does?

Is there any way to get gl to use double precision values?

Has anyone had experience using very large coordinate values with gl?

mikael_aronsson
10-30-2001, 01:38 PM
Hi !

As far as I know, most OpenGL hardware is using floats internally, and you cannot do anything about that... correct me if I am wrong.

Mikael

Ryo
10-30-2001, 01:49 PM
Why don't you use offset.

BigD
10-30-2001, 01:52 PM
Originally posted by Ryo:
Why don't you use offset.

Please elaborate..

Ryo
10-30-2001, 06:39 PM
Say you have a point with following coordinates.
x : 10000000.111
y : 10000000.222
z : 10000000.333

Then, you can draw a point like this...

// Move by offset
glTranslated(10000000.0, 10000000.0, 10000000.0);

// Draw a point with value-offset
glBegin(GL_POINTS);
glVertex3f( 0.111f, 0.222f, 0.333f );
glEnd();

Hope it helps!

alok47
11-01-2001, 06:44 PM
Originally posted by Ryo:
Say you have a point with following coordinates.
x : 10000000.111
y : 10000000.222
z : 10000000.333

Then, you can draw a point like this...

// Move by offset
glTranslated(10000000.0, 10000000.0, 10000000.0);

// Draw a point with value-offset
glBegin(GL_POINTS);
glVertex3f( 0.111f, 0.222f, 0.333f );
glEnd();

Hope it helps!


I dont't think it will work.
Bcos the value of glTranslate is combined with what is passed to glVertex() and then it might exceed the largest possible float value, which is the same as passing it to glVertex directly.

Ryo
11-01-2001, 11:24 PM
Then, subtract a constance value from each point.