Basic OpenGL reshape function question...

Member
Posts: 321
Joined: 2004.10
Post: #1
Code:
void reshape1(int width, int height)
{
   glViewport(0, 0, width, height);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
        [b]gluPerspective(); or glFrustrum(); or glOrtho();[/b]
   glGetDoublev(GL_PROJECTION_MATRIX, projection);
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
   gluLookAt(lookat[0].value, lookat[1].value, lookat[2].value,
                      lookat[3].value, lookat[4].value, lookat[5].value,
                      lookat[6].value, lookat[7].value, lookat[8].value);
   glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
   glClearColor(0.0, 0.0, 0.0, 0.0);
}



void reshape2(int width, int height)
{
   same as above: glViewport(), glMatrixMode, glLoadIdentity

       [b]gluPerspective(60.0, (GLfloat)width/height, 1.0, 256.0);[/b]
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslatef(0.0, 0.0, -5.0);
    glRotatef(-45.0, 0.0, 1.0, 0.0);
    glClearColor(0.0, 0.0, 0.0, 0.0);
  }

This is Nate Robin's code from his projection tutorial and I'm wondering why the reshape1 function has the glGetDoublev(GL_PROJECTION_MATRIX, projection); statement whereas reshape2 does not? And I'm correct in saying that the reshape2 function doesn't have a gluLookAt() function because it uses all default values?

Thanks in advance.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Presumably he gets the projection matrix because he wants it later. You shouldn't call glGet. He has to because he's writing an odd tutorial app Rasp
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #3
(Mar 24, 2011 03:03 PM)WhatMeWorry Wrote:  And I'm correct in saying that the reshape2 function doesn't have a gluLookAt() function because it uses all default values?
You can always replace gluLookAt with translations and rotations. gluLookAt simply packages the information in terms of camera position and direction.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Basic OpenGL questions Mercy 5 4,509 Dec 23, 2008 10:25 AM
Last Post: AnotherJake
  Texture Basic Question(s)... WhatMeWorry 2 3,227 Feb 27, 2007 10:06 AM
Last Post: arekkusu
  Depth Buffer / Testing basic question... WhatMeWorry 5 6,321 Nov 18, 2005 12:50 AM
Last Post: arekkusu
  basic matrix question hyperzoanoid 3 3,240 Sep 27, 2003 03:06 PM
Last Post: DoG
  An OpenGL Question Justin Brimm 1 2,299 Dec 13, 2002 03:38 AM
Last Post: OneSadCookie