#include <windows.h> 
 
 
  
#include <GL/gl.h> 
#include <GL/glu.h> 
#include <GL/glaux.h>  
//
初始化
OpenGL
场景
 
void myinit (void) 
{  
 
 
 
 
glClearColor (1.0, 1.0, 1.0, 1.0); 
 
//
将背景置成白色
 
 
 
 
 
glShadeModel (GL_FLAT); 
//
设置明暗处理
 
}  
void putpixel(int x,int y)//
画点
 
{  
 
 
 
 
glBegin(GL_POINTS); 
 
 
  
 
 
 
 
glColor3f (0.0f, 1.0f, 0.0f); 
  
 
 
 
 
glVertex2f(x, y); 
 
glEnd(); 
}  
void CirclePoint(int x,int y)//
画点
 
{ 
 
putpixel(300+x,300+y); 
 
putpixel(300+y,300+x); 
 
putpixel(300-y,300+x); 
 
putpixel(300-x,300+y); 
 
putpixel(300-x,300-y); 
 
putpixel(300-y,300-x); 
 
putpixel(300+x,300-y); 
 
putpixel(300+y,300-x); 
 
 
 
 
glBegin(GL_POINTS); 
 
 
  
 
 
 
 
glColor3f (0.0f, 1.0f, 0.0f); 
 
 
glEnd(); 
} 
  
//
用户的绘图过程
  
void MidBresenhamCircle(int r) 
{  
 
 
 
int x,y,d;  
 
 
 
x=0;y=r;d=1-r; 
 
 
 
while(x<=y){ 
 
 
 
 
CirclePoint(x,y); 
 
 
 
 
if(d<0) d+=2*x+3; 
 
 
 
 
else{ 
 
 
 
 
 
 
 
d+=2*(x-y)+5; 
 
 
 
 
y--; 
 
 
 
 
}