opengl绘制卡通人物哆啦A梦

前段时间老师布置一作业,我画了一个哆啦A梦,代码如下

#include <Windows.h>
#include <gl\glut.h>
#include <stdio.h>  
#include<math.h>

#define GLUT_DISABLE_ATEXIT_HACK 
#define N 100
const GLfloat tempR = 0.5f;//脸半径
const GLfloat PI = 3.1415926536f;


//颜色设置
static GLfloat ColorChoose[5][3] = {
	{ 0.0, 0.74, 1.0 }, { 1.0, 1.0, 1.0 }, { 1.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 },
	{ 1.0, 1.0, 0.0 } };

static GLfloat r = 1.0f, g = 1.0f, b = 0.0f;
static GLfloat spin = 0.0;
int fg = 0;
static float x = 400, y = 400;

static int FACE_COLOR = 0;//湖蓝色
static int EYE_COLOR = 1;//白色
static int NOSE_COLOR = 2;//红色
static int LINE_COLOR = 3;//黑色
static int LINGDANG_COLOR = 4;//黄色




//画脸 0.0, 0.4, 0.4
void face(float x, float y, float radius)
{
	int count;
	int sections = 200;

	GLfloat TWOPI = 2.0f * 3.14159f;

	//glLineWidth(1.f);
	glColor3f(ColorChoose[FACE_COLOR][0], ColorChoose[FACE_COLOR][1], ColorChoose[FACE_COLOR][2]);
	glBegin(GL_TRIANGLE_FAN);
	glVertex2f(x, y);

	for (count = 0; count <= sections; count++)
	{
		glVertex2f(x + radius*cos(count*TWOPI / sections), y + radius*sin(count*TWOPI / sections));
	}
	glEnd();
}

//脸白
void face1(float x, float y, float radius)
{
	int count;
	int sections = 200;

	GLfloat TWOPI = 2.0f * 3.14159f;

	//glLineWidth(1.f);
	glColor3f(ColorChoose[EYE_COLOR][0], ColorChoose[EYE_COLOR][1], ColorChoose[EYE_COLOR][2]);
	glBegin(GL_TRIANGLE_FAN);
	glVertex2f(x, y);

	for (count = 0; count <= sections; count++)
	{
		glVertex2f(x + radius*cos(count*TWOPI / sections), y + radius*sin(count*TWOPI / sections));
	}
	glEnd();
}

//描线
void drawline(float x, float y, float radius)
{
	int count;
	int sections = 200;

	GLfloat TWOPI = 2.0f * 3.14159f;
	glLineWidth(3);
	glColor3f(ColorChoose[LINE_COLOR][0], ColorChoose[LINE_COLOR][1], ColorChoose[LINE_COLOR][2]);
	glBegin(GL_LINE_STRIP);
	for (count = 0; count <= sections; count++)
	{
		glVertex2f(x + radius*cos(count*TWOPI / sections), y + radius*sin(count*TWOPI / sections));
	}
	glEnd();
}

//嘴巴
void mouthhalf(float x, float y, float radius)
{
	int count;
	int sections = 200;

	GLfloat TWOPI = 2.0f * 3.14159f;

	//glLineWidth(1.f);
	glColor3f(ColorChoose[NOSE_COLOR][0], ColorChoose[NOSE_COLOR][1], ColorChoose[NOSE_COLOR][2]);
	glBegin(GL_TRIANGLE_FAN);
	glVertex2f(x, y);

	for (count = 100; count <= 
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值