add preliminary glut replacement test for Bullet 2.x demos

This commit is contained in:
Erwin Coumans
2014-07-03 16:42:50 -07:00
parent 87d44cbb74
commit bae303c5da
12 changed files with 416 additions and 37 deletions

View File

@@ -14,6 +14,7 @@ subject to the following restrictions:
*/
#include "DemoApplication.h"
#include "LinearMath/btIDebugDraw.h"
#include "BulletDynamics/Dynamics/btDynamicsWorld.h"
@@ -112,6 +113,8 @@ DemoApplication::~DemoApplication()
if (m_shapeDrawer)
delete m_shapeDrawer;
//GLDebugResetFont(0,0);
}

View File

@@ -112,6 +112,12 @@ public:
virtual ~DemoApplication();
void setDynamicsWorld(btDynamicsWorld* world)
{
m_dynamicsWorld=world;
}
btDynamicsWorld* getDynamicsWorld()
{
return m_dynamicsWorld;

View File

@@ -41,7 +41,7 @@ subject to the following restrictions:
#include <GL/glu.h>
#else
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glu.h>
#endif
#endif
@@ -59,6 +59,19 @@ static int sScreenHeight = -1;
void GLDebugResetFont(int screenWidth,int screenHeight)
{
if (screenWidth==0 && screenHeight==0)
{
sScreenWidth = screenWidth;
sScreenHeight = screenHeight;
if (sTexturesInitialized)
{
glDeleteTextures(1, &sTexture);
glBindTexture(GL_TEXTURE_2D,0);
sTexturesInitialized = false;
}
return;
}
if ((sScreenWidth == screenWidth) && (sScreenHeight == screenHeight))
return;

View File

@@ -13,7 +13,7 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef _WINDOWS
#ifndef DONT_USE_GLUT
#include "DemoApplication.h"
@@ -71,6 +71,7 @@ static void glutDisplayCallback(void)
gDemoApplication->displayCallback();
}
#include <GL/glut.h>
int glutmain(int argc, char **argv,int width,int height,const char* title,DemoApplication* demoApp) {
@@ -117,4 +118,4 @@ CGLSetParameter(cgl_context, kCGLCPSwapInterval, &swap_interval);
}
#endif //_WINDOWS
#endif //DONT_USE_GLUT

View File

@@ -15,51 +15,68 @@ subject to the following restrictions:
#ifndef GLUT_STUFF_H
#define GLUT_STUFF_H
#ifdef DONT_USE_GLUT
#ifdef _WIN32//for glut.h
#include <windows.h>
#endif
#endif //DONT_USE_GLUT
//think different
#if defined(__APPLE__) && !defined (VMDMESA)
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#else
#ifndef DONT_USE_GLUT
#include <GLUT/glut.h>
#endif//DONT_USE_GLUT
#else//(__APPLE__) && !defined (VMDMESA)
#ifdef _WINDOWS
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#else
#include <GL/gl.h>
#include <GL/glut.h>
#endif //_WINDOWS
#endif //APPLE
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#define BT_ACTIVE_ALT VK_LMENU
#define BT_ACTIVE_SHIFT VK_LSHIFT
#define BT_ACTIVE_CTRL VK_LCONTROL
#else //_WINDOWS
#ifdef DONT_USE_GLUT
#include <GL/gl.h>
#include <GL/glu.h>
#define BT_ACTIVE_ALT 8192
#define BT_ACTIVE_SHIFT 8193
#define BT_ACTIVE_CTRL 8194
#else//DONT_USE_GLUT
#ifdef _WIN32
#include <windows.h>
#endif//_WIN32
#include <GL/gl.h>
#include <GL/glut.h>
#define BT_KEY_K 'k'
#define BT_KEY_LEFT GLUT_KEY_LEFT
#define BT_KEY_RIGHT GLUT_KEY_RIGHT
#define BT_KEY_UP GLUT_KEY_UP
#define BT_KEY_DOWN GLUT_KEY_DOWN
#define BT_KEY_F1 GLUT_KEY_F1
#define BT_KEY_F2 GLUT_KEY_F2
#define BT_KEY_F3 GLUT_KEY_F3
#define BT_KEY_F4 GLUT_KEY_F4
#define BT_KEY_F5 GLUT_KEY_F5
#define BT_KEY_PAGEUP GLUT_KEY_PAGE_UP
#define BT_KEY_PAGEDOWN GLUT_KEY_PAGE_DOWN
#define BT_KEY_END GLUT_KEY_END
#define BT_KEY_HOME GLUT_KEY_HOME
#define BT_ACTIVE_ALT GLUT_ACTIVE_ALT
#define BT_ACTIVE_CTRL GLUT_ACTIVE_ALT
#define BT_ACTIVE_SHIFT GLUT_ACTIVE_SHIFT
#endif//DONT_USE_GLUT
#endif//_WINDOWS
#endif //(__APPLE__) && !defined (VMDMESA)
#ifdef _WINDOWS
#define BT_ACTIVE_ALT VK_LMENU
#define BT_ACTIVE_SHIFT VK_LSHIFT
#else
#define BT_KEY_K 'k'
#define BT_KEY_LEFT GLUT_KEY_LEFT
#define BT_KEY_RIGHT GLUT_KEY_RIGHT
#define BT_KEY_UP GLUT_KEY_UP
#define BT_KEY_DOWN GLUT_KEY_DOWN
#define BT_KEY_F1 GLUT_KEY_F1
#define BT_KEY_F2 GLUT_KEY_F2
#define BT_KEY_F3 GLUT_KEY_F3
#define BT_KEY_F4 GLUT_KEY_F4
#define BT_KEY_F5 GLUT_KEY_F5
#define BT_KEY_PAGEUP GLUT_KEY_PAGE_UP
#define BT_KEY_PAGEDOWN GLUT_KEY_PAGE_DOWN
#define BT_KEY_END GLUT_KEY_END
#define BT_KEY_HOME GLUT_KEY_HOME
#define BT_ACTIVE_ALT GLUT_ACTIVE_ALT
#define BT_ACTIVE_CTRL GLUT_ACTIVE_ALT
#define BT_ACTIVE_SHIFT GLUT_ACTIVE_SHIFT
#endif
#if BT_USE_FREEGLUT
#include "GL/freeglut_ext.h" //to be able to return from glutMainLoop()

View File

@@ -36,6 +36,11 @@ public:
///rgba input is in range [0..1] for each component
inline void setPixel(int x,int y,const btVector4& rgba)
{
btAssert(x>=0);
btAssert(y>=0);
btAssert(x<m_width);
btAssert(x<m_height);
unsigned char* pixel = &m_buffer[ (x+y*m_width) * 4];
pixel[0] = (unsigned char)(255.*rgba.getX());