資源簡介
從.gl中讀取信息,在OpenGL中繪制自行車的三維模型,并實現了自行車的運動和改變方向 放大縮小等

代碼片段和文件信息
#include?“stdafx.h“
#include?
#include?
#include?
#include?
#include?
#include?
#include?“bicycle.h“
static?int?flag;
int?angle?=?0;
int?pan?=?0;
void?init(){
GLfloat?mat_specular[]?=?{1.01.01.01.0};
GLfloat?mat_shininess[]?=?{50.0};
GLfloat?light_position[]?=?{2.02.02.00.0};
GLfloat?withe_ligth[]?=?{1.01.01.01.0};
GLfloat?lmode_ambient[]?=?{0.10.10.11.0};
glClearColor(0.00.00.00.0);
glShadeModel(GL_SMOOTH);
//? glMaterialfv(GL_FRONTGL_SPECULARmat_specular);
//? glMaterialfv(GL_FRONTGL_SHININESSmat_shininess);
glLightfv(GL_LIGHT0GL_POSITIONlight_position);
glLightfv(GL_LIGHT0GL_DIFFUSEwithe_ligth);
glLightfv(GL_LIGHT0GL_SPECULARwithe_ligth);
glLightModelfv(GL_LIGHT_MODEL_AMBIENTlmode_ambient);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
flag?=?GL3DS_initialize_bicycle();
}
void?dispaly(){
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
/*glutSolidSphere(1.03016);*/
glPushMatrix();
glScalef(0.10.10.1);
glCallList(flag);
glPopMatrix();
glFlush();
}
void?reshape(int?wint?h){
//? if?(w>h)
//? glViewport(00(GLsizei)h(GLsizei)h);
//? else?
//? glViewport(00(GLsizei)w(GLsizei)w);
glViewport(00(GLsizei)w(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if?(w<=h)
{
glOrtho(-1.51.5-1.5*(GLfloat)h/(GLfloat)w1.5*(GLfloat)h/(GLfloat)w-10.010.0);
}
else
glOrtho(-1.5*(GLfloat)h/(GLfloat)w1.5*(GLfloat)h/(GLfloat)w-1.51.5-10.010.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
//空閑處理函數
void?myIdle()
{
angle?=+?20;
if?(angle>=360)
angle?=?angle-360;
pan?=+?5;
glutPostRedisplay();
}
//處理鍵盤事件
void?keyboard(unsigned?char?keyint?x?int?y)
{
switch(key){
case?‘s‘:
glutIdleFunc(myIdle);
break;
case?27:
exit(0);
default:
break;
}
}
int?main(int?argcchar**argv)
{
glutInit(&argcargv);
glutInitDisplayMode(GLUT_SINGLE?|?GLUT_RGB);
glutInitWindowSize(900900);
glutInitWindowPosition(100100);
glutCreateWindow(argv[0]);
init();
glutDisplayFunc(dispaly);
glutKeyboardFunc(keyboard);
glutReshapeFunc(reshape);
//glutIdleFunc(myIdle);
glutMainLoop();
return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2321??2012-11-10?11:31??opengl編寫的自行車\code\bicycle\bicycle\3Dcar.cpp
?????文件??????12413??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\bicycle.cpp
?????文件??????87296??2012-11-06?13:30??opengl編寫的自行車\code\bicycle\bicycle\bicycle.gl
?????文件??????73767??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\bicycle.h
?????文件???????4559??2012-11-10?14:17??opengl編寫的自行車\code\bicycle\bicycle\bicycle.vcproj
?????文件???????1409??2012-11-19?22:48??opengl編寫的自行車\code\bicycle\bicycle\bicycle.vcproj.RAO-PC.liu.user
?????文件???????5833??2012-11-23?10:13??opengl編寫的自行車\code\bicycle\bicycle\bicycle.vcxproj
?????文件???????1387??2012-11-23?10:13??opengl編寫的自行車\code\bicycle\bicycle\bicycle.vcxproj.filters
?????文件????????143??2012-11-23?10:13??opengl編寫的自行車\code\bicycle\bicycle\bicycle.vcxproj.user
?????文件??????????1??2006-11-20?16:11??opengl編寫的自行車\code\bicycle\bicycle\ClassDiagram1.cd
?????文件????????663??2012-11-10?11:38??opengl編寫的自行車\code\bicycle\bicycle\Debug\bicycle.exe.em
?????文件????????728??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\bicycle.exe.em
?????文件????????381??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\bicycle.exe.intermediate.manifest
?????文件?????????57??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\bicycle.lastbuildstate
?????文件???????2940??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\bicycle.log
?????文件?????135821??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\bicycle.obj
?????文件????1179648??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\bicycle.pch
?????文件??????????0??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\bicycle.unsuccessfulbuild
?????文件????????204??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\bicycle_manifest.rc
?????文件???????7034??2012-11-19?22:47??opengl編寫的自行車\code\bicycle\bicycle\Debug\BuildLog.htm
?????文件???????1442??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\cl.command.1.tlog
?????文件??????21258??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\CL.read.1.tlog
?????文件????????768??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\CL.write.1.tlog
?????文件??????????2??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\li
?????文件??????????2??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\li
?????文件??????????2??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\li
?????文件??????????2??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\li
?????文件??????????2??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\li
?????文件?????????65??2012-11-19?22:47??opengl編寫的自行車\code\bicycle\bicycle\Debug\mt.dep
?????文件????????516??2012-11-23?10:30??opengl編寫的自行車\code\bicycle\bicycle\Debug\rc.command.1.tlog
............此處省略65個文件信息
評論
共有 條評論