switching projection modes
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:
my draw callback function looks like this:
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-
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.... */
You're only pushing and popping the MODELVIEW matrix, not the PROJECTION matrix. You should be pushing and popping both.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| switching screen resolution | NelsonMandella | 3 | 2,903 |
Apr 25, 2010 01:33 PM Last Post: SethWillits |
|
| Full Screen Switching | Blacktiger | 3 | 3,003 |
Feb 9, 2008 03:05 PM Last Post: Blacktiger |
|
| Projection Matrix vs. Animation Speed | jbirac | 0 | 1,488 |
Dec 20, 2005 12:50 AM Last Post: jbirac |
|
| Trouble with fullscreen switching | codeman9 | 14 | 4,967 |
Aug 11, 2004 01:37 PM Last Post: arekkusu |
|
| Switch Between Fullscreen and Windowed Modes - Again... | thaeez | 2 | 2,679 |
Jul 9, 2004 02:49 AM Last Post: thaeez |
|

