Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: Near & far parameter in glfrustum-glperspective c++

  1. #11
    Junior Member Newbie
    Join Date
    Aug 2012
    Posts
    9
    BTW, does the assignment require you to use perspective? If not, consider orthographic. It's a little simpler to think about. In fact, since you're having trouble, I'd just use glOrtho first regardless. Then think about what (if anything) you need to change for perspective.
    I ask to the instructor information about the parameterization of the camera and he told me that i must automatically fix the parameter of gluPerspective for adapting the project to all the dataset that i pass to the project.


    Since this is a homework problem, I shouldn't get into the details of helping you solve it. I'd talk to your instructor and get some guidance.
    Yes this is an homework problem but i cannot resolve it. The material that the instructor gave us don't resolve the problem.

    My question is the follow: how can i parametrize near and far?i'm working to this problem from 15 days but i don't resolve it and i cannot go to next step. Please help me. can i send you the project and the project requests for mail?can we speak on skype?
    Please help me, i'm working all the summer for this project

  2. #12
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882
    See questions 5 and 7 in the Forum Posting Guidelines.

    And on 5, you need to give it the old college try. You need to do most of the work. Post the details describing what you have tried and why you think those don't work.

    The problem isn't hard -- you want to enclose your dataset with 6 planes (the planes defining the view frustum). And you need to become intimately familiar with how those planes are defined. Again, see the projection documentation mentioned. It's very clear about this. And again, use ortho first -- it's easy!

  3. #13
    Junior Member Newbie
    Join Date
    Aug 2012
    Posts
    9
    Quote Originally Posted by Dark Photon View Post
    See questions 5 and 7 in the Forum Posting Guidelines.

    And on 5, you need to give it the old college try. You need to do most of the work. Post the details describing what you have tried and why you think those don't work.

    The problem isn't hard -- you want to enclose your dataset with 6 planes (the planes defining the view frustum). And you need to become intimately familiar with how those planes are defined. Again, see the projection documentation mentioned. It's very clear about this. And again, use ortho first -- it's easy!
    ok, i describe my problems...
    the request of the teacher is the follows:

    "The student is required to achieve a general application that is able to adapt to the size of the dataset to be displayed appropriately parameterizing the volume of view."
    the teacher told me to use gluPerspective and NOT glOrtho and glFrustum.
    my gluPerspective is this:

    Code :
    gluPerspective(60.0,                  //The camera angle
                       (double)width / (double)height, //The width-to-height ratio
                       200.0,                   //The near z clipping coordinate
                       500.0);                //The far z clipping coordinate

    in main.cpp i fix the follow parameter:
    Code :
    float xpos = heightMap->xcenter;
    float ypos = heightMap->ycenter;
    float zpos = heightMap->zcenter;

    and my display function is this:

    Code :
    void display (void)
    {
     
    	 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    	 glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
    	 glLoadIdentity();
    	 light();
    	 glTranslatef(-(xpos), (ypos), -(zpos)) ;
    	 glRotatef(-cameraAngle, 1.0f, 0.0f, 0.0f); //Rotate the camera
    	 glColor4f(0, 1, 0, 1);
    	 //renderPrimitive(); // Render the primitive
    	 //glCallList(DLid);
    	 //glRotatef(angle, 1.0f, 0.0f, 0.0f); //togliere i commenti se si vuole far ruotare l'immagine in automatico
    	 heightMap->Render();
    	 glutSwapBuffers();
    	 glFlush(); // Flush the OpenGL buffers to the window
     
    }

    for adapting to the size of the dataset i think that i can't fix manually parameter near & far of gluPerspective but these parameters must be calculated automatically, isn't right?if this is correct, i would know how automatically calculate near & far.

    Thanks for your answer

  4. #14
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882
    Quote Originally Posted by Agata_ View Post
    ...the request of the teacher is the follows:

    Quote Originally Posted by Teacher
    The student is required to achieve a general application that is able to adapt to the size of the dataset to be displayed appropriately parameterizing the volume of view." the teacher told me to use gluPerspective and NOT glOrtho and glFrustum.
    ...near & far of gluPerspective but these parameters must be calculated automatically, isn't right?if this is correct, i would know how automatically calculate near & far.
    Yes, per your instructor, that's explicitly what you are supposed to figure out. That along with the other gluPerspective parameters.

  5. #15
    Junior Member Newbie
    Join Date
    Aug 2012
    Posts
    9
    Quote Originally Posted by Dark Photon View Post
    Yes, per your instructor, that's explicitly what you are supposed to figure out. That along with the other gluPerspective parameters.
    ok but can you help me for this problem?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •