資源簡介
17個VC++與OPENGL寫的游戲程序代碼
代碼片段和文件信息
#include?
void?Initialize();
void?MouseHandler(int?button?int?state?int?x?int?y);
void?KeyboardHandler(unsigned?char?key?int?x?int?y);
void?MainMenuHandler(int?option);
void?Animate();
void?Reshape(int?width?int?height);
void?Display();
/****************************************************************************
?main()
?Setup?GLUT?and?OpenGL?drop?into?the?event?loop
*****************************************************************************/
int?main(int?argc?char?**argv)
{
??//?Setup?the?basic?GLUT?stuff
??glutInit(&argc?argv);
??glutInitDisplayMode(GLUT_DOUBLE?|?GLUT_RGB?|?GLUT_DEPTH);
??//?Create?the?window
??glutInitWindowSize(1024?768);
??glutInitWindowPosition(100?150);
??glutCreateWindow(“BOGLGP?Chapter?1“);
??Initialize();
??//?Register?the?event?callback?functions
??glutDisplayFunc(Display);?
??glutReshapeFunc(Reshape);
??glutMouseFunc(MouseHandler);
??glutKeyboardFunc(KeyboardHandler);
??glutIdleFunc(Animate);
??//?At?this?point?control?is?relinquished?to?the?GLUT?event?handler.
??//?Control?is?returned?as?events?occur?via?the?callback?functions.
??glutMainLoop();???
???
??return?0;
}?//?end?main()
/****************************************************************************
?Initialize()
?One?time?setup?including?creating?menus?creating?a?light?setting?the
?shading?mode?and?clear?color?and?loading?textures.
*****************************************************************************/
void?Initialize()
{
??//?set?up?the?only?meny
??int?mainMenu;
??mainMenu?=?glutCreateMenu(MainMenuHandler);
??glutSetMenu(mainMenu);
??glutAddMenuEntry(“Exit“?0);
??glutAttachMenu(GLUT_RIGHT_BUTTON);
??glEnable(GL_DEPTH_TEST);
}?//?end?Initialize()
/****************************************************************************
?MouseHandler()
?
?Handle?mouse?events.?For?this?simple?demo?just?exit?on?a?left?click.
*****************************************************************************/
void?MouseHandler(int?button?int?state?int?x?int?y)
{
??switch?(button)
??{
??case?GLUT_LEFT_BUTTON:
????{
??????exit(0);
????}?break;
??default:
????break;
??}
??//?force?a?screen?redraw
??glutPostRedisplay();
}?//?end?MouseHandler()
/****************************************************************************
?KeyboardHandler()
?Keyboard?handler.?Again?we‘ll?just?exit?when?q?is?pressed.
*****************************************************************************/
void?KeyboardHandler(unsigned?char?key?int?x?int?y)
{
??switch?(key)
??{
??case?‘q‘:??//?exit
????{
??????exit(0);
????}?break;
??default:
????{
????}?break;
??}
??glutPostRedisplay();
}?//?end?KeyboardHandler()
/****************************************************************************
?MainMenuHandler()
?Main?menu?callback.
*****************************************************************************/
void?MainMenuHandler(int?option)
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????27670??2004-02-09?15:02??OPENGL?游戲\Chapter01\Simple\glut.h
?????文件?????237568??2004-02-09?15:02??OPENGL?游戲\Chapter01\Simple\glut32.dll
?????文件??????28728??2004-02-09?15:02??OPENGL?游戲\Chapter01\Simple\glut32.lib
?????文件???????5123??2004-02-09?15:02??OPENGL?游戲\Chapter01\Simple\Simple.cpp
?????文件???????4434??2004-02-09?15:03??OPENGL?游戲\Chapter01\Simple\Simple.dsp
?????文件????????535??2004-02-09?15:03??OPENGL?游戲\Chapter01\Simple\Simple.dsw
?????文件??????45056??2004-02-09?15:03??OPENGL?游戲\Chapter01\Simple\Simple.exe
?????文件????????901??2004-02-09?15:03??OPENGL?游戲\Chapter01\Simple\Simple.sln
?????文件???????4414??2004-02-09?15:03??OPENGL?游戲\Chapter01\Simple\Simple.vcproj
?????文件???????1982??2004-01-29?12:49??OPENGL?游戲\Chapter02\OpenGLApplication\CGfxOpenGL.cpp
?????文件????????406??2004-01-29?12:49??OPENGL?游戲\Chapter02\OpenGLApplication\CGfxOpenGL.h
?????文件???????4274??2004-02-04?11:46??OPENGL?游戲\Chapter02\OpenGLApplication\OpenGLApplication.dsp
?????文件????????557??2004-02-04?11:46??OPENGL?游戲\Chapter02\OpenGLApplication\OpenGLApplication.dsw
?????文件??????45056??2004-02-10?09:58??OPENGL?游戲\Chapter02\OpenGLApplication\OpenGLApplication.exe
?????文件????????923??2004-01-29?12:49??OPENGL?游戲\Chapter02\OpenGLApplication\OpenGLApplication.sln
?????文件???????3646??2004-01-29?12:49??OPENGL?游戲\Chapter02\OpenGLApplication\OpenGLApplication.vcproj
?????文件???????8542??2004-01-29?12:49??OPENGL?游戲\Chapter02\OpenGLApplication\winmain.cpp
?????文件???????2325??2004-02-04?11:52??OPENGL?游戲\Chapter03\Lines\CGfxOpenGL.cpp
?????文件????????469??2004-01-10?14:12??OPENGL?游戲\Chapter03\Lines\CGfxOpenGL.h
?????文件???????4142??2004-02-04?11:52??OPENGL?游戲\Chapter03\Lines\Lines.dsp
?????文件????????533??2004-02-04?11:52??OPENGL?游戲\Chapter03\Lines\Lines.dsw
?????文件??????45056??2004-02-10?09:59??OPENGL?游戲\Chapter03\Lines\Lines.exe
?????文件????????899??2004-01-10?14:12??OPENGL?游戲\Chapter03\Lines\Lines.sln
?????文件???????3598??2004-01-10?14:12??OPENGL?游戲\Chapter03\Lines\Lines.vcproj
?????文件???????6662??2004-01-10?14:12??OPENGL?游戲\Chapter03\Lines\winmain.cpp
?????文件???????1988??2004-02-04?11:54??OPENGL?游戲\Chapter03\OnYourOwn1\CGfxOpenGL.cpp
?????文件????????469??2004-01-10?14:12??OPENGL?游戲\Chapter03\OnYourOwn1\CGfxOpenGL.h
?????文件???????6703??2004-01-10?14:12??OPENGL?游戲\Chapter03\OnYourOwn1\OnYourOwn1.cpp
?????文件???????4200??2004-02-04?11:53??OPENGL?游戲\Chapter03\OnYourOwn1\OnYourOwn1.dsp
?????文件????????543??2004-02-04?11:53??OPENGL?游戲\Chapter03\OnYourOwn1\OnYourOwn1.dsw
............此處省略648個文件信息
評論
共有 條評論