资源简介

从.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.embed.manifest

     文件        728  2012-11-23 10:30  opengl编写的自行车\code\bicycle\bicycle\Debug\bicycle.exe.embed.manifest.res

     文件        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\link-cvtres.read.1.tlog

     文件          2  2012-11-23 10:30  opengl编写的自行车\code\bicycle\bicycle\Debug\link-cvtres.write.1.tlog

     文件          2  2012-11-23 10:30  opengl编写的自行车\code\bicycle\bicycle\Debug\link.command.1.tlog

     文件          2  2012-11-23 10:30  opengl编写的自行车\code\bicycle\bicycle\Debug\link.read.1.tlog

     文件          2  2012-11-23 10:30  opengl编写的自行车\code\bicycle\bicycle\Debug\link.write.1.tlog

     文件         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个文件信息

评论

共有 条评论