Results 1 to 2 of 2

Thread: Help me, translations don't work !!

  1. #1
    Senior Member Regular Contributor
    Join Date
    Mar 2002
    Location
    France
    Posts
    286

    Help me, translations don't work !!

    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 () ;

    }

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Help me, translations don't work !!

    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.

Similar Threads

  1. Model Translations
    By Richard145 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-15-2007, 07:04 AM
  2. Question about translations
    By Vincent Dumont in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-13-2006, 01:03 PM
  3. Q. bout translations
    By mithun_daa in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-10-2003, 05:01 PM
  4. translations
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-03-2003, 12:16 AM
  5. Translations and rotations?!
    By esuvs in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-18-2003, 06:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean