I needed some clarification regardin this:
glVertex2i(x , y+30);
glVertex2i(x + 30,y+30);
glVertex2i(x + 30,y);
void main(int argc,char ** argv)
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()
Basically the glutMainLoop() call starts an infinite loop calling the function your specified before. You only specified a display function but could also specify a reshape function and a mouse handling function for example (with glutReshapeFunc() and glutMouseFunc() respectively)
So when you specify glutDisplayFunc(display), you basically say to glut that each time you need to render, call the "display" function. Of course you have to put your draw(); function in that display() function or it will not be called.
The code you pasted here will basically render 1 time then never again (thus you see nothing being drawn).
Of course you have to put your draw(); function in that display() function or it will not be called.
But the control was going into the draw() function.
Also like you said,it should have rendered it once right?
But that the rendering was not done.Can you please explain why?
Yes, It will render one time but your eyes will not have time to see it since the buffer is cleared immediately after (on the next frame).
The glClear(GL_COLOR_BUFFER_BIT); clears the buffer and all that was in it and reset all pixels to the color specified by glClearColor (in your case perfect white). So basically you need to but your draw() function just after the glClear call.
Yeah got it! Thanks a lot..