zero_t9

03-27-2005, 05:34 PM

Gurus, Hi:

I have a snippet of codes below. My intentions is to use projection matrix to implement transform(-8,-6,-84) and then use viewing volume for final display. However, it just does not work(looks like it is opengl bug:) read my reasoning below.

glMatrixMode(GL_MODELVIEW); glLoadIdentity();

glMatrixMode(GL_PROJECTION); glLoadIdentity();

gluLookAt(8,6,84, 8,6,0, 0,1,0);

glFrustum(-11,11,-11,11,30,200);

glPolygonMode( GL_FRONT_AND_BACK , GL_LINE );

glBegin( GL_POLYGON );

glVertex3f(0,0,54);

glVertex3f(16,0,54);

glVertex3f(16,10,54);

glVertex3f(8,16,54);

glVertex3f(0,10,54);

glEnd();

If I switch the order of gluLookAt and glFrustum to be

glFrustum(-11,11,-11,11,30,200);

gluLookAt(8,6,84, 8,6,0, 0,1,0);

then everything is fine.

In my understanding, if I want to transform a sphere at origin to (x,y)=(1,1) position. We need to specify the matrix

glRotatef(45, 0,1,0);

glTranslatef(square_root(2), 0, 0);

if we specify

glTranslatef(square_root(2), 0, 0);

glRotatef(45, 0,1,0);

the sphere will be at (square_root(2), 0).

Furthermore, if I move the translation matrix to model view as below

glMatrixMode(GL_MODELVIEW);glLoadIdentity();

glTranslatef(-8,-6,-84);

glMatrixMode(GL_PROJECTION);glLoadIdentity();

glFrustum(-11,11,-11,11,30,200);

The result will be okay too.

Anybody know why? ( I can provide you tester program if needed)

I have a snippet of codes below. My intentions is to use projection matrix to implement transform(-8,-6,-84) and then use viewing volume for final display. However, it just does not work(looks like it is opengl bug:) read my reasoning below.

glMatrixMode(GL_MODELVIEW); glLoadIdentity();

glMatrixMode(GL_PROJECTION); glLoadIdentity();

gluLookAt(8,6,84, 8,6,0, 0,1,0);

glFrustum(-11,11,-11,11,30,200);

glPolygonMode( GL_FRONT_AND_BACK , GL_LINE );

glBegin( GL_POLYGON );

glVertex3f(0,0,54);

glVertex3f(16,0,54);

glVertex3f(16,10,54);

glVertex3f(8,16,54);

glVertex3f(0,10,54);

glEnd();

If I switch the order of gluLookAt and glFrustum to be

glFrustum(-11,11,-11,11,30,200);

gluLookAt(8,6,84, 8,6,0, 0,1,0);

then everything is fine.

In my understanding, if I want to transform a sphere at origin to (x,y)=(1,1) position. We need to specify the matrix

glRotatef(45, 0,1,0);

glTranslatef(square_root(2), 0, 0);

if we specify

glTranslatef(square_root(2), 0, 0);

glRotatef(45, 0,1,0);

the sphere will be at (square_root(2), 0).

Furthermore, if I move the translation matrix to model view as below

glMatrixMode(GL_MODELVIEW);glLoadIdentity();

glTranslatef(-8,-6,-84);

glMatrixMode(GL_PROJECTION);glLoadIdentity();

glFrustum(-11,11,-11,11,30,200);

The result will be okay too.

Anybody know why? ( I can provide you tester program if needed)