标签:create creat void return ace clear ssi oid less
1 //Five edges polygon. 2 //As less code as possible. 3 4 #include "stdafx.h" 5 #include<gl/glut.h> 6 #include<stdlib.h> 7 #include<iostream> 8 #include<math.h> 9 10 const GLdouble PI = 3.1415926; 11 static GLdouble x, y; 12 using namespace std; 13 14 void drawCircle(GLdouble radius, GLdouble divide) 15 { 16 17 for (int k = 0; k < divide; k++) 18 { 19 x = radius* cos((k / divide) * 2 * PI); 20 y = radius* sin((k / divide) * 2 * PI); 21 glColor3f((k/divide), 1.0, 1.0); 22 glVertex3d(x, y, 0.0); 23 cout << "(" << x << "," << y << "("<<endl; 24 } 25 } 26 27 void init(void) 28 { 29 glClearColor(0.0, 0.0, 0.0, 0.0); 30 } 31 32 void display(void) 33 { 34 glClear(GL_COLOR_BUFFER_BIT); 35 36 37 glBegin(GL_POLYGON); 38 39 drawCircle(0.8, 100); 40 41 glEnd(); 42 glFlush(); 43 44 } 45 46 47 int main(int argc, char** argv) 48 { 49 glutInit(&argc, argv); 50 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); 51 glutInitWindowPosition(500, 300); 52 glutInitWindowSize(500, 500); 53 glutCreateWindow("DrawGeometry"); 54 init(); 55 glutDisplayFunc(display); 56 glutMainLoop(); 57 return 0; 58 }
画了一个圆
并打印输出x,y坐标
标签:create creat void return ace clear ssi oid less
原文地址:http://www.cnblogs.com/turningpoint/p/6700879.html