#include<GL/glut.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
void drawCircle(float radius,int start,int end,float x1, float y1)
{
float angle = 0;
float x2,y2,cx,cy,fx,fy;
int cache = 0;
glEnable(GL_LINE_SMOOTH);
glLineWidth(10.0);
glBegin(GL_LINES);
for (angle = start; angle < end; angle+=1.0) {
float rad_angle = angle * 3.14 / 180;
x2 = radius * sin((double)rad_angle);
y2 = radius * cos((double)rad_angle);
if (cache) {
//glVertex2f(0.0,0.0);
glVertex2f(cx,cy);
glVertex2f(x2,y2);
} else {
fx = x2;
fy = y2;
}
cache = 1;
cx = x2;
cy = y2;
}
//glVertex2f(0.0,0.0);
//glVertex2f(x2,y2);
//glVertex2f(fx,fy);
glEnd();
}
void display(void)
{
glClearColor(1.0,1.0,1.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glTranslatef(-10,0,-30);
glColor3ub(253,77,44);
drawCircle(5,,180,0,0);
glutSwapBuffers();
}
void reshape (int w, int h) {
glViewport (0, 0, (GLsizei)w, (GLsizei)h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective (60, (GLfloat)w / (GLfloat)h, 0.1, 100.0);
glMatrixMode (GL_MODELVIEW);
}
int main (int argc, char **argv) {
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE);
glutInitWindowSize (1200, 800);
glutInitWindowPosition (0, 0);
glutCreateWindow ("lol");
//init();
glutDisplayFunc (display);
//glutIdleFunc (display);
glutReshapeFunc (reshape);
//glutKeyboardFunc (keyboard);
glutMainLoop ();
return 0;
}
Comments
Post a Comment