Results 1 to 2 of 2

Thread: Help setting up the view

  1. #1
    Junior Member Newbie
    Join Date
    May 2001
    Posts
    3

    Help setting up the view

    In order to define the view in my application, I have the four corners of the view plane and vectors which run from these corners such that they define the corners of the view window (always rectangular). I know on which side of the view plane the vectors meet, and that they do, but not exactly where.

    How do I communicate this to OpenGL in order to define the correct view? And should I put this information on projection or modelview?

    E.g. if the viewer were at the origin, looking along z I might have the view plane constructed between position vectors (-1, -1, 1), (1, -1, 1), (1, 1, 1) and (-1, 1, 1), with exactly the same vectors used at each point to define the corners of the display. Am I even making sense?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Feb 2001
    Location
    Australia
    Posts
    431

    Re: Help setting up the view

    Here's a typical view setup function:

    Code :
    void ResizeScene(int width, int height)
    {
    	glViewport(0, 0, width, height);
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
    	glFrustum((GLdouble)-1.0, (GLdouble)1.0, 
    		(GLdouble)-1.0, (GLdouble)1.0,
    		(GLdouble)1.0, (GLdouble)1000.0);
    	glMatrixMode(GL_MODELVIEW);
    }
    glFrustum sets up your viewing volume. Parameters are left, right, bottom, top, zNear, zFar i.e. the coordinates of the clipping planes of your view volume. You will have your point of view at the origin so in your drawing function, you need to start probably like this:

    Code :
    glLoadIdentity();
    GLfloat Z_Offset(-1.0f);
    // This will offset your "camera" to +1.0f along the z axis (out of screen).
    glTranslatef(0.0f, 0.0f, Z_Offset);
    ...
    DrawObjects();
    Hope that helps.

Similar Threads

  1. Creating multiple planes in 3D view (projection view)
    By Bhoot123 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 02-20-2018, 02:40 AM
  2. newbie view location / view direction in textfield
    By newsb in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-12-2011, 02:15 PM
  3. Extract view frutum planes from view matrix
    By ei05tbe in forum OpenGL: General
    Replies: 4
    Last Post: 09-18-2010, 06:22 PM
  4. Setting up view in Ortho Mode - window vs pixels.
    By cutting_crew in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-07-2008, 08:00 PM
  5. Setting up a 3D view
    By ltrain_riders in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 10-17-2002, 12:25 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