opengl

 

 

#include <glut.h> #include <math.h> const int n = 20; const GLfloat R = 0.5f; const GLfloat Pi = 3.1415926536f; void myDisplay(void) { int i; glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); for(i=0; i<n; ++i) glVertex2f(R*cos(2*Pi/n*i), R*sin(2*Pi/n*i)); glEnd(); glFlush(); } void init (void) { glClearColor (0.0, 0.0, 0.0, 0.0);/**//* select clearing color */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);/**//* initialize viewing values */ } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);/**//*Declare initial display mode(single buffer and RGBA).*/ glutInitWindowSize (250, 250); /**//*Declare initial window size.*/ glutInitWindowPosition (400, 400);/**//*Declare initial window position.*/ glutCreateWindow ("hello");/**//*Open window with "hello"in its title bar.*/ init ();/**//*Call initialization routines.*/ glutDisplayFunc(myDisplay); /**//*Register callback function to display graphics.*/ glutMainLoop();/**//*Enter main loop and process events.*/ return 0; /**//* ANSI C requires main to return int. */ }  

 

你可能感兴趣的:(opengl)