Hi everyone, im very new to opengl so my questions here might be a bit dull, hope you dont mind help me out
Thing is, im reading the red book and try to mess up with every code example to gain understanding, and here my mess:
void display(void)
{
/* clear all pixels */
glClear (GL_COLOR_BUFFER_BIT);/* draw white polygon (rectangle) with corners at
- (-0.5, -0.5, 0.0) and (0.5, 0.5, 0.0)
*/
glColor3f (1.0, 1.0, 1.0);
glLoadIdentity();
gluLookAt(0.0,0.0,2.0, 0.0,0.0,-100.0, 0.0,1.0,0.0);
glBegin(GL_POLYGON);
glVertex2f (-0.5, -0.5);
glVertex2f (0.5, -0.5);
glVertex2f (0.5, 0.5);
glVertex2f (-0.5, 0.5);
glEnd();
glFlush ();
}void init (void)
{
/* select clearing (background) color */
glClearColor (0.0, 0.0, 0.0, 0.0);/* initialize viewing values /
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glOrtho(0.0, 1.0, 0.0, 1.0, 1.0, -1.0);
//glFrustum(2.0,1.0,-1.0,1.0,1.5,20.0);
gluOrtho2D(-1.0,1.0,-1.0,1.0);
}
int main(int argc, char* argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (500,450);
glutInitWindowPosition(100,100);
glutCreateWindow(âOpenGLâ);
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
First of all, i use the default camera position and orientation and things went fine but after that, i slightly modified the position
then, the screen is completely black (with all the three projections at the init()), and i cant get it. As i thought, with
gluLookAt(0.0,0.0,2.0, 0.0,0.0,-100.0, 0.0,1.0,0.0);
i just moved the camera 2 units along the z-axis while still aiming at (0,0,-100) which supposed to take no effect at all.
Im not very good at English so i might get something wrong from the book, please correct me