资源简介
内容和要求:
1. 利用GLUT库,编写一个OpenGL程序,实现以下功能:
仿照课本的例子,绘制若干OpenGL基本体素(三角形、三角形带、四边形、四边
形带)构成的球体,
可以控制改变球的数量和球的体积,来改变基本体素的数量以及顶点的数量。
可以通过改变glPolygonMode,切换是否填充所绘制的基本体素。
可以通过glRotate,使绘制的球体旋转。
利用函数glutGet(GLUT_ELAPSED_TIME)(returns the time in milliseconds since
glutInit or the first invocation of the function)统计绘制时间

代码片段和文件信息
#include “stdafx.h“
#include
#include
#include
#include
#define pi 3.1415926
#define GLfloat float
#define GLdouble double
#define GLint int
double c=pi/180.0;
double radius=90.0;
int w=1000h=700;
double a=10.0;
int aa=0;
int bb=1;
int cc=0;
int dd=0;
int num=1;
int strip=GL_TRIANGLE_STRIP;
int mode=GL_LINE;
void drawSphere(void)
{
float thetaphirphithetarphir20;
float xyz;
for(phi=-90.0;phi<=90.0;phi+=a)
{
phir=c*phi;
phir20=c*(phi+a);
glPolygonMode(GL_FRONTmode);
glPolygonMode(GL_BACK mode);
glFrontFace(GL_CCW); //逆时针为正面
glBegin(strip);
for(theta=-180.0;theta<=180.0;theta+=a)
{
thetar=c*theta;
x=radius*sin(thetar)*cos(phir);
y=radius*cos(thetar)*cos(phir);
z=radius*sin(phir);
glVertex3f(xyz);
x=radius*sin(thetar)*cos(phir20);
y=radius*cos(thetar)*cos(phir20);
z=radius*sin(phir20);
glVertex3f(xyz);
}
glEnd();
}
glPolygonMode(GL_FRONTmode);
glPolygonMode(GL_BACK mode);
glFrontFace(GL_CCW);
glBegin(strip);
glVertex3d(0.00.0radius);
double c80=c*90.0;
z=radius*sin(c80);
for(theta=-180.0;theta<=180.0;theta+=a)
{
thetar=c*theta;
x=radius*sin(thetar)*cos(c80);
y=radius*cos(thetar)*cos(c80);
glVertex3f(xyz);
}
glEnd();
glPolygonMode(GL_FRONTmode);
glPolygonMode(GL_BACK mode);
glFrontFace(GL_CCW);
glBegin(strip);
glVertex3f(0.00.0-radius);
z=-radius*sin(c80);
for(theta=-180.0;theta<=180.0;theta+=a)
{
thetar=c*theta;
x=radius*sin(thetar)*cos(c80);
y=radius*cos(thetar)*cos(c80);
glVertex3f(xyz);
}
glEnd();
}
void init(void)
{
glViewport(00wh);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glClearColor(1.01.01.00.0);
glColor3f(0.01.00.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
//void mouse(int btnint stateint xint y)
//{
//
//}
void reshape(GLsizei ww GLsizei hh)
{
glViewport (0 0 (GLsizei) w (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0 (GLdouble)w 0.0(GLdouble)h -w h);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT);
glutPostRedisplay();
w=ww;
h=hh;
}
void display(void)
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
int n=1;
for(n=1;n<=num;n++)
{
glTranslated(90+40*nh/20);
glRotated(aabb+n*100cc+n*100dd);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 37888 2012-12-23 08:53 polycom\Debug\polycom.exe
文件 416512 2012-12-23 08:53 polycom\Debug\polycom.ilk
文件 568320 2012-12-23 08:53 polycom\Debug\polycom.pdb
文件 6304 2012-12-23 08:53 polycom\polycom\Debug\BuildLog.htm
文件 60 2012-12-23 08:53 polycom\polycom\Debug\mt.dep
文件 663 2012-11-19 16:33 polycom\polycom\Debug\polycom.exe.em
文件 728 2012-11-19 16:33 polycom\polycom\Debug\polycom.exe.em
文件 621 2012-12-23 08:53 polycom\polycom\Debug\polycom.exe.intermediate.manifest
文件 46684 2012-12-23 08:53 polycom\polycom\Debug\polycom.obj
文件 3211264 2012-11-19 16:33 polycom\polycom\Debug\polycom.pch
文件 12009 2012-11-19 16:33 polycom\polycom\Debug\stdafx.obj
文件 363520 2012-12-23 08:53 polycom\polycom\Debug\vc90.idb
文件 167936 2012-12-23 08:53 polycom\polycom\Debug\vc90.pdb
文件 5578 2012-11-19 16:47 polycom\polycom\polycom.cpp
文件 4498 2012-11-16 20:14 polycom\polycom\polycom.vcproj
文件 1413 2012-12-23 08:55 polycom\polycom\polycom.vcproj.Smile-PC.Smile.user
文件 1183 2012-11-16 20:14 polycom\polycom\ReadMe.txt
文件 212 2012-11-16 20:14 polycom\polycom\stdafx.cpp
文件 233 2012-11-16 20:14 polycom\polycom\stdafx.h
文件 498 2012-11-16 20:14 polycom\polycom\targetver.h
文件 11996160 2012-12-23 08:55 polycom\polycom.ncb
文件 887 2012-11-16 20:14 polycom\polycom.sln
..A..H. 10752 2012-12-23 08:55 polycom\polycom.suo
目录 0 2012-12-23 08:53 polycom\polycom\Debug
目录 0 2012-11-19 16:33 polycom\Debug
目录 0 2012-11-19 16:47 polycom\polycom
目录 0 2012-11-16 20:15 polycom
----------- --------- ---------- ----- ----
16853923 27
............此处省略0个文件信息
相关资源
- 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室内场景的绘制,包括碰撞检测
评论
共有 条评论