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);
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);
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.
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();
}