在visualstudio2010下用OpenGL编写的程序,用于显示一个二维图形(本代码中为一只小猪),并可实现鼠标拖拽,键盘控制移动,右键菜单等功能。
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 26112 2013-10-07 21:08 myPigDebugmyPig.exe
文件 392212 2013-09-28 16:51 myPigDebugmyPig.ilk
文件 625664 2013-10-07 21:08 myPigDebugmyPig.pdb
文件 46530560 2013-10-08 11:16 myPigipchmypig-f467bea0mypig-f3d6fad2.ipch
文件 738 2013-10-07 21:08 myPigmyPigDebugcl.command.1.tlog
文件 21792 2013-10-07 21:08 myPigmyPigDebugCL.read.1.tlog
文件 468 2013-10-07 21:08 myPigmyPigDebugCL.write.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink-cvtres.read.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink-cvtres.write.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.2576-cvtres.read.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.2576-cvtres.write.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.2576.read.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.2576.write.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.6140-cvtres.read.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.6140-cvtres.write.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.6140.read.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.6140.write.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.6476-cvtres.read.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.6476-cvtres.write.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.6476.read.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.6476.write.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.7952-cvtres.read.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.7952-cvtres.write.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.7952.read.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.7952.write.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.9352-cvtres.read.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.9352-cvtres.write.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.9352.read.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.9352.write.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebuglink.9824-cvtres.read.1.tlog
............此处省略39个文件信息
#include
#include
#include
#include
const int n = 1000;
const GLfloat RB = 0.7f; //身体半径
const GLfloat RL = 0.1f; //左右腿半径
const GLfloat a = 0.15f; //鼻子长半轴长
const GLfloat b = 0.1f; //鼻子短半轴长
const GLfloat RN = 0.02f; //鼻孔半径
const GLfloat RE = 0.03f; //眼睛半径
const GLfloat RE2 = 0.05f; //瞪眼后眼睛半径
const GLfloat RE3 = 0.01f; //眯眼后眼睛半径
const GLfloat Pi = 3.1415926536f; //圆周率
GLfloat x = 0.0f; //x轴坐标原点
GLfloat y = 0.0f; //y轴坐标原点
GLfloat z = 0.0f; //z轴坐标原点
GLfloat sx = 1.0f; //x轴缩放参数
GLfloat sy = 1.0f; //y轴缩放参数
GLfloat sz = 1.0f; //z轴缩放参数
GLint mx ; //鼠标x轴坐标
GLint my; //鼠标y轴坐标
void myDisplay(void)
{
glClearColor(1.0 1.0 1.0 1.0); //设置背景为白色
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0 0.5 0.5);
glBegin(GL_POLYGON);
glVertex2f(RB*cos(5*Pi/6)+x RB*sin(5*Pi/6)+y);
glVertex2f(RB*cos(2*Pi/3)+x RB*sin(2*Pi/3)+y);
glVertex2f(-0.64+x 0.64+y);
glEnd();//左耳
glColor3f(1.0 0.5 0.5);
glBegin(GL_POLYGON);
glVertex2f(RB*cos(Pi/6)+x RB*sin(Pi/6)+y);
glVertex2f(RB*cos(Pi/3)+x RB*sin(Pi/3)+y);
glVertex2f(0.64+x 0.64+y);
glEnd();//右耳
glColor3f(1.0 0.5 0.5);
glBegin(GL_POLYGON);
for(int i=0; i glVertex2f(-0.4+RL*cos(2*Pi/n*i)+x -0.6+RL*sin(2*Pi/n*i)+y);
glEnd();//左腿
glColor3f(1.0 0.5 0.5);
glBegin(GL_POLYGON);
for(int i=0; i glVertex2f(0.4+RL*cos(2*Pi/n*i)+x -0.6+RL*sin(2*Pi/n*i)+y);
glEnd();//右腿
glColor3f(1.0 0.8 0.8);
glBegin(GL_POLYGON);
for(int i=0; i glVertex2f(RB*cos(2*Pi/n*i) +x RB*sin(2*Pi/n*i)+y);
glEnd();//身体
glColor3f(1.0 0.5 0.5);
glBegin(GL_POLYGON);
for(int i=0; i glVertex2f(a*cos(2*Pi/n*i) + x b*sin(2*Pi/n*i)+y);
glEnd();//鼻子
glColor3f(0.0 0.0 0.0);
glBegin(GL_POLYGON);
for(int i=0; i glVertex2f(-0.07+RN*cos(2*Pi/n*i)+x RN*sin(2*Pi/n*i)+y);
glEnd();//左鼻孔
glColor3f(0.0 0.0 0.0);
glBegin(GL_POLYGON);
for(int i=0; i glVertex2f(0.07+RN*cos(2*Pi/n*i)+x RN*sin(2*Pi/n*i)+y);
glEnd();//右鼻孔
glColor3f(0.0 0.0 0.0);
glBegin(GL_POLYGON);
for(int i=0; i glVertex2f(-0.11+RE*cos(2*Pi/n*i)+x 0.13+RE*sin(2*Pi/n*i)+y);
glEnd();//左眼
glColor3f(0.0 0.0 0.0);
glBegin(GL_POLYGON);
for(int i=0; i glVertex2f(0.11+RE*cos(2*Pi/n*i)+x 0.13+RE*sin(2*Pi/n*i)+y);
glEnd();//右眼
//glPushMatrix();
// glScalef(sx sy sz);
//glPopMatrix();
glFlush();
}
void myDisplay2(void) //squint
{
glClearColor(1.0 1.0 1.0 1.0); //设置背景为白色
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0 0.5 0.5);
glBegin(GL_POLYGON);
glVertex2f(RB*cos(5*Pi/6)+x RB*sin(5*Pi/6)+y);
glVertex2f(RB*cos(2*Pi/3)+x RB*sin(2*Pi/3)+y);
glVertex2f(-0.64+x 0.64+y);
glEnd();//左耳
glColor3f(1.0 0.5 0.5);
glBegin(GL_POLYGON);
glVertex2f(R
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 26112 2013-10-07 21:08 myPigDebugmyPig.exe
文件 392212 2013-09-28 16:51 myPigDebugmyPig.ilk
文件 625664 2013-10-07 21:08 myPigDebugmyPig.pdb
文件 46530560 2013-10-08 11:16 myPigipchmypig-f467bea0mypig-f3d6fad2.ipch
文件 738 2013-10-07 21:08 myPigmyPigDebugcl.command.1.tlog
文件 21792 2013-10-07 21:08 myPigmyPigDebugCL.read.1.tlog
文件 468 2013-10-07 21:08 myPigmyPigDebugCL.write.1.tlog
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
文件 2 2013-09-28 16:51 myPigmyPigDebugli
............此处省略39个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)