diff --git a/SimDynamics/DynamicsEngine/BulletEngine/BulletOpenGLViewer.h b/SimDynamics/DynamicsEngine/BulletEngine/BulletOpenGLViewer.h index 40670a851438bcc3858da71cfa05fca8c0a1580d..6422a74afc31d824afe494f5b060bad51b9e665f 100644 --- a/SimDynamics/DynamicsEngine/BulletEngine/BulletOpenGLViewer.h +++ b/SimDynamics/DynamicsEngine/BulletEngine/BulletOpenGLViewer.h @@ -28,13 +28,13 @@ #include "../../DynamicsWorld.h" #include "BulletEngine.h" -/*#ifdef _WINDOWS +#ifdef _WINDOWS #include <Win32DemoApplication.h> #define PlatformDemoApplication Win32DemoApplication -#else*/ +#else #include <GlutDemoApplication.h> #define PlatformDemoApplication GlutDemoApplication -//#endif +#endif #include <btBulletDynamicsCommon.h> #include <GlutStuff.h> diff --git a/SimDynamics/examples/BulletDebugViewerGlut/BulletDebugViewerGlut.cpp b/SimDynamics/examples/BulletDebugViewerGlut/BulletDebugViewerGlut.cpp index fb49af7f436a63c1f244f3b838c2a718346d9aee..8f79efc8c152aad54a191c6dd8d7f7a268ce8d05 100644 --- a/SimDynamics/examples/BulletDebugViewerGlut/BulletDebugViewerGlut.cpp +++ b/SimDynamics/examples/BulletDebugViewerGlut/BulletDebugViewerGlut.cpp @@ -12,6 +12,117 @@ using namespace std; using namespace VirtualRobot; using namespace SimDynamics; + +#ifdef WIN32 + +#include <GL/gl.h> +#include <GL/glut.h> +#include "DemoApplication.h" + +//glut is C code, this global gDemoApplication links glut to the C++ demo +static DemoApplication* gDemoApplication = 0; + + +#include "GlutStuff.h" + +static void glutKeyboardCallback(unsigned char key, int x, int y) +{ + gDemoApplication->keyboardCallback(key, x, y); +} + +static void glutKeyboardUpCallback(unsigned char key, int x, int y) +{ + gDemoApplication->keyboardUpCallback(key, x, y); +} + +static void glutSpecialKeyboardCallback(int key, int x, int y) +{ + gDemoApplication->specialKeyboard(key, x, y); +} + +static void glutSpecialKeyboardUpCallback(int key, int x, int y) +{ + gDemoApplication->specialKeyboardUp(key, x, y); +} + + +static void glutReshapeCallback(int w, int h) +{ + gDemoApplication->reshape(w, h); +} + +static void glutMoveAndDisplayCallback() +{ + gDemoApplication->moveAndDisplay(); +} + +static void glutMouseFuncCallback(int button, int state, int x, int y) +{ + gDemoApplication->mouseFunc(button, state, x, y); +} + + +static void glutMotionFuncCallback(int x, int y) +{ + gDemoApplication->mouseMotionFunc(x, y); +} + + +static void glutDisplayCallback(void) +{ + gDemoApplication->displayCallback(); +} + + +int glutmain(int argc, char **argv, int width, int height, const char* title, DemoApplication* demoApp) { + + gDemoApplication = demoApp; + + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL); + glutInitWindowPosition(width / 2, height / 2); + glutInitWindowSize(width, height); + glutCreateWindow(title); +#ifdef BT_USE_FREEGLUT + glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); +#endif + + gDemoApplication->myinit(); + + glutKeyboardFunc(glutKeyboardCallback); + glutKeyboardUpFunc(glutKeyboardUpCallback); + glutSpecialFunc(glutSpecialKeyboardCallback); + glutSpecialUpFunc(glutSpecialKeyboardUpCallback); + + glutReshapeFunc(glutReshapeCallback); + //createMenu(); + glutIdleFunc(glutMoveAndDisplayCallback); + glutMouseFunc(glutMouseFuncCallback); + glutPassiveMotionFunc(glutMotionFuncCallback); + glutMotionFunc(glutMotionFuncCallback); + glutDisplayFunc(glutDisplayCallback); + + glutMoveAndDisplayCallback(); + + //enable vsync to avoid tearing on Apple (todo: for Windows) + +#if defined(__APPLE__) && !defined (VMDMESA) + int swap_interval = 1; + CGLContextObj cgl_context = CGLGetCurrentContext(); + CGLSetParameter(cgl_context, kCGLCPSwapInterval, &swap_interval); +#endif + + + + glutMainLoop(); + return 0; +} +#endif + + + + + int main(int argc,char* argv[]) { VirtualRobot::RuntimeEnvironment::considerKey("robot"); diff --git a/SimDynamics/examples/BulletDebugViewerGlut/CMakeLists.txt b/SimDynamics/examples/BulletDebugViewerGlut/CMakeLists.txt index af5f49be2d9a3616ee16640cc11820a82aaafd75..58bcc8bbe0e7541bdaad2c89cff558142983a64c 100644 --- a/SimDynamics/examples/BulletDebugViewerGlut/CMakeLists.txt +++ b/SimDynamics/examples/BulletDebugViewerGlut/CMakeLists.txt @@ -6,6 +6,8 @@ CMAKE_POLICY(VERSION 2.6) INCLUDE(${Simox_DIR}/CMakeModules/SimoxMacros.cmake) +include_directories(${GLUT_INCLUDE_DIR}) +#message("GLUT_INCLUDE_DIR:${GLUT_INCLUDE_DIR}") # create the executable SimoxApplication(${PROJECT_NAME} "BulletDebugViewerGlut.cpp" "") TARGET_LINK_LIBRARIES(${PROJECT_NAME} SimDynamics)