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:
@@ -8,8 +8,18 @@ IF (NOT CMAKE_BUILD_TYPE)
|
||||
SET(CMAKE_BUILD_TYPE "Release")
|
||||
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)
|
||||
cmake_policy(SET CMP0003 NEW)
|
||||
@@ -33,31 +43,32 @@ ENDIF (OPENGL_FOUND)
|
||||
|
||||
FIND_PACKAGE(GLU)
|
||||
|
||||
FIND_PACKAGE(GLUT)
|
||||
IF (GLUT_FOUND)
|
||||
MESSAGE("GLUT FOUND")
|
||||
MESSAGE(${GLUT_glut_LIBRARY})
|
||||
ELSE (GLUT_FOUND)
|
||||
IF (USE_GLUT)
|
||||
FIND_PACKAGE(GLUT)
|
||||
IF (GLUT_FOUND)
|
||||
MESSAGE("GLUT FOUND")
|
||||
MESSAGE(${GLUT_glut_LIBRARY})
|
||||
ELSE (GLUT_FOUND)
|
||||
|
||||
IF (MINGW)
|
||||
MESSAGE ("GLUT NOT FOUND not found, trying to use MINGW glut32")
|
||||
SET(GLUT_glut_LIBRARY glut32)
|
||||
ENDIF (MINGW)
|
||||
IF (MINGW)
|
||||
MESSAGE ("GLUT NOT FOUND not found, trying to use MINGW glut32")
|
||||
SET(GLUT_glut_LIBRARY glut32)
|
||||
ENDIF (MINGW)
|
||||
|
||||
IF (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)
|
||||
ENDIF (MSVC)
|
||||
ENDIF (GLUT_FOUND)
|
||||
IF (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)
|
||||
ENDIF (MSVC)
|
||||
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)
|
||||
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)
|
||||
|
||||
ENDIF(USE_GLUT)
|
||||
|
||||
OPTION(BUILD_DEMOS "Set when you want to build the demos" ON)
|
||||
IF(BUILD_DEMOS)
|
||||
|
||||
@@ -14,6 +14,7 @@ subject to the following restrictions:
|
||||
*/
|
||||
|
||||
|
||||
|
||||
///create 125 (5x5x5) dynamic object
|
||||
#define ARRAY_SIZE_X 5
|
||||
#define ARRAY_SIZE_Y 5
|
||||
@@ -54,7 +55,7 @@ void BasicDemo::clientMoveAndDisplay()
|
||||
|
||||
glFlush();
|
||||
|
||||
glutSwapBuffers();
|
||||
swapBuffers();
|
||||
|
||||
}
|
||||
|
||||
@@ -71,7 +72,7 @@ void BasicDemo::displayCallback(void) {
|
||||
m_dynamicsWorld->debugDrawWorld();
|
||||
|
||||
glFlush();
|
||||
glutSwapBuffers();
|
||||
swapBuffers();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,14 @@ subject to the following restrictions:
|
||||
#ifndef BASIC_DEMO_H
|
||||
#define BASIC_DEMO_H
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include "Win32DemoApplication.h"
|
||||
#define PlatformDemoApplication Win32DemoApplication
|
||||
#else
|
||||
#include "GlutDemoApplication.h"
|
||||
#define PlatformDemoApplication GlutDemoApplication
|
||||
#endif
|
||||
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
|
||||
class btBroadphaseInterface;
|
||||
@@ -27,7 +34,8 @@ struct btCollisionAlgorithmCreateFunc;
|
||||
class btDefaultCollisionConfiguration;
|
||||
|
||||
///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
|
||||
|
||||
@@ -15,12 +15,29 @@ INCLUDE_DIRECTORIES(
|
||||
${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)
|
||||
@@ -1,20 +1,25 @@
|
||||
if (CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||
SUBDIRS( OpenGL AllBulletDemos ConvexDecompositionDemo Benchmarks HelloWorld
|
||||
CcdPhysicsDemo ConstraintDemo SliderConstraintDemo GenericJointDemo Raytracer
|
||||
RagdollDemo ForkLiftDemo BasicDemo Box2dDemo BspDemo MovingConcaveDemo VehicleDemo
|
||||
ColladaDemo UserCollisionAlgorithm CharacterDemo SoftDemo HeightFieldFluidDemo
|
||||
CollisionInterfaceDemo ConcaveConvexcastDemo SimplexDemo DynamicControlDemo
|
||||
DoublePrecisionDemo ConcaveDemo CollisionDemo
|
||||
ContinuousConvexCollision ConcaveRaycastDemo GjkConvexCastDemo
|
||||
MultiMaterialDemo)
|
||||
else (CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||
SUBDIRS( OpenGL AllBulletDemos ConvexDecompositionDemo Benchmarks HelloWorld
|
||||
MultiThreadedDemo CcdPhysicsDemo ConstraintDemo SliderConstraintDemo Raytracer
|
||||
GenericJointDemo RagdollDemo ForkLiftDemo BasicDemo Box2dDemo BspDemo MovingConcaveDemo
|
||||
VehicleDemo ColladaDemo UserCollisionAlgorithm CharacterDemo SoftDemo
|
||||
HeightFieldFluidDemo
|
||||
CollisionInterfaceDemo ConcaveConvexcastDemo SimplexDemo DynamicControlDemo
|
||||
DoublePrecisionDemo ConcaveDemo CollisionDemo
|
||||
ContinuousConvexCollision ConcaveRaycastDemo GjkConvexCastDemo
|
||||
MultiMaterialDemo)
|
||||
endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||
SUBDIRS( OpenGL BasicDemo )
|
||||
|
||||
|
||||
#todo: re-enable the rest of the demos again
|
||||
|
||||
#if (CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||
# SUBDIRS( OpenGL AllBulletDemos ConvexDecompositionDemo Benchmarks HelloWorld
|
||||
# CcdPhysicsDemo ConstraintDemo SliderConstraintDemo GenericJointDemo Raytracer
|
||||
# RagdollDemo ForkLiftDemo BasicDemo Box2dDemo BspDemo MovingConcaveDemo VehicleDemo
|
||||
# ColladaDemo UserCollisionAlgorithm CharacterDemo SoftDemo HeightFieldFluidDemo
|
||||
# CollisionInterfaceDemo ConcaveConvexcastDemo SimplexDemo DynamicControlDemo
|
||||
# DoublePrecisionDemo ConcaveDemo CollisionDemo
|
||||
# ContinuousConvexCollision ConcaveRaycastDemo GjkConvexCastDemo
|
||||
# MultiMaterialDemo)
|
||||
#else (CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||
# SUBDIRS( OpenGL AllBulletDemos ConvexDecompositionDemo Benchmarks HelloWorld
|
||||
# MultiThreadedDemo CcdPhysicsDemo ConstraintDemo SliderConstraintDemo Raytracer
|
||||
# GenericJointDemo RagdollDemo ForkLiftDemo BasicDemo Box2dDemo BspDemo MovingConcaveDemo
|
||||
# VehicleDemo ColladaDemo UserCollisionAlgorithm CharacterDemo SoftDemo
|
||||
# HeightFieldFluidDemo
|
||||
# CollisionInterfaceDemo ConcaveConvexcastDemo SimplexDemo DynamicControlDemo
|
||||
# DoublePrecisionDemo ConcaveDemo CollisionDemo
|
||||
# ContinuousConvexCollision ConcaveRaycastDemo GjkConvexCastDemo
|
||||
# MultiMaterialDemo)
|
||||
#endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||
|
||||
@@ -12,24 +12,41 @@
|
||||
|
||||
|
||||
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Extras/ConvexHull
|
||||
)
|
||||
|
||||
|
||||
ADD_LIBRARY(OpenGLSupport
|
||||
GLDebugFont.cpp
|
||||
GLDebugFont.h
|
||||
GL_DialogDynamicsWorld.cpp
|
||||
GL_DialogDynamicsWorld.h
|
||||
GL_DialogWindow.cpp
|
||||
GL_DialogWindow.h
|
||||
GL_ShapeDrawer.cpp
|
||||
GL_ShapeDrawer.h
|
||||
GL_Simplex1to4.cpp
|
||||
GL_Simplex1to4.h
|
||||
GLDebugDrawer.cpp
|
||||
GlutStuff.cpp
|
||||
GLDebugDrawer.h
|
||||
|
||||
RenderTexture.cpp
|
||||
RenderTexture.h
|
||||
DemoApplication.cpp
|
||||
DemoApplication.h
|
||||
|
||||
GlutDemoApplication.cpp
|
||||
GlutDemoApplication.h
|
||||
GlutStuff.cpp
|
||||
GlutStuff.h
|
||||
|
||||
|
||||
Win32DemoApplication.cpp
|
||||
Win32DemoApplication.h
|
||||
)
|
||||
|
||||
|
||||
IF (BUILD_SHARED_LIBS)
|
||||
TARGET_LINK_LIBRARIES(OpenGLSupport BulletDynamics BulletCollision ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY})
|
||||
ENDIF (BUILD_SHARED_LIBS)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
// if (m_debugMode > 0)
|
||||
{
|
||||
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();
|
||||
}
|
||||
drawLine(from,to,color,color);
|
||||
}
|
||||
|
||||
void GLDebugDrawer::drawSphere (const btVector3& p, btScalar radius, const btVector3& color)
|
||||
|
||||
@@ -33,11 +33,14 @@ subject to the following restrictions:
|
||||
#endif
|
||||
#else
|
||||
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -32,11 +32,13 @@ class btCollisionObject;
|
||||
#endif
|
||||
#else
|
||||
|
||||
#include <GL/glut.h>
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
#ifndef _WINDOWS
|
||||
|
||||
#include "GlutDemoApplication.h"
|
||||
|
||||
@@ -81,5 +82,6 @@ void GlutDemoApplication::swapBuffers()
|
||||
|
||||
}
|
||||
|
||||
#endif //_WINDOWS
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#ifndef _WINDOWS
|
||||
|
||||
#include "DemoApplication.h"
|
||||
|
||||
@@ -106,3 +107,4 @@ int glutmain(int argc, char **argv,int width,int height,const char* title,DemoAp
|
||||
}
|
||||
|
||||
|
||||
#endif //_WINDOWS
|
||||
|
||||
@@ -26,13 +26,15 @@ subject to the following restrictions:
|
||||
#include <GLUT/glut.h>
|
||||
#else
|
||||
|
||||
#include <GL/glut.h>
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
#endif
|
||||
#define BT_ACTIVE_ALT VK_LMENU
|
||||
#else
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
#define BT_KEY_K 'k'
|
||||
@@ -53,7 +55,8 @@ subject to the following restrictions:
|
||||
#define BT_ACTIVE_CTRL GLUT_ACTIVE_ALT
|
||||
#define BT_ACTIVE_SHIFT GLUT_ACTIVE_SHIFT
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BT_USE_FREEGLUT
|
||||
#include "GL/freeglut_ext.h" //to be able to return from glutMainLoop()
|
||||
|
||||
@@ -37,8 +37,10 @@ DemoApplication* createDemo();
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
void EnableOpenGL(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
|
||||
|
||||
@@ -181,11 +183,21 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
return 0; // Return
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
}
|
||||
break;
|
||||
@@ -297,8 +309,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
|
||||
case WM_KEYDOWN:
|
||||
printf("bla\n");
|
||||
switch ( wParam )
|
||||
{
|
||||
case VK_CONTROL:
|
||||
case VK_PRIOR:
|
||||
case VK_NEXT:
|
||||
case VK_END:
|
||||
@@ -321,14 +335,18 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
case 'Q':
|
||||
case VK_ESCAPE:
|
||||
PostQuitMessage(0);
|
||||
{
|
||||
quitRequest = 1;
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_CHAR:
|
||||
gDemoApplication->keyboardCallback(wParam,0,0);
|
||||
if (!quitRequest)
|
||||
gDemoApplication->keyboardCallback(wParam,0,0);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -364,6 +382,8 @@ void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC)
|
||||
// create and enable the render context (RC)
|
||||
*hRC = wglCreateContext( *hDC );
|
||||
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)
|
||||
{
|
||||
sOpenGLInitialized = false;
|
||||
|
||||
wglMakeCurrent( NULL, NULL );
|
||||
wglDeleteContext( hRC );
|
||||
ReleaseDC( hWnd, hDC );
|
||||
|
||||
Reference in New Issue
Block a user