Results 1 to 4 of 4

Thread: perspective

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2005
    Posts
    15

    perspective

    i have only been working in 2d views, could anyone give me a code that will just have lines for the 3 axis shown from a perspective far away? so the image looks something like this...

    __________
    | |
    | |/_ |
    |________|

    thanks

  2. #2
    Senior Member Frequent Contributor ehsan2004's Avatar
    Join Date
    Jun 2004
    Location
    Iran
    Posts
    645

    Re: perspective

    Hi. Change your reshape function:

    GLvoid ReSizeGLScene(GLsizei width, GLsizei height)
    {
    if (height==0)
    {
    height=1;
    }
    glViewport(0,0,width,height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(54.0f,(GLfloat)width/(GLfloat)height,0.1f,1000.0f);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    }

    -Ehsan-

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2005
    Posts
    15

    Re: perspective

    see, that doesnt work for me... like i initially said, can someone give me a complete code that i can compile that will give me a perspective view of the axis. for example, a line from 0,0,0 to 0,0,300 0,300,0 and 300,0,0 with the glOrtho of 0,300,0,300,0,300 looking from 500,500,400 at 0,0,0

    does that make sence?? right now i have a program that has 3 different views, looking donw all the axis, i want a third window to be an 'animate' window which will just revolve the camera, showing the whole world... thanks

  4. #4
    Senior Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Berlin, Germany
    Posts
    188

    Re: perspective

    Code :
    /* setup camera */
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(fovy, aspect, znear, zfar);
     
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(
      fromx, fromy, fromz,
      0, 0, 0,
      0, 1, 0
    );
     
    /* draw axes */
    glBegin(GL_LINES);
    glColor3f(1, 0, 0);
    glVertex3f(0, 0, 0);
    glVertex3f(1, 0, 0);
     
    glColor3f(0, 1, 0);
    glVertex3f(0, 0, 0);
    glVertex3f(0, 1, 0);
     
    glColor3f(0, 0, 1);
    glVertex3f(0, 0, 0);
    glVertex3f(0, 0, 1);
    glEnd();
    355/113 -- Not the famous irrational number PI, but an incredible simulation!

Similar Threads

  1. Draw texture without perspective on mesh with perspective depth
    By Ray1184 in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 10-22-2018, 04:17 AM
  2. Replies: 2
    Last Post: 06-06-2015, 07:35 AM
  3. Replies: 3
    Last Post: 01-25-2015, 12:27 PM
  4. changing from perspective to ortho back to perspective
    By crappy04 in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 02-19-2001, 09:03 AM
  5. Perspective -> Orthographic -> Perspective. Textures die!!?
    By Lucretia in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 10-23-2000, 02:19 AM

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