source: proiecte/SIMEO/SimeoDemo/GlutStuff.cpp @ 168

Last change on this file since 168 was 168, checked in by (none), 14 years ago

Simeo: added initial proof of concept code.

File size: 3.0 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16
17#include "DemoApplication.h"
18
19//glut is C code, this global gDemoApplication links glut to the C++ demo
20static DemoApplication* gDemoApplication = 0;
21
22
23#include "GlutStuff.h"
24
25static  void glutKeyboardCallback(unsigned char key, int x, int y)
26{
27        gDemoApplication->keyboardCallback(key,x,y);
28}
29
30static  void glutKeyboardUpCallback(unsigned char key, int x, int y)
31{
32  gDemoApplication->keyboardUpCallback(key,x,y);
33}
34
35static void glutSpecialKeyboardCallback(int key, int x, int y)
36{
37        gDemoApplication->specialKeyboard(key,x,y);
38}
39
40static void glutSpecialKeyboardUpCallback(int key, int x, int y)
41{
42        gDemoApplication->specialKeyboardUp(key,x,y);
43}
44
45
46static void glutReshapeCallback(int w, int h)
47{
48        gDemoApplication->reshape(w,h);
49}
50
51static void glutMoveAndDisplayCallback()
52{
53        gDemoApplication->moveAndDisplay();
54}
55
56static void glutMouseFuncCallback(int button, int state, int x, int y)
57{
58        gDemoApplication->mouseFunc(button,state,x,y);
59}
60
61
62static void     glutMotionFuncCallback(int x,int y)
63{
64        gDemoApplication->mouseMotionFunc(x,y);
65}
66
67
68static void glutDisplayCallback(void)
69{
70        gDemoApplication->displayCallback();
71}
72
73
74int glutmain(int argc, char **argv,int width,int height,const char* title,DemoApplication* demoApp) {
75   
76        gDemoApplication = demoApp;
77
78        glutInit(&argc, argv);
79    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
80    glutInitWindowPosition(0, 0);
81    glutInitWindowSize(width, height);
82    glutCreateWindow(title);
83#ifdef BT_USE_FREEGLUT
84        glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
85#endif
86
87    gDemoApplication->myinit();
88
89        glutKeyboardFunc(glutKeyboardCallback);
90        glutKeyboardUpFunc(glutKeyboardUpCallback);
91        glutSpecialFunc(glutSpecialKeyboardCallback);
92        glutSpecialUpFunc(glutSpecialKeyboardUpCallback);
93
94        glutReshapeFunc(glutReshapeCallback);
95    //createMenu();
96        glutIdleFunc(glutMoveAndDisplayCallback);
97        glutMouseFunc(glutMouseFuncCallback);
98        glutMotionFunc(glutMotionFuncCallback);
99        glutDisplayFunc( glutDisplayCallback );
100
101        glutMoveAndDisplayCallback();
102       
103    glutMainLoop();
104    return 0;
105}
106
107
Note: See TracBrowser for help on using the repository browser.