How to make circle in c++ using opengl

How to make circle in c++ using OpenGL with indefinite points (GL_POINTS)

This method used the no of the point to draw a circle. The problem with this method is you need more precession and you can’t fill a circle with colors.

How to make circle in c++ using OpenGL GL_POINTS

#include<stdio.h>
#include<GL/glut.h>
double x=0,y=10,r=10;
double p0,p;
void display(void){
  
  glClear(GL_COLOR_BUFFER_BIT);
  glOrtho(-110,110,-110,110,0,100);
  p0=1-r;
  glBegin(GL_POINTS);
  while(x!=y){
    
    glColor3f(1,0.4,0.9);
    glVertex2f(x,y);
    glVertex2f(y,x);
    glVertex2f(-x,y);
    glVertex2f(-y,x);
    glVertex2f(-x,-y);
    glVertex2f(-y,-x);
    glVertex2f(x,-y);
    glVertex2f(y,-x);
    if(p0<0){
      p=p0+2*x+3;
      
    }
    else{
      p=p0+2*(x-y)+5;
      y--;
    }
    p0=p;
    x++;
}
glEnd();
glFlush();
}
 int main(int argc ,char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
    glutInitWindowSize(500,500);
    glutInitWindowPosition(0,0);  
    glutCreateWindow("Simple circle"); 
    glutDisplayFunc(display); 
    glutMainLoop();
    return 0; 
}

PEOPLE ARE ALSO VIEWING

HOW TO COUNT NUMBER OF WORDS AND LINES IN LEX PROGRAM

TOP SECRET WHATSAPP TRICKS YOU NEVER KNEW 2017

 

Leave a Reply

Your email address will not be published. Required fields are marked *