⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 circle1.cpp

📁 a source code for banker s algorithm
💻 CPP
字号:
#include<glut.h>
#include<windows.h>
	
void myInit(void)
{
		glClearColor(1.0,1.0,1.0,1.0);
		glColor3f(1.0,0.0,0.0);
		glPointSize(4.0);
		gluOrtho2D(300.0,0.0,300.0,0.0);
}



void plotPixel(GLint cx,GLint cy)
{
		glColor3f(1.0,0.0,0.0);
		glBegin(GL_POINTS);
			glVertex2i(cx,cy);
		glEnd();
}



void drawPixel(GLint h,GLint k,GLint x,GLint y)
{
		plotPixel(x+h,y+k);
		plotPixel(-x+h,y+k);
		plotPixel(x+h,-y+k);
		plotPixel(-x+h,-y+k);
		plotPixel(y+h,x+k);
		plotPixel(-y+h,x+k);
		plotPixel(y+h,-x+k);
 		plotPixel(-y+h,-x+k);
}


void drawCircle(int h,int k,int r)
{
	GLint d=1-r,x=0,y=r;
		while(y>x)
	{
		drawPixel(h,k,x,y);
		if(d<0)
		d=d+2*x+3;
		 
		else
		{	d=d+2*(x-y)+5;
			y=y-1;
		}

		x=x+1;
	}
	 drawPixel(h,k,x,y);
}



void display(void)
{
		GLint xc=100,yc=100,r=50;
		glClear(GL_COLOR_BUFFER_BIT);
		drawCircle(xc,yc,r);
		glFlush();
}

void main(void)
{
	glutInitWindowPosition(100,100);
	glutCreateWindow("Circle");
	glutDisplayFunc(display);
	myInit();
	glutMainLoop();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -