#include //include the GLUT library responsible for the window, menus....etc
#include //include the GL library responsible for the drawing function
void Init(void) // Your initialization function and its Name is not a constant u change it
{
glClearColor(1.0,1.0,1.0,0.0); //set the background color
glMatrixMode(GL_PROJECTION); // set the Matrix Mode with the projection Mode
gluOrtho2D(0.0,200.0,0.0,150.0); // set the range of the view orthogonal
glPointSize(4.0); // set the one point =4 pixels
}
void Linesg(void)
{
glClear(GL_COLOR_BUFFER_BIT); // load the bg color from the COLOR BUFFER BIT
glColor3f(1.0,0.0,0.0); // set the drawing color with RED color
glBegin(GL_LINE_STRIP); //Begin Drawing Line Strip
glVertex2i(10,10); //p1 where 2i = 2 arguments (x, y) & i for integer
glVertex2i(10,50); // p2
glVertex2i(150,10); // p3
glVertex2i(150,50); // p4
glEnd(); //end of drawing function
glFlush(); // flush the scene from the buffer to show on the screen
}
void main/(int argc,char** argv) // main C++ function
{
glutInit (&argc,argv); // initialize the toolkit
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB); // use Single buffer & RGB color mode
glutInitWindowPosition(50,100); // set the window position @ 50 x & 100 y
glutInitWindowSize(400,300); // set the window size 400 width & 300 height
glutCreateWindow(" This is my first Example"); // create the window with title "This i...."
Init(); // call ur initialization function
glutDisplayFunc(Linesg); // call ur display function
glutMainLoop(); // call the Main loop of the openGL which keep waiting
//for keyboard or mouse events
}
Thursday, 26 March 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment