#include<GL/glut.h>
#include<GL/gl.h>
void display (void)
{
//1 glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0,0.0,1.0);
glBegin(GL_POLYGON);
glVertex3f(0.25,0.25,0.0);
glVertex3f(0.75,0.25,0.0);
glVertex3f(0.75,0.75,0.0);
glVertex3f(0.25,0.75,0.0);
glEnd();
glFlush();
}
void init (void)
{
glClearColor(0.0,0.1,0.0,0.0);
//2 glClear(GL_COLOR_BUFFER_BIT);
glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGBA);
glutInitWindowSize(300,300);
glutCreateWindow(“test_hello”);
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
I am a newbie in openGL. In the above program can somebody tell me what’s the difference in placing the command glClear(…) in positions commented and marked 1 and 2 ?
Best,
Pkri