PDA

View Full Version : Help me, translations don't work !!



airseb
07-12-2002, 08:07 AM
With gltranslatef (0.0, 0.0, -5.0) nothing appears at the screen. And with no translation we can see perfectly the model with a big size. (i want to do a translation to reduce the size of the model)
Please help me.

#include <GL/glut.h>
#include <stdlib.h>

#define X .525731112119133606
#define Z .850650808352039932


void display ()
{
static GLfloat tableau_entrelace [] = {1.0, 1.0, 1.0, -X, 0.0, Z, 1.0, 1.0, 1.0, X, 0.0, Z,
1.0, 1.0, 1.0, -X, 0.0, -Z, 1.0, 1.0, 1.0, X, 0.0, -Z, 1.0, 1.0, 1.0, 0.0, Z, X,
1.0, 1.0, 1.0, 0.0, Z, -X, 1.0, 1.0, 1.0, 0.0, -Z, X, 1.0, 1.0, 1.0, 0.0, -Z, -X,
1.0, 1.0, 1.0, Z, X, 0.0, 1.0, 1.0, 1.0, -Z, X, 0.0,1.0, 1.0, 1.0, Z, -X, 0.0,
1.0, 1.0, 1.0, -Z, -X, 0.0} ;

glInterleavedArrays (GL_C3F_V3F, 0, tableau_entrelace) ;

static GLuint indices [20][3]= {1,4,0,4,9,0,4,5,9,8,5,4,1,8,4,1,10,8,10,3,8,8,3,5 ,3,2,5,
3,7,2,3,10,7,10,6,7,6,11,7,6,0,11,6,1,0,10,1,6,11, 0,9,2,11,9,5,2,9,11,2,7};

glPolygonMode (GL_FRONT, GL_LINE) ;
glFrontFace (GL_CCW) ;
glEnable (GL_CULL_FACE) ;
glCullFace (GL_BACK) ;



glTranslatef (0.0, 0.0, -5.0) ;

glDrawElements (GL_TRIANGLES, 60, GL_UNSIGNED_INT, indices) ;


glutSwapBuffers() ;
glFlush () ;
}

void main (int argc, char** argv)

{
glutInit (&argc, argv) ;
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) ;
glutInitWindowSize (640, 480) ;
glutInitWindowPosition (250,250) ;
glutCreateWindow (argv [0]) ;

glClearColor (0.0, 0.0, 0.0, 0.0) ;
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glEnable( GL_DEPTH_TEST );

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glFrustum(10.0 , 10.0, 10.0, 10.0, 0.0001, 3000000.0); //toujours des valeurs positives (ša marche)

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glutDisplayFunc (display) ;


glutMainLoop () ;

}

Bob
07-12-2002, 08:57 AM
First, the values you pass to glFrustum will create a perspective volume with nearly 179.9 degrees field of view. Yuo are really pushing the perspective to the limit, and is not going to work in practice. Either read some more about how glFRustum works, and what the parameters are used for, or use gluPerspective.

Second, the near and far clip plane in the frustum is litterally going to render the depth buffer useless. If you need the far plane at 3000000, you should have the near plane somewhere between 30 and 300 to be able to use the depth buffer in practice.