View Full Version : How to draw a screen aligned QUAD?
apapaxionga
11-15-2011, 07:00 PM
if i initialize the Viewport like this:
glViewport(0, 0, screenWidth, screenHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0f, (float)(screenWidth)/screenHeight, 1.0f, 100.0f);
glMatrixMode(GL_MODELVIEW);
mobeen
11-15-2011, 11:17 PM
Hi,
You will need to use the orthographic projection for this. Something along these lines should work.
void OnResize(int nw, int nh) {
glViewport(0,0,nw,nh);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,1,0,1,0,1);
glMatrixMode(GL_MODELVIEW);
}
Then use this code to draw the quad
void DrawFullScreen() {
glBegin(GL_QUADS);
glVertex2f(0,0);
glVertex2f(1,0);
glVertex2f(1,1);
glVertex2f(0,1);
glEnd();
}
See if this helps.
V-man
11-16-2011, 04:46 AM
Here's another one
void OnResize(int nw, int nh) {
glViewport(0,0,nw,nh);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
}
void DrawFullScreen() {
glBegin(GL_QUADS);
glVertex2f(-1,-1);
glVertex2f(1,-1);
glVertex2f(1,1);
glVertex2f(-1,1);
glEnd();
}
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.