简介本文向大家介绍OpenGL一个函数实现抗锯齿,感兴趣的朋友可以参考一下。

代码

	const double PI = acos(-1.0);
	/**
	* 绘制椭圆
	*
	* @param x			圆心x坐标
	* @param y			圆心y坐标
	* @param R1			长轴半径
	* @param R2			短轴半径
	* @param bIsFill	是否填充
	*
	**/
	static void DrawEllipse(GLfloat x, GLfloat y, GLfloat R1, GLfloat R2, bool bIsFill = false)
	{
		int nPointCount = 200;
		if (bIsFill)
		{
			glBegin(GL_POLYGON);
		}
		else
		{
			glBegin(GL_LINE_LOOP);
		}
		for (int i = 0; i < nPointCount; ++i)
		{
			glVertex2f(x + R1*cos(2 * PI / nPointCount*i), y + R2*sin(2 * PI / nPointCount*i));
		}
		glEnd();
	}


更多为你推荐