12 void reshape(int x, int y);
13 void keyb(unsigned char key, int x, int y);
17 int main(int argc, char **argv)
19 unsigned int flags = GLUT_RGB | GLUT_DOUBLE;
21 flags |= GLUT_MULTISAMPLE;
24 glutInit(&argc, argv);
25 glutInitWindowSize(800, 600);
26 glutInitDisplayMode(flags);
27 glutCreateWindow("census");
29 glutDisplayFunc(display);
30 glutReshapeFunc(reshape);
31 glutKeyboardFunc(keyb);
43 if(init_logo("data/census.curves") == -1) {
48 glEnable(GL_MULTISAMPLE);
54 static void draw_disc(float x, float y, float rad, int sub)
57 glBegin(GL_TRIANGLE_FAN);
59 for(i=0; i<sub; i++) {
60 float t = (float)i / (float)(sub - 1);
61 float theta = t * M_PI * 2.0;
62 glVertex2f(cos(theta) * rad + x, sin(theta) * rad + y);
67 static void draw_line(float x0, float y0, float x1, float y1, float rad)
69 float dx, dy, rx, ry, len;
73 len = sqrt(dx * dx + dy * dy);
78 draw_disc(x0, y0, rad, 8);
79 draw_disc(x1, y1, rad, 8);
82 glVertex2f(x0 + rx, y0 + ry);
83 glVertex2f(x1 + rx, y1 + ry);
84 glVertex2f(x1 - rx, y1 - ry);
85 glVertex2f(x0 - rx, y0 - ry);
92 float a[2], b[2], dt = 1.0f / (float)(nverts - 1);
94 glClear(GL_COLOR_BUFFER_BIT);
99 for(i=0; i<nverts-1; i++) {
100 float t0 = (float)i * dt;
101 float t1 = (float)(i + 1) * dt;
104 draw_line(a[0], a[1], b[0], b[1], 0.02);
109 draw_disc(a[0], a[1], 0.05, 18);
110 draw_disc(b[0], b[1], 0.05, 18);
112 glColor3f(0.8, 0, 0);
113 draw_disc(0, 0, 0.14, 24);
116 assert(glGetError() == GL_NO_ERROR);
119 void reshape(int x, int y)
121 float aspect = (float)x / (float)y;
123 glViewport(0, 0, x, y);
124 glMatrixMode(GL_PROJECTION);
126 glScalef(1.0f / aspect, 1.0f, 1.0f);
129 void keyb(unsigned char key, int x, int y)
137 printf("nverts: %d\n", nverts);
143 printf("nverts: %d\n", nverts);