Mukund
04-15-2010, 11:17 AM
Hello everyone.
I needed some clarification regardin this:
void display()
{
glClearColor(1.0,1.0,1.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,640.0,0.0,480.0,-500.0,500.0);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
void draw()
{
int x=10,y=200;
glColor3f(0.0,0.0,0.0);
for(int i=0;i<10;i++){
glBegin(GL_LINE_LOOP);
glVertex2i(x,y);
glVertex2i(x , y+30);
glVertex2i(x + 30,y+30);
glVertex2i(x + 30,y);
glEnd();
y+=30;
}
glFlush();
}
void main(int argc,char ** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(640,480);
glutCreateWindow("Rect");
glutDisplayFunc(display);
draw();
glutMainLoop();
}
Here the boxes are not getting drawn!
However when i give it in my display callback, it works!!
Why is this?Has it got to do domething with glutMainLoop()
I needed some clarification regardin this:
void display()
{
glClearColor(1.0,1.0,1.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,640.0,0.0,480.0,-500.0,500.0);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
void draw()
{
int x=10,y=200;
glColor3f(0.0,0.0,0.0);
for(int i=0;i<10;i++){
glBegin(GL_LINE_LOOP);
glVertex2i(x,y);
glVertex2i(x , y+30);
glVertex2i(x + 30,y+30);
glVertex2i(x + 30,y);
glEnd();
y+=30;
}
glFlush();
}
void main(int argc,char ** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(640,480);
glutCreateWindow("Rect");
glutDisplayFunc(display);
draw();
glutMainLoop();
}
Here the boxes are not getting drawn!
However when i give it in my display callback, it works!!
Why is this?Has it got to do domething with glutMainLoop()