Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <GL\glut.h>
- #include <math.h>
- double height = 600;
- double width = 600;
- const double DEG2RAD = 3.14159265/180;
- void drawCircle2(double x, double y,double r)
- {
- glBegin(GL_POLYGON);
- for (int i=0; i < 360; i++)
- {
- double deg = i*DEG2RAD;
- glVertex2d(cos(deg)*r+x,sin(deg)*r+y);
- }
- glEnd();
- }
- /*
- void drawCircle(double x, double y, double r) {
- double xx1,yy1;
- glBegin(GL_LINES);
- for (double i = 0; i < 180; i+=2*eps)
- {
- xx1 = r * cos((double)i) + x;
- yy1 = r * sin((double)i) + y;
- glVertex3d(xx1,yy1,0);
- xx1= r * cos(i + eps) + x;
- yy1 = r * sin(i + eps) + y;
- glVertex3d(xx1,yy1,0);
- }
- glEnd();
- }
- */
- void Draw() {
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3f(1.0, 1.0, 1.0);
- glEnable(GL_LINE_SMOOTH);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
- drawCircle2(200,200,100);
- glBegin(GL_LINES);
- glVertex2d(0, 0);
- glVertex2d(600, 300);
- glEnd();
- glFlush();
- }
- void Initialize() {
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0.0, width, 0.0, height, -1.0, 1.0);
- }
- int main(int iArgc, char** cppArgv) {
- glutInit(&iArgc, cppArgv);
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
- glutInitWindowSize(width, height);
- glutInitWindowPosition(200, 200);
- glutCreateWindow("Example");
- Initialize();
- glutDisplayFunc(Draw);
- glutMainLoop();
- return 0;
- }
Add Comment
Please, Sign In to add comment