// set the color to use in draw glColor3f(0.5, 0.5, 0.0); // create a polygon ( define the vertexs) glBegin(GL_POLYGON);{ glVertex2f(-0.5,-0.5); glVertex2f(-0.5, 0.5); glVertex2f( 0.5, 0.5); glVertex2f( 0.5,-0.5); } glEnd();
// flush the drawing to screen . glFlush(); }
// Keyboard callback function ( called on keyboard event handling ) void keyboard(unsigned char key, int x, int y) { if (key =='q'|| key =='Q') exit(EXIT_SUCCESS); }
// Main execution function int main(int argc, char *argv[]) { glutInit(&argc, argv);// Initialize GLUT glutCreateWindow("OpenGL example");// Create a window glutDisplayFunc(display);// Register display callback glutKeyboardFunc(keyboard);// Register keyboard callback glutMainLoop();// Enter main event loop
return (EXIT_SUCCESS); }
Attachments:
opengl2.GIF [ 5.98 KiB | Viewed 725 times ]
_________________ Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )