#include<windows.h>
#include<gl.h>
#include<glu.h>
#include<glut.h>
#include <math.h>
#include<stdio.h>
#define PI 3.1415926535898
GLint circle_points =100;
// This is the draw function.
void draw()
{
glClear(GL_COLOR_BUFFER_BIT);
double angle =
2* PI/circle_points ;
glBegin(GL_LINE_LOOP);
double
angle1=0.0;
glVertex2d(
cos(0.0) , sin(0.0));
int i;
for ( i=0 ;
i< circle_points ;i++)
{
printf(
"angle = %f \n" , angle1);
glVertex2d(cos(angle1),sin(angle1));
angle1 +=
angle ;
}
glEnd();
glFlush();
}
void init()
{
glClearColor(0.0,0.0,0.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);
}
void keyboard (unsigned char key , int x, int y)
{
exit(0);
}
void main( int argc,char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE |GLUT_RGB);
glutInitWindowSize(250,250);
glutInitWindowPosition(100,100);
glutCreateWindow("ch06");
init();
glutKeyboardFunc(keyboard);
glutDisplayFunc(draw);
glutMainLoop();
}
No comments:
Post a Comment