iDevGames Forums
Basic OpenGL reshape function question... - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Basic OpenGL reshape function question... (/thread-8752.html)



Basic OpenGL reshape function question... - WhatMeWorry - Mar 24, 2011 03:03 PM

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.


RE: Basic OpenGL reshape function question... - OneSadCookie - Mar 24, 2011 03:26 PM

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


RE: Basic OpenGL reshape function question... - Ingemar - Mar 30, 2011 07:05 AM

(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.