Don't use GLUT by default under Windows, but a Win32 App instead. All demos have to be fixed (only basic demo works now). Also on Mac OSX, we plan to use cocoa instead of Glut.

This commit is contained in:
erwin.coumans
2010-01-19 22:59:49 +00:00
parent 5d3ba1daa6
commit 7b41af1765
13 changed files with 161 additions and 75 deletions

View File

@@ -8,8 +8,18 @@ IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Release") SET(CMAKE_BUILD_TYPE "Release")
ENDIF (NOT CMAKE_BUILD_TYPE) ENDIF (NOT CMAKE_BUILD_TYPE)
# string (REPLACE "/D_WINDOWS" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
remove_definitions(-D_WINDOWS )
IF (WIN32)
OPTION(USE_GLUT "Use Glut" OFF)
ELSE(WIN32)
OPTION(USE_GLUT "Use Glut" ON)
ENDIF(WIN32)
IF (USE_GLUT)
string (REPLACE "/D_WINDOWS" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
remove_definitions(-D_WINDOWS )
ENDIF (USE_GLUT)
IF(COMMAND cmake_policy) IF(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW) cmake_policy(SET CMP0003 NEW)
@@ -33,31 +43,32 @@ ENDIF (OPENGL_FOUND)
FIND_PACKAGE(GLU) FIND_PACKAGE(GLU)
FIND_PACKAGE(GLUT) IF (USE_GLUT)
IF (GLUT_FOUND) FIND_PACKAGE(GLUT)
MESSAGE("GLUT FOUND") IF (GLUT_FOUND)
MESSAGE(${GLUT_glut_LIBRARY}) MESSAGE("GLUT FOUND")
ELSE (GLUT_FOUND) MESSAGE(${GLUT_glut_LIBRARY})
ELSE (GLUT_FOUND)
IF (MINGW) IF (MINGW)
MESSAGE ("GLUT NOT FOUND not found, trying to use MINGW glut32") MESSAGE ("GLUT NOT FOUND not found, trying to use MINGW glut32")
SET(GLUT_glut_LIBRARY glut32) SET(GLUT_glut_LIBRARY glut32)
ENDIF (MINGW) ENDIF (MINGW)
IF (MSVC) IF (MSVC)
MESSAGE ("GLUT NOT FOUND, trying to use Bullet/Glut/glut32.lib for MSVC") MESSAGE ("GLUT NOT FOUND, trying to use Bullet/Glut/glut32.lib for MSVC")
SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/Glut/glut32.lib) SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/Glut/glut32.lib)
ENDIF (MSVC) ENDIF (MSVC)
ENDIF (GLUT_FOUND) ENDIF (GLUT_FOUND)
IF (WIN32)
INCLUDE_DIRECTORIES(${BULLET_PHYSICS_SOURCE_DIR}/Glut)
ELSE (WIN32)
# This is the lines for linux. This should always work if everything is installed and working fine.
INCLUDE_DIRECTORIES(/usr/include /usr/local/include ${GLUT_INCLUDE_DIR})
ENDIF (WIN32)
IF (WIN32) ENDIF(USE_GLUT)
INCLUDE_DIRECTORIES(${BULLET_PHYSICS_SOURCE_DIR}/Glut)
ELSE (WIN32)
# This is the lines for linux. This should always work if everything is installed and working fine.
INCLUDE_DIRECTORIES(/usr/include /usr/local/include ${GLUT_INCLUDE_DIR})
ENDIF (WIN32)
OPTION(BUILD_DEMOS "Set when you want to build the demos" ON) OPTION(BUILD_DEMOS "Set when you want to build the demos" ON)
IF(BUILD_DEMOS) IF(BUILD_DEMOS)

View File

@@ -14,6 +14,7 @@ subject to the following restrictions:
*/ */
///create 125 (5x5x5) dynamic object ///create 125 (5x5x5) dynamic object
#define ARRAY_SIZE_X 5 #define ARRAY_SIZE_X 5
#define ARRAY_SIZE_Y 5 #define ARRAY_SIZE_Y 5
@@ -54,7 +55,7 @@ void BasicDemo::clientMoveAndDisplay()
glFlush(); glFlush();
glutSwapBuffers(); swapBuffers();
} }
@@ -71,7 +72,7 @@ void BasicDemo::displayCallback(void) {
m_dynamicsWorld->debugDrawWorld(); m_dynamicsWorld->debugDrawWorld();
glFlush(); glFlush();
glutSwapBuffers(); swapBuffers();
} }

View File

@@ -15,7 +15,14 @@ subject to the following restrictions:
#ifndef BASIC_DEMO_H #ifndef BASIC_DEMO_H
#define BASIC_DEMO_H #define BASIC_DEMO_H
#ifdef _WINDOWS
#include "Win32DemoApplication.h"
#define PlatformDemoApplication Win32DemoApplication
#else
#include "GlutDemoApplication.h" #include "GlutDemoApplication.h"
#define PlatformDemoApplication GlutDemoApplication
#endif
#include "LinearMath/btAlignedObjectArray.h" #include "LinearMath/btAlignedObjectArray.h"
class btBroadphaseInterface; class btBroadphaseInterface;
@@ -27,7 +34,8 @@ struct btCollisionAlgorithmCreateFunc;
class btDefaultCollisionConfiguration; class btDefaultCollisionConfiguration;
///BasicDemo is good starting point for learning the code base and porting. ///BasicDemo is good starting point for learning the code base and porting.
class BasicDemo : public GlutDemoApplication
class BasicDemo : public PlatformDemoApplication
{ {
//keep the collision shapes, for deletion/cleanup //keep the collision shapes, for deletion/cleanup

View File

@@ -15,12 +15,29 @@ INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL ${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
) )
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppBasicDemo
main.cpp
BasicDemo.cpp
)
IF (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppBasicDemo
main.cpp
BasicDemo.cpp
BasicDemo.h
)
ELSE (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppBasicDemo
WIN32
../OpenGL/Win32AppMain.cpp
Win32BasicDemo.cpp
BasicDemo.cpp
BasicDemo.h
)
ENDIF (USE_GLUT)

View File

@@ -1,20 +1,25 @@
if (CMAKE_SIZEOF_VOID_P MATCHES "8") SUBDIRS( OpenGL BasicDemo )
SUBDIRS( OpenGL AllBulletDemos ConvexDecompositionDemo Benchmarks HelloWorld
CcdPhysicsDemo ConstraintDemo SliderConstraintDemo GenericJointDemo Raytracer
RagdollDemo ForkLiftDemo BasicDemo Box2dDemo BspDemo MovingConcaveDemo VehicleDemo #todo: re-enable the rest of the demos again
ColladaDemo UserCollisionAlgorithm CharacterDemo SoftDemo HeightFieldFluidDemo
CollisionInterfaceDemo ConcaveConvexcastDemo SimplexDemo DynamicControlDemo #if (CMAKE_SIZEOF_VOID_P MATCHES "8")
DoublePrecisionDemo ConcaveDemo CollisionDemo # SUBDIRS( OpenGL AllBulletDemos ConvexDecompositionDemo Benchmarks HelloWorld
ContinuousConvexCollision ConcaveRaycastDemo GjkConvexCastDemo # CcdPhysicsDemo ConstraintDemo SliderConstraintDemo GenericJointDemo Raytracer
MultiMaterialDemo) # RagdollDemo ForkLiftDemo BasicDemo Box2dDemo BspDemo MovingConcaveDemo VehicleDemo
else (CMAKE_SIZEOF_VOID_P MATCHES "8") # ColladaDemo UserCollisionAlgorithm CharacterDemo SoftDemo HeightFieldFluidDemo
SUBDIRS( OpenGL AllBulletDemos ConvexDecompositionDemo Benchmarks HelloWorld # CollisionInterfaceDemo ConcaveConvexcastDemo SimplexDemo DynamicControlDemo
MultiThreadedDemo CcdPhysicsDemo ConstraintDemo SliderConstraintDemo Raytracer # DoublePrecisionDemo ConcaveDemo CollisionDemo
GenericJointDemo RagdollDemo ForkLiftDemo BasicDemo Box2dDemo BspDemo MovingConcaveDemo # ContinuousConvexCollision ConcaveRaycastDemo GjkConvexCastDemo
VehicleDemo ColladaDemo UserCollisionAlgorithm CharacterDemo SoftDemo # MultiMaterialDemo)
HeightFieldFluidDemo #else (CMAKE_SIZEOF_VOID_P MATCHES "8")
CollisionInterfaceDemo ConcaveConvexcastDemo SimplexDemo DynamicControlDemo # SUBDIRS( OpenGL AllBulletDemos ConvexDecompositionDemo Benchmarks HelloWorld
DoublePrecisionDemo ConcaveDemo CollisionDemo # MultiThreadedDemo CcdPhysicsDemo ConstraintDemo SliderConstraintDemo Raytracer
ContinuousConvexCollision ConcaveRaycastDemo GjkConvexCastDemo # GenericJointDemo RagdollDemo ForkLiftDemo BasicDemo Box2dDemo BspDemo MovingConcaveDemo
MultiMaterialDemo) # VehicleDemo ColladaDemo UserCollisionAlgorithm CharacterDemo SoftDemo
endif (CMAKE_SIZEOF_VOID_P MATCHES "8") # HeightFieldFluidDemo
# CollisionInterfaceDemo ConcaveConvexcastDemo SimplexDemo DynamicControlDemo
# DoublePrecisionDemo ConcaveDemo CollisionDemo
# ContinuousConvexCollision ConcaveRaycastDemo GjkConvexCastDemo
# MultiMaterialDemo)
#endif (CMAKE_SIZEOF_VOID_P MATCHES "8")

View File

@@ -12,24 +12,41 @@
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Extras/ConvexHull ${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Extras/ConvexHull
) )
ADD_LIBRARY(OpenGLSupport ADD_LIBRARY(OpenGLSupport
GLDebugFont.cpp GLDebugFont.cpp
GLDebugFont.h
GL_DialogDynamicsWorld.cpp GL_DialogDynamicsWorld.cpp
GL_DialogDynamicsWorld.h
GL_DialogWindow.cpp GL_DialogWindow.cpp
GL_DialogWindow.h
GL_ShapeDrawer.cpp GL_ShapeDrawer.cpp
GL_ShapeDrawer.h
GL_Simplex1to4.cpp GL_Simplex1to4.cpp
GL_Simplex1to4.h
GLDebugDrawer.cpp GLDebugDrawer.cpp
GlutStuff.cpp GLDebugDrawer.h
RenderTexture.cpp RenderTexture.cpp
RenderTexture.h
DemoApplication.cpp DemoApplication.cpp
DemoApplication.h
GlutDemoApplication.cpp GlutDemoApplication.cpp
GlutDemoApplication.h
GlutStuff.cpp
GlutStuff.h
Win32DemoApplication.cpp
Win32DemoApplication.h
) )
IF (BUILD_SHARED_LIBS) IF (BUILD_SHARED_LIBS)
TARGET_LINK_LIBRARIES(OpenGLSupport BulletDynamics BulletCollision ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}) TARGET_LINK_LIBRARIES(OpenGLSupport BulletDynamics BulletCollision ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY})
ENDIF (BUILD_SHARED_LIBS) ENDIF (BUILD_SHARED_LIBS)

View File

@@ -24,14 +24,7 @@ void GLDebugDrawer::drawLine(const btVector3& from,const btVector3& to,const btV
void GLDebugDrawer::drawLine(const btVector3& from,const btVector3& to,const btVector3& color) void GLDebugDrawer::drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
{ {
// if (m_debugMode > 0) drawLine(from,to,color,color);
{
glBegin(GL_LINES);
glColor4f(color.getX(), color.getY(), color.getZ(),1.f);
glVertex3d(from.getX(), from.getY(), from.getZ());
glVertex3d(to.getX(), to.getY(), to.getZ());
glEnd();
}
} }
void GLDebugDrawer::drawSphere (const btVector3& p, btScalar radius, const btVector3& color) void GLDebugDrawer::drawSphere (const btVector3& p, btScalar radius, const btVector3& color)

View File

@@ -33,11 +33,14 @@ subject to the following restrictions:
#endif #endif
#else #else
#include <GL/glut.h>
#ifdef _WINDOWS #ifdef _WINDOWS
#include <windows.h> #include <windows.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#else
#include <GL/glut.h>
#endif #endif
#endif #endif

View File

@@ -32,11 +32,13 @@ class btCollisionObject;
#endif #endif
#else #else
#include <GL/glut.h>
#ifdef _WINDOWS #ifdef _WINDOWS
#include <windows.h> #include <windows.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#else
#include <GL/glut.h>
#endif #endif
#endif #endif

View File

@@ -1,4 +1,5 @@
#ifndef _WINDOWS
#include "GlutDemoApplication.h" #include "GlutDemoApplication.h"
@@ -81,5 +82,6 @@ void GlutDemoApplication::swapBuffers()
} }
#endif //_WINDOWS

View File

@@ -13,6 +13,7 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#ifndef _WINDOWS
#include "DemoApplication.h" #include "DemoApplication.h"
@@ -106,3 +107,4 @@ int glutmain(int argc, char **argv,int width,int height,const char* title,DemoAp
} }
#endif //_WINDOWS

View File

@@ -26,13 +26,15 @@ subject to the following restrictions:
#include <GLUT/glut.h> #include <GLUT/glut.h>
#else #else
#include <GL/glut.h>
#ifdef _WINDOWS #ifdef _WINDOWS
#include <windows.h> #include <windows.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#endif #define BT_ACTIVE_ALT VK_LMENU
#endif #else
#include <GL/glut.h>
#define BT_KEY_K 'k' #define BT_KEY_K 'k'
@@ -53,7 +55,8 @@ subject to the following restrictions:
#define BT_ACTIVE_CTRL GLUT_ACTIVE_ALT #define BT_ACTIVE_CTRL GLUT_ACTIVE_ALT
#define BT_ACTIVE_SHIFT GLUT_ACTIVE_SHIFT #define BT_ACTIVE_SHIFT GLUT_ACTIVE_SHIFT
#endif
#endif
#if BT_USE_FREEGLUT #if BT_USE_FREEGLUT
#include "GL/freeglut_ext.h" //to be able to return from glutMainLoop() #include "GL/freeglut_ext.h" //to be able to return from glutMainLoop()

View File

@@ -37,8 +37,10 @@ DemoApplication* createDemo();
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC); void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC);
void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC); void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC);
static bool sOpenGLInitialized = false;
static int sWidth = 0;
static int sHeight =0;
static int quitRequest = 0;
// WinMain // WinMain
@@ -181,11 +183,21 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return 0; // Return return 0; // Return
case SIZE_MAXIMIZED: // Was Window Maximized? case SIZE_MAXIMIZED: // Was Window Maximized?
gDemoApplication->reshape(LOWORD (lParam), HIWORD (lParam)); sWidth = LOWORD (lParam);
sHeight = HIWORD (lParam);
if (sOpenGLInitialized)
{
gDemoApplication->reshape(sWidth,sHeight);
}
return 0; // Return return 0; // Return
case SIZE_RESTORED: // Was Window Restored? case SIZE_RESTORED: // Was Window Restored?
gDemoApplication->reshape(LOWORD (lParam), HIWORD (lParam)); sWidth = LOWORD (lParam);
sHeight = HIWORD (lParam);
if (sOpenGLInitialized)
{
gDemoApplication->reshape(sWidth,sHeight);
}
return 0; // Return return 0; // Return
} }
break; break;
@@ -297,8 +309,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
case WM_KEYDOWN: case WM_KEYDOWN:
printf("bla\n");
switch ( wParam ) switch ( wParam )
{ {
case VK_CONTROL:
case VK_PRIOR: case VK_PRIOR:
case VK_NEXT: case VK_NEXT:
case VK_END: case VK_END:
@@ -321,14 +335,18 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
case 'Q': case 'Q':
case VK_ESCAPE: case VK_ESCAPE:
PostQuitMessage(0); {
quitRequest = 1;
PostQuitMessage(0);
}
return 0; return 0;
} }
return 0; return 0;
case WM_CHAR: case WM_CHAR:
gDemoApplication->keyboardCallback(wParam,0,0); if (!quitRequest)
gDemoApplication->keyboardCallback(wParam,0,0);
break; break;
default: default:
@@ -364,6 +382,8 @@ void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC)
// create and enable the render context (RC) // create and enable the render context (RC)
*hRC = wglCreateContext( *hDC ); *hRC = wglCreateContext( *hDC );
wglMakeCurrent( *hDC, *hRC ); wglMakeCurrent( *hDC, *hRC );
sOpenGLInitialized = true;
gDemoApplication->reshape(sWidth,sHeight);
} }
@@ -371,6 +391,8 @@ void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC)
void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC) void DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC)
{ {
sOpenGLInitialized = false;
wglMakeCurrent( NULL, NULL ); wglMakeCurrent( NULL, NULL );
wglDeleteContext( hRC ); wglDeleteContext( hRC );
ReleaseDC( hWnd, hDC ); ReleaseDC( hWnd, hDC );