OpenGL中点算法画圆弧、内接多边形算法画圆

#include "stdafx.h"
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define PI acos(-1.0)
#define Jiao (36.0/180*PI)
void init1(){
      glClearColor(0.0,0.0,0.0,1.0);
}
double x[110],y[110];
void Set(int x,int y,int c1,int c2,int c3){  
    glVertex2f(x,y);  
}  
//中点算法画圆弧
void drawB(){
	int x=-50,y=50;
	double r=50;
	int H0=5-4*r;
	int xi=x,yi=y;
	int pian=200;
	glBegin(GL_POINTS);
		Set(xi+pian,yi+pian,1,0,0);
		while(xi<=x+r){
			if(H0<0){
				H0+=8*xi+12;
			} else {
				H0+=8*(xi-yi)+20;
			}
			if(H0>0)yi--;
			xi++;
			Set(xi+pian,yi+pian,1,0,0);
			
		}
	glEnd();
}
//内接多边形逼近画圆
void CALLBACK drawA(){
	glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1,0,0); 
	drawB();
    double xi=100,yi=100,r=50,a=18.0/180*PI,zen=2*26.0/180*PI;
    double tmp=a;
    int i;
	int n=2*PI/zen+1;
    for(i=0;i


 

你可能感兴趣的:(OpenGL中点算法画圆弧、内接多边形算法画圆)