内容和要求:
1. 利用GLUT库,编写一个OpenGL程序,实现以下功能:
仿照课本的例子,绘制若干OpenGL基本体素(三角形、三角形带、四边形、四边
形带)构成的球体,
可以控制改变球的数量和球的体积,来改变基本体素的数量以及顶点的数量。
可以通过改变glPolygonMode,切换是否填充所绘制的基本体素。
可以通过glRotate,使绘制的球体旋转。
利用函数glutGet(GLUT_ELAPSED_TIME)(returns the time in milliseconds since
glutInit or the first invocation of the function)统计绘制时间
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 37888 2012-12-23 08:53 polycomDebugpolycom.exe
文件 416512 2012-12-23 08:53 polycomDebugpolycom.ilk
文件 568320 2012-12-23 08:53 polycomDebugpolycom.pdb
文件 6304 2012-12-23 08:53 polycompolycomDebugBuildLog.htm
文件 60 2012-12-23 08:53 polycompolycomDebugmt.dep
文件 663 2012-11-19 16:33 polycompolycomDebugpolycom.exe.embed.manifest
文件 728 2012-11-19 16:33 polycompolycomDebugpolycom.exe.embed.manifest.res
文件 621 2012-12-23 08:53 polycompolycomDebugpolycom.exe.intermediate.manifest
文件 46684 2012-12-23 08:53 polycompolycomDebugpolycom.obj
文件 3211264 2012-11-19 16:33 polycompolycomDebugpolycom.pch
文件 12009 2012-11-19 16:33 polycompolycomDebugstdafx.obj
文件 363520 2012-12-23 08:53 polycompolycomDebugvc90.idb
文件 167936 2012-12-23 08:53 polycompolycomDebugvc90.pdb
文件 5578 2012-11-19 16:47 polycompolycompolycom.cpp
文件 4498 2012-11-16 20:14 polycompolycompolycom.vcproj
文件 1413 2012-12-23 08:55 polycompolycompolycom.vcproj.Smile-PC.Smile.user
文件 1183 2012-11-16 20:14 polycompolycomReadMe.txt
文件 212 2012-11-16 20:14 polycompolycomstdafx.cpp
文件 233 2012-11-16 20:14 polycompolycomstdafx.h
文件 498 2012-11-16 20:14 polycompolycom argetver.h
文件 11996160 2012-12-23 08:55 polycompolycom.ncb
文件 887 2012-11-16 20:14 polycompolycom.sln
..A..H. 10752 2012-12-23 08:55 polycompolycom.suo
目录 0 2012-12-23 08:53 polycompolycomDebug
目录 0 2012-11-19 16:33 polycomDebug
目录 0 2012-11-19 16:47 polycompolycom
目录 0 2012-11-16 20:15 polycom
----------- --------- ---------- ----- ----
16853923 27
............此处省略0个文件信息
#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 polycomDebugpolycom.exe
文件 416512 2012-12-23 08:53 polycomDebugpolycom.ilk
文件 568320 2012-12-23 08:53 polycomDebugpolycom.pdb
文件 6304 2012-12-23 08:53 polycompolycomDebugBuildLog.htm
文件 60 2012-12-23 08:53 polycompolycomDebugmt.dep
文件 663 2012-11-19 16:33 polycompolycomDebugpolycom.exe.em
文件 728 2012-11-19 16:33 polycompolycomDebugpolycom.exe.em
文件 621 2012-12-23 08:53 polycompolycomDebugpolycom.exe.intermediate.manifest
文件 46684 2012-12-23 08:53 polycompolycomDebugpolycom.obj
文件 3211264 2012-11-19 16:33 polycompolycomDebugpolycom.pch
文件 12009 2012-11-19 16:33 polycompolycomDebugstdafx.obj
文件 363520 2012-12-23 08:53 polycompolycomDebugvc90.idb
文件 167936 2012-12-23 08:53 polycompolycomDebugvc90.pdb
文件 5578 2012-11-19 16:47 polycompolycompolycom.cpp
文件 4498 2012-11-16 20:14 polycompolycompolycom.vcproj
文件 1413 2012-12-23 08:55 polycompolycompolycom.vcproj.Smile-PC.Smile.user
文件 1183 2012-11-16 20:14 polycompolycomReadMe.txt
文件 212 2012-11-16 20:14 polycompolycomstdafx.cpp
文件 233 2012-11-16 20:14 polycompolycomstdafx.h
文件 498 2012-11-16 20:14 polycompolycom argetver.h
文件 11996160 2012-12-23 08:55 polycompolycom.ncb
文件 887 2012-11-16 20:14 polycompolycom.sln
..A..H. 10752 2012-12-23 08:55 polycompolycom.suo
目录 0 2012-12-23 08:53 polycompolycomDebug
目录 0 2012-11-19 16:33 polycomDebug
目录 0 2012-11-19 16:47 polycompolycom
目录 0 2012-11-16 20:15 polycom
----------- --------- ---------- ----- ----
16853923 27
............此处省略0个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)