软件工程第二次作业
2014-11-21 19:10
387 查看
这次作业是做一个小游戏。选择了C++语言,使用OpenGL图形接口。可以通过键盘上的q,w,e,r,t,a,s,d,f,g,h来旋转改变魔方的各种组合。程序主要文件包括CubeGame.cpp(创建屏幕窗口),cubemanage.cpp(操纵魔方), wcgcube.cpp(渲染魔方)。
项目参与人员:鞠凡,学号:2012211565,班级:0411202,主要负责:代码
张明熙,学号:2012211735,班级:0411202,主要负责:资料
主要代码:
程序运行截图:
性能分析:
调用关系树:
WcgCube.exe调用了许多系统动态链接库。
进程:
WcgCube.exe是程序中唯一的进程,进程ID是14260。
CPU:
程序运行36秒左右,CPU占用峰值大约5%。
热路径:
函数:
几个系统重要文件占的比重比较大,如ig4icd32.dll, gdi32.dll等, 还有用户界面API user32.dll。程序中的WcgCube::draw函数是除系统函数之外占比最大的,其他还有CubeManage::draw等。
模块:
WcgCube.exe模块是除几个系统重要模块之外占比最大的。
心得:结对编程的好处就是可以互相弥补对方的不足,有效提高软件开发效率。合作时一定要多沟通,互相交流想法。
项目参与人员:鞠凡,学号:2012211565,班级:0411202,主要负责:代码
张明熙,学号:2012211735,班级:0411202,主要负责:资料
主要代码:
#include <windows.h> // Windows API #include <Gl/glut.h> // gl.h和glu.h已经包括在glut.h中了 #include <math.h> #include <iostream.h> #include "cubemanage.h" // 操纵魔方 #include "wcgcube.h" // 渲染魔方 static GLfloat PI=3.1415f; // 旋转量 static GLfloat xRot = 0.0f; static GLfloat yRot = 0.0f; static GLfloat rotate=0.0f; static int rotateType=0; static int rotateOK=0; static int rotateRate=100; static GLfloat rotateStep=5*PI/180; CubeManage cm; // 渲染屏幕函数 void RenderScene(void)
{ <span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>// 清除当前屏幕 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); <span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>glPushMatrix(); <span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>glRotatef(xRot, 1.0f, 0.0f, 0.0f); glRotatef(yRot, 0.0f, 1.0f, 0.0f); cm.draw(rotateType,rotate); <span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>glPopMatrix();
// 显示图形
glutSwapBuffers();
}
// 渲染环境初始化
void SetupRC()
{ <span style="white-space:pre"> </span><span style="white-space:pre"> </span>// 黑色背景
glClearColor(0.0f, 0.0f, 0.0f, 1.0f );
glEnable(GL_DEPTH_TEST);
// glEnable(GL_DITHER);
glShadeModel(GL_SMOOTH);
}
void TimerFunc(int value)
{
<span style="white-space:pre"> </span>
<span style="font-family: Arial, Helvetica, sans-serif;"> </span>
if (rotate>=PI/2) { cm.turn(rotateType); rotateType=0; rotateOK=0; rotate=0.0f; // 刷新窗口 glutPostRedisplay(); return; } rotate+=rotateStep; // 刷新窗口 glutPostRedisplay(); glutTimerFunc(rotateRate,TimerFunc,1); } void SpecialKeys(int key, int x, int y) { if (key == GLUT_KEY_F1) { if (rotateOK==1) return; rotateType=1; rotateOK=1; rotate=0.0f; glutTimerFunc(rotateRate,TimerFunc,1); } if (key == GLUT_KEY_F2) { if (rotateOK==1) return; rotateType=2; rotateOK=1; rotate=0.0f; glutTimerFunc(rotateRate,TimerFunc,1); } if (key == GLUT_KEY_F3) { if (rotateOK==1) return; rotateType=3; rotateOK=1; rotate=0.0f; glutTimerFunc(rotateRate,TimerFunc,1); } if (key == GLUT_KEY_F4) { if (rotateOK==1) return; rotateType=4; rotateOK=1; rotate=0.0f; glutTimerFunc(rotateRate,TimerFunc,1); } if (key == GLUT_KEY_F5) { if (rotateOK==1) return; rotateType=5; rotateOK=1; rotate=0.0f; glutTimerFunc(rotateRate,TimerFunc,1); } if (key == GLUT_KEY_F6) { if (rotateOK==1) return; rotateType=6; rotateOK=1; rotate=0.0f; glutTimerFunc(rotateRate,TimerFunc,1); } if (key == GLUT_KEY_F7) { if (rotateOK==1) return; rotateType=7; rotateOK=1; rotate=0.0f; glutTimerFunc(rotateRate,TimerFunc,1); } if (key == GLUT_KEY_F8) { if (rotateOK==1) return; rotateType=8; rotateOK=1; rotate=0.0f; glutTimerFunc(rotateRate,TimerFunc,1); } if (key == GLUT_KEY_F9) { if (rotateOK==1) return; rotateType=9; rotateOK=1; rotate=0.0f; glutTimerFunc(rotateRate,TimerFunc,1); } if (key == GLUT_KEY_F10) { if (rotateOK==1) return; rotateType=10; rotateOK=1; rotate=0.0f; glutTimerFunc(rotateRate,TimerFunc,1); } if (key == GLUT_KEY_F11) { if (rotateOK==1) return; rotateType=11; rotateOK=1; rotate=0.0f; glutTimerFunc(rotateRate,TimerFunc,1); } if (key == GLUT_KEY_F12) { if (rotateOK==1) return; rotateType=12; rotateOK=1; rotate=0.0f; glutTimerFunc(rotateRate,TimerFunc,1); } if(key == GLUT_KEY_UP) xRot-= 5.0f; if(key == GLUT_KEY_DOWN) xRot += 5.0f; if(key == GLUT_KEY_LEFT) yRot -= 5.0f; if(key == GLUT_KEY_RIGHT) yRot += 5.0f; if(key > 356.0f) xRot = 0.0f; if(key < -1.0f) xRot = 355.0f; if(key > 356.0f) yRot = 0.0f; if(key < -1.0f) yRot = 355.0f; // 刷新屏幕 glutPostRedisplay(); } void ChangeSize(int w, int h) { GLfloat nRange = 100.0f; // 避免除数为0 if(h == 0) <span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>h = 1; // 设置视觉点 <span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>glViewport(0, 0, w, h); // 重置坐标系统 glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Establish clipping volume (left, right, bottom, top, near, far) <span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>if (w <= h) <span style="white-space:pre"> </span>glOrtho (-nRange, nRange, -nRange*h/w, nRange*h/w, -nRange, nRange); <span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span>else <span style="white-space:pre"> </span>glOrtho (-nRange*w/h, nRange*w/h, -nRange, nRange, -nRange, nRange); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutCreateWindow("RGB Cube"); glutReshapeFunc(ChangeSize); glutSpecialFunc(SpecialKeys); glutDisplayFunc(RenderScene); SetupRC(); glutMainLoop(); return 0; }
程序运行截图:
性能分析:
调用关系树:
WcgCube.exe调用了许多系统动态链接库。
进程:
WcgCube.exe是程序中唯一的进程,进程ID是14260。
CPU:
程序运行36秒左右,CPU占用峰值大约5%。
热路径:
函数:
几个系统重要文件占的比重比较大,如ig4icd32.dll, gdi32.dll等, 还有用户界面API user32.dll。程序中的WcgCube::draw函数是除系统函数之外占比最大的,其他还有CubeManage::draw等。
模块:
WcgCube.exe模块是除几个系统重要模块之外占比最大的。
心得:结对编程的好处就是可以互相弥补对方的不足,有效提高软件开发效率。合作时一定要多沟通,互相交流想法。
相关文章推荐
- 2017年软件工程第二次作业
- 软件工程第二次作业----(1)补交
- 软件工程第二次作业:基于Unity的3D魔方实现
- 【软件工程实践 · 团队项目】 第二次作业
- 第二次软件工程作业
- 高级软件工程第二次作业
- 2017 软件工程 结对第二次作业
- 2016福州大学软件工程团队选题报告(团队第二次作业)成绩
- 17秋 软件工程 团队第二次作业 选题报告
- 软件工程——第二次作业
- 现代软件工程第二次作业
- 软件工程第二次作业
- 软件工程作业-----第二次
- 结合directx3D函数库3D视角游戏(软件工程第二次作业)
- 2016福州大学软件工程第二次结对编程作业成绩
- 软件工程第二次作业
- 软件工程第二次作业
- 第二次软件工程作业:第一次组队编程
- 软件工程第二次作业 软件评价
- 软件工程第二次作业 软件评价