资源简介
利用opengl使用Microsoft Visual Studio 2005编写出来的小程序,附带着源代码

代码片段和文件信息
#define MAX_POLYGONS 8
#define MAX_VERTICES 10
#define TRUE 1
#define FALSE 0
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
void myMouse(intintintint);
void myMotion(intint);
void myDisplay();
void Reshape(intint);
void color_menu(int);
void safe_menu(int);
void main_menu(int);
int pick_polygon(int xint y);
void myinit();
typedef struct polygon
{
int color;
bool used;
int xminxmaxyminymax;
float xcyc;
int nvertices;
int x[MAX_VERTICES];
int y[MAX_VERTICES];
}polygon;
bool picking = FALSE;
bool moving = FALSE;
bool changing = false;
bool del = false;
int in_polygon = -1;
int present_color = 0;
int fs;
ifstream fin;
ofstream fout;
GLsizei wh = 500ww = 500;
int draw_mode = 0;
GLfloat colors[8][3]={{0.00.00.0}{1.00.00.0}{0.01.00.0}{0.00.01.0}{0.01.01.0}{1.00.01.0}{1.01.00.0}{1.01.01.0}};
polygon polygons[MAX_POLYGONS];
void myReshape(int wint h)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0(GLdouble)w0.0(GLdouble)h);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(00wh);
ww = w;
wh = h;
}
void myinit()
{
int i;
glClearColor(1.01.01.01.0);
for(i=0;i polygons[i].used=FALSE;
}
void myMouse(int btnint stateint xint y)
{
int ij;
y = wh-y;
if(btn==GLUT_LEFT_BUTTON && state==GLUT_DOWN && !picking && !moving)
{
moving = FALSE;
if(in_polygon>=0)
{
if(polygons[in_polygon].nvertices==MAX_VERTICES)
{
printf(“exceeds maximum number vertices\n“);
exit(0);
}
i=polygons[in_polygon].nvertices;
polygons[in_polygon].x[i]=x;
polygons[in_polygon].y[i]=y;
polygons[in_polygon].nvertices++;
}
}
if(btn==GLUT_LEFT_BUTTON && state==GLUT_DOWN && picking && !moving)
{
picking= FALSE;
moving =FALSE;
j=pick_polygon(xy);
if(j>=0)
{
polygons[j].used=FALSE;
in_polygon=-1;
glutPostRedisplay();
}
}
}
int pick_polygon(int xint y)
{
int i;
for(i=0;i {
if(polygons[i].used)
if((x>=polygons[i].xmin)&&(x<=polygons[i].xmax)&&(y>=polygons[i].ymin)&&(y<=polygons[i].ymax))
{
in_polygon=i;
moving = TRUE;
return(i);
}
}
printf(“not in a polygon\n“);
return(-1);
}
void myMotion(int xint y)
{
float dxdy;
int ij;
if(moving)
{
y = wh -y;
j = pick_polygon(xy);
if(j<0)
{
printf(“not in a polygon\n“);
return;
}
dx=x-polygons[j].xc;
dy=y-polygons[j].yc;
for(i=0;i {
polygons[j].x[i]+=dx;
polygons[j].y[i]+=dy;
}
polygons[j].xc+=dx;
polygons[j].yc+=dy;
if(dx>0)
polygons[j].xmax+=dx;
else
polygons[j].xmin+=dx;
if(dy>0)
polygons[j].ymax+=dy;
else
polygons[j].ymin+=dy;
glutPostRedisplay
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7278 2013-11-13 19:59 test02.cpp
文件 47616 2013-11-17 17:40 实验模板.doc
文件 61440 2013-11-17 17:33 实验二(2).exe
----------- --------- ---------- ----- ----
116334 3
- 上一篇:中国软件文档国家标准
- 下一篇:小程序离职交接文档
相关资源
- OpenGL参考手册
- Qt Creator opengl实现四元数鼠标控制轨迹
- OpenGL文档,api大全,可直接查询函数
- opengl轮廓字体源代码
- MFC读三维模型obj文件
- 利用OpenGL写毛笔字算法
- MFC中OpenGL面和体的绘制以及动画效果
- 基于OPENGL的光线跟踪源代码368758
- VC 实现三维旋转(源码)
- 自编用openGL实现3D分形树,分形山
- OpenGL球形贴图自旋程序
- OpenGL导入贴图的Texture类
- 计算机图形学(openGL)代码
- 用OpenGL开发的机械臂运动仿真程序(
- OpenGL-3D坦克模拟
- OPENGL实现世界上最小的3D游戏
- VS2012OpenGL配置所需要的全部libdllh文件
- 基于OpenGL的仿蝗虫机器人三维动态仿
- 图形学 - OpenGL实现3种三维茶壶显示源
- opengl程序-会跳舞的骷髅
- opengl实现三维网格光顺Laplacian算法
- opengl——爆炸
- OpenGL三维地形建模
- opengl游戏编程徐明亮版(含源码)
- 用OPENGL画的一个简单的直升飞机
- opengl完美天空盒
- 3D绘图程序设计:使用Direct3D 10/9和Ope
- OpenGL绘制可运动自行车源程序.zip
- OpenGL实现飘动效果
- opengl室内场景的绘制,包括碰撞检测
评论
共有 条评论