#include<GL/glut.h>
float theta = 0.0, thetar;
int flag=0;
void mydisplay(void)
{
float cx=-0.0,cy=0.0, r=1;
int num_segments=80;
int i;
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
thetar=theta*(3.14/180);
glColor3f(0.0, 1.0, 0.0);
glVertex2f(0.0, 0.0);
glColor3f(0.0, 1.0, 0.0);
glVertex2f(-sin(thetar), cos(thetar));
glEnd();
glBegin(GL_LINE_LOOP);
for(i = 0; i<num_segments; i++)
{
float theta1;
theta1 = (2.0 * 3.1415926 * (i)) / (num_segments);
float x = r * cosf(theta1);
float y = r * sinf(theta1);
glVertex2f(x + cx, y + cy);
}
glEnd();
glutSwapBuffers();
}
void spinDisplay(void)
{
theta -= 0.1;
if (theta < 360.0)
theta += 360.0;
glutPostRedisplay();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(150, 150);
glutInitWindowSize(500,500);
glutCreateWindow("Clock");
glutDisplayFunc(mydisplay);
glutIdleFunc(spinDisplay);
glutMainLoop();
return 0;
}
OUTPUT
No comments:
Post a Comment