I am following the tutorials on NeHe and was wondering how does the computer determine the size of the plane you are writing. I know you can edit it with glOrtho, but on Lesson1 they don’t use this anywhere and they still use glVertex3f how do they know where the limits are that they see on the screen?
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glu.h>
#include <unistd.h>
#include <stdlib.h>
int window;
void Display(void){
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(-1.5,0.0,-6.0);
glBegin(GL_POLYGON);
glVertex3f(0.0,1.0,0.0);
glVertex3f(1.0,-1.0,0.0);
glVertex3f(-1.0,-1.0,0.0);
glEnd();
glTranslatef(3.0,0.0,0.0);
glBegin(GL_QUADS);
glVertex3f(-1.0,1.0,0.0);
glVertex3f(1.0,1.0,0.0);
glVertex3f(1.0,-1.0,0.0);
glVertex3f(-1.0,-1.0,0.0);
glEnd();
glutSwapBuffers();
}
void keyboard(unsigned char key,int x,int y){
usleep(100);
if(key==27){
glutDestroyWindow(window);
exit(0);
}
}
void Idle(int Width,int Height){
if(Height==0)
Height=1;
glViewport(0,0,Width,Height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0,(GLfloat)Width/(GLfloat)Height,0.1,100.0);
glMatrixMode(GL_MODELVIEW);
}
void InitGL(int Width,int Height){
glClearColor(0.0,0.0,0.0,0.0);
glClearDepth(1.0);
glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0,(GLfloat)Width/(GLfloat)Height,0.1,100);
glMatrixMode(GL_MODELVIEW);
}
int main(int argc,char **argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_ALPHA|GLUT_DEPTH);
glutInitWindowSize(640,480);
glutInitWindowPosition(0,0);
window=glutCreateWindow("Zoot Suit Riot");
glutDisplayFunc(Display);
glutFullScreen();
glutIdleFunc(Display);
glutReshapeFunc(Idle);
glutKeyboardFunc(keyboard);
InitGL(640,480);
glutMainLoop();
return 0;
}