switching projection modes

Member
Posts: 45
Joined: 2002.04
Post: #1
ok, so I have a menu system setup when my game initially starts, and from that I want to change over to my game view.

My menus use a 2D view (gluOrtho2D) and I want to switch to a perspective view for my game... (gluPerspective).

I am using GLUT, so I have entirely separate callbacks for each, menus and game..

all I get is a black screen when I switch over..

this is my setup:

Code:
glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45, 4.0 / 3.0, 1, 1000);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    
    gluLookAt(0.0, 5.0, -5.0,  0.0, 0.0, 0.0,  0.0, 1.0, 0.0);


my draw callback function looks like this:

Code:
    glClear(GL_COLOR_BUFFER_BIT);
    render_xz_plane();
    
    glColor3f(1.0,1.0,1.0);
    glBegin(GL_QUADS);
    {
        glVertex3f(0.0, 0.0, 0.0);
        glVertex3f(10.0, 0.0, 0.0);
        glVertex3f(10.0, 0.0, 10.0);
        glVertex3f(0.0, 0.0, 10.0);
    }
    glEnd();
    
    glPushMatrix();
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0.0, game_settings.width, game_settings.height, 0.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    
    draw_fps((float)game_settings.width - 250, 20.0);
    
    //the follow quad is just to test... and it doesn't work..
    glColor3f(1.0,0.0,0.0);
    glBegin(GL_QUADS);
    {
        glVertex2f(0.0, 0.0);
        glVertex2f(10.0, 0.0);
        glVertex2f(10.0, 10.0);
        glVertex2f(0.0, 10.0);
    }
    glEnd();
    
    glPopMatrix();
    
    glutSwapBuffers();


I have no idea what is going on..
I just get a black screen..

I was under the impression that one was able to combine different views together.. to achieve different effects...

I want to do all my UI graphics in a 2D space and overlay them on my 3D scene..

how>?

Hank-

/* Drunk...... fix later.... */
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
You're only pushing and popping the MODELVIEW matrix, not the PROJECTION matrix. You should be pushing and popping both.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  switching screen resolution NelsonMandella 3 3,467 Apr 25, 2010 01:33 PM
Last Post: SethWillits
  Full Screen Switching Blacktiger 3 3,613 Feb 9, 2008 03:05 PM
Last Post: Blacktiger
  Projection Matrix vs. Animation Speed jbirac 0 1,761 Dec 20, 2005 12:50 AM
Last Post: jbirac
  Trouble with fullscreen switching codeman9 14 5,599 Aug 11, 2004 01:37 PM
Last Post: arekkusu
  Switch Between Fullscreen and Windowed Modes - Again... thaeez 2 2,971 Jul 9, 2004 02:49 AM
Last Post: thaeez