Made glut optional (if it's installed it is used and optional

bullet debug via the --bullet-debug command line option can be used, 
otherwise this command line option is not available).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2926 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2009-01-15 04:08:41 +00:00
parent d9db33a3a0
commit 0b5bee042e
7 changed files with 68 additions and 21 deletions

View File

@ -284,21 +284,45 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
CXXFLAGS="$ORIGCXXFLAGS"
AC_SUBST(NOREGMOVE)
dnl ==============================================
dnl Glut (optional), used by bullet debugging only
dnl ==============================================
save_LIBS=$LIBS
save_LDFLAGS=$LDFLAGS
save_CXXFLAGS=$CXXFLAGS
case "${host}" in
*darwin*|*macosx*)
dnl Apparently -framework is needed for include files and libraries
CXXFLAGS="$CXXFLAGS -framework GLUT"
LDFLAGS="$LDFLAGS -framework GLUT"
esac
AC_SEARCH_LIBS(glutInit, [glut], have_glut_lib=yes)
if test x$have_glut_lib = xyes; then
# Apple has the headers in GLUT/glut.h instead of GL/glut.h
AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h], have_glut_hdr=yes)
fi
if test x$have_glut_hdr = xyes; then
AC_DEFINE(HAVE_GLUT)
SUMMARY="$SUMMARY\nGlut found, enabling optional bullet debug"
else
SUMMARY="$SUMMARY\nNo glut found, disabling bullet debug"
dnl Remove the unnecessary -framework GLUT on Macs (no impact
dnl of this on any other platforms)
CXXFLAGS=$save_CSSFLAGS
LDFLAGS=$save_LDFLAGS
fi
glut_LIBS="$LIBS"
LIBS=$save_LIBS
dnl ==============
dnl Bullet physics
dnl ==============
AC_DEFINE([BT_NO_PROFILE], [], [Disable bullet internal profiling])
SUMMARY="$SUMMARY\nUsing bullet physics."
BULLETTREE="src/bullet"
bullet_LIBS="-Lbullet/Demos/OpenGL -lbulletopenglsupport -Lbullet/src -lbulletdynamics -lbulletcollision -lbulletmath"
case "${host}" in
*darwin*|*macosx*)
bullet_LIBS="-Lbullet/Demos/OpenGL -lbulletopenglsupport -Lbullet/src -lbulletdynamics -lbulletcollision -lbulletmath -framework GLUT"
;;
*)
bullet_LIBS="-Lbullet/Demos/OpenGL -lbulletopenglsupport -Lbullet/src -lbulletdynamics -lbulletcollision -lbulletmath -lglut"
;;
esac
dnl ====
dnl enet
@ -356,6 +380,7 @@ AC_SUBST(enet_LIBS)
AC_SUBST(opengl_LIBS)
AC_SUBST(openal_LIBS)
AC_SUBST(oggvorbis_LIBS)
AC_SUBST(glut_LIBS)
AC_SUBST(sdl_LIBS)
AC_SUBST(BULLETTREE)
AC_SUBST(ENETTREE)

View File

@ -295,9 +295,10 @@ libstatic_ssg_a_CXXFLAGS = $(NOREGMOVE)
# Link in the specific gcc 4.1 bug work around
supertuxkart_LDADD = libstatic_ssg.a \
-lplibjs -lplibsl -lplibssg -lplibpu -lplibfnt -lplibsg \
-lplibul -lplibssgaux $(bullet_LIBS) $(enet_LIBS) $(opengl_LIBS) \
$(sdl_LIBS) $(openal_LIBS) $(oggvorbis_LIBS) $(INTLLIBS)
-lplibjs -lplibsl -lplibssg -lplibpu -lplibfnt -lplibsg \
-lplibul -lplibssgaux $(bullet_LIBS) $(enet_LIBS) $(glut_LIBS) \
$(opengl_LIBS) $(sdl_LIBS) $(openal_LIBS) $(oggvorbis_LIBS) \
$(INTLLIBS)
EXTRA_DIST = robots/empty_robot.cpp robots/empty_robot.hpp

View File

@ -12,7 +12,7 @@ subject to the following restrictions:
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifdef HAVE_GLUT
#ifdef WIN32 //needed for glut.h
#include <windows.h>
#endif
@ -680,3 +680,4 @@ GL_ShapeDrawer::~GL_ShapeDrawer()
m_shapeHulls.clear();
}
#endif

View File

@ -74,10 +74,12 @@
#include "network/network_manager.hpp"
// Only needed for bullet debug!
#ifdef __APPLE__
# include <GLUT/glut.h>
#else
# include <GL/glut.h>
#ifdef HAVE_GLUT
# ifdef __APPLE__
# include <GLUT/glut.h>
# else
# include <GL/glut.h>
# endif
#endif
void cmdLineHelp (char* invocation)
@ -154,10 +156,12 @@ int handleCmdLine(int argc, char **argv)
{
user_config->m_track_debug=1;
}
#ifdef HAVE_GLUT
else if(!strcmp(argv[i], "--bullet-debug"))
{
user_config->m_bullet_debug=1;
}
#endif
else if(!strcmp(argv[i], "--kartsize-debug"))
{
user_config->m_print_kart_sizes=true;
@ -507,7 +511,10 @@ void CleanTuxKart()
int main(int argc, char *argv[] )
{
try {
#ifdef HAVE_GLUT
// only needed for bullet debugging.
glutInit(&argc, argv);
#endif
InitTuxkart();
//handleCmdLine() needs InitTuxkart() so it can't be called first

View File

@ -48,17 +48,22 @@ void Physics::init(const Vec3 &world_min, const Vec3 &world_max)
m_collision_conf);
m_dynamics_world->setGravity(btVector3(0.0f, 0.0f,
-RaceManager::getTrack()->getGravity()));
#ifdef HAVE_GLUT
if(user_config->m_bullet_debug)
{
{
m_debug_drawer=new GLDebugDrawer();
m_debug_drawer->setDebugMode(btIDebugDraw::DBG_DrawWireframe);
m_dynamics_world->setDebugDrawer(m_debug_drawer);
}
#endif
} // init
//-----------------------------------------------------------------------------
Physics::~Physics()
{
#ifdef HAVE_GLUT
if(user_config->m_bullet_debug) delete m_debug_drawer;
#endif
delete m_dynamics_world;
delete m_axis_sweep;
delete m_dispatcher;
@ -318,9 +323,11 @@ void Physics::draw()
void Physics::debugDraw(float m[16], btCollisionShape *s, const btVector3 color)
{
#ifdef HAVE_GLUT
m_shape_drawer.drawOpenGL(m, s, color, 0);
// btIDebugDraw::DBG_DrawWireframe);
// btIDebugDraw::DBG_DrawAabb);
#endif
} // debugDraw
// -----------------------------------------------------------------------------

View File

@ -39,8 +39,10 @@ class Physics : public btSequentialImpulseConstraintSolver
private:
btDynamicsWorld *m_dynamics_world;
Kart *m_kart;
#ifdef HAVE_GLUT
GLDebugDrawer *m_debug_drawer;
GL_ShapeDrawer m_shape_drawer;
#endif
btCollisionDispatcher *m_dispatcher;
btBroadphaseInterface *m_axis_sweep;
btDefaultCollisionConfiguration *m_collision_conf;

View File

@ -26,10 +26,12 @@
#include "user_config.hpp"
#include "btBulletDynamicsCommon.h"
#ifdef __APPLE__
# include <GLUT/glut.h>
#else
# include <GL/glut.h>
#ifdef HAVE_GLUT
# ifdef __APPLE__
# include <GLUT/glut.h>
# else
# include <GL/glut.h>
# endif
#endif
#include "scene.hpp"
@ -143,6 +145,7 @@ void Scene::draw(float dt)
//if(!user_config->m_profile)ssgCullAndDraw ( m_scenegraph );
ssgCullAndDraw ( m_scenegraph );
}
#ifdef HAVE_GLUT
else
{
// Use bullets debug drawer
@ -191,6 +194,7 @@ void Scene::draw(float dt)
}
RaceManager::getWorld()->getPhysics()->draw();
} // bullet_debug
#endif
} // for cameras
if (TRACK->useFog())