Back to index

supertuxkart  0.5+dfsg1
GlutStuff.cpp
Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 */
00015 
00016 
00017 #include "DemoApplication.h"
00018 
00019 //glut is C code, this global gDemoApplication links glut to the C++ demo
00020 static DemoApplication* gDemoApplication = 0;
00021 
00022 
00023 #include "GlutStuff.h"
00024 
00025 static void glutKeyboardCallback(unsigned char key, int x, int y)
00026 {
00027        gDemoApplication->keyboardCallback(key,x,y);
00028 }
00029 
00030 static void glutSpecialKeyboardCallback(int key, int x, int y)
00031 {
00032        gDemoApplication->specialKeyboard(key,x,y);
00033 }
00034 
00035 static void glutSpecialKeyboardUpCallback(int key, int x, int y)
00036 {
00037        gDemoApplication->specialKeyboardUp(key,x,y);
00038 }
00039 
00040 
00041 static void glutReshapeCallback(int w, int h)
00042 {
00043        gDemoApplication->reshape(w,h);
00044 }
00045 
00046 static void glutMoveAndDisplayCallback()
00047 {
00048        gDemoApplication->moveAndDisplay();
00049 }
00050 
00051 static void glutMouseFuncCallback(int button, int state, int x, int y)
00052 {
00053        gDemoApplication->mouseFunc(button,state,x,y);
00054 }
00055 
00056 
00057 static void   glutMotionFuncCallback(int x,int y)
00058 {
00059        gDemoApplication->mouseMotionFunc(x,y);
00060 }
00061 
00062 
00063 static void glutDisplayCallback(void)
00064 {
00065        gDemoApplication->displayCallback();
00066 }
00067 
00068 
00069 int glutmain(int argc, char **argv,int width,int height,const char* title,DemoApplication* demoApp) {
00070     
00071        gDemoApplication = demoApp;
00072 
00073        glutInit(&argc, argv);
00074     glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
00075     glutInitWindowPosition(0, 0);
00076     glutInitWindowSize(width, height);
00077     glutCreateWindow(title);
00078 #ifdef BT_USE_FREEGLUT
00079        glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
00080 #endif
00081 
00082     gDemoApplication->myinit();
00083 
00084        glutKeyboardFunc(glutKeyboardCallback);
00085        glutSpecialFunc(glutSpecialKeyboardCallback);
00086        glutSpecialUpFunc(glutSpecialKeyboardUpCallback);
00087 
00088        glutReshapeFunc(glutReshapeCallback);
00089     //createMenu();
00090        glutIdleFunc(glutMoveAndDisplayCallback);
00091        glutMouseFunc(glutMouseFuncCallback);
00092        glutMotionFunc(glutMotionFuncCallback);
00093        glutDisplayFunc( glutDisplayCallback );
00094 
00095        glutMoveAndDisplayCallback();
00096        
00097     glutMainLoop();
00098     return 0;
00099 }