Back to index

supertuxkart  0.5+dfsg1
GLDebugDrawer.cpp
Go to the documentation of this file.
00001 
00002 #include "GLDebugDrawer.h"
00003 #include "LinearMath/btPoint3.h"
00004 
00005 #ifdef WIN32 //needed for glut.h
00006 #include <windows.h>
00007 #endif
00008 
00009 //think different
00010 #if defined(__APPLE__) && !defined (VMDMESA)
00011 #include <OpenGL/gl.h>
00012 #include <OpenGL/glu.h>
00013 #include <GLUT/glut.h>
00014 #else
00015 #include <GL/glut.h>
00016 #endif
00017 
00018 #include "BMF_Api.h"
00019 #include <stdio.h> //printf debugging
00020 GLDebugDrawer::GLDebugDrawer()
00021 :m_debugMode(0)
00022 {
00023 
00024 }
00025 void   GLDebugDrawer::drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
00026 {
00027 //     if (m_debugMode > 0)
00028        {
00029               glBegin(GL_LINES);
00030               glColor3f(color.getX(), color.getY(), color.getZ());
00031               glVertex3d(from.getX(), from.getY(), from.getZ());
00032               glVertex3d(to.getX(), to.getY(), to.getZ());
00033               glEnd();
00034        }
00035 }
00036 
00037 void   GLDebugDrawer::setDebugMode(int debugMode)
00038 {
00039        m_debugMode = debugMode;
00040 
00041 }
00042 
00043 void   GLDebugDrawer::draw3dText(const btVector3& location,const char* textString)
00044 {
00045        glRasterPos3f(location.x(),  location.y(),  location.z());
00046        BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),textString);
00047 }
00048 
00049 void   GLDebugDrawer::reportErrorWarning(const char* warningString)
00050 {
00051        printf(warningString);
00052 }
00053 
00054 void   GLDebugDrawer::drawContactPoint(const btVector3& pointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color)
00055 {
00056        if (m_debugMode & btIDebugDraw::DBG_DrawContactPoints)
00057        {
00058               btVector3 to=pointOnB+normalOnB*distance;
00059               const btVector3&from = pointOnB;
00060               glBegin(GL_LINES);
00061               glColor3f(color.getX(), color.getY(), color.getZ());
00062               glVertex3d(from.getX(), from.getY(), from.getZ());
00063               glVertex3d(to.getX(), to.getY(), to.getZ());
00064               glEnd();
00065 
00066 
00067               glRasterPos3f(from.x(),  from.y(),  from.z());
00068               char buf[12];
00069               sprintf(buf," %d",lifeTime);
00070               BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
00071 
00072 
00073        }
00074 }
00075 
00076 
00077 
00078