refactor to allow various gfx backends (work-in-progress)
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
void BasicDemoPhysicsSetup::initPhysics(GraphicsPhysicsBridge& gfxBridge)
|
||||
{
|
||||
createEmptyDynamicsWorld();
|
||||
|
||||
gfxBridge.createPhysicsDebugDrawer(m_dynamicsWorld);
|
||||
m_dynamicsWorld->getDebugDrawer()->setDebugMode(btIDebugDraw::DBG_DrawWireframe+btIDebugDraw::DBG_DrawContactPoints);
|
||||
|
||||
///create a few basic rigid bodies
|
||||
btBoxShape* groundShape = createBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
|
||||
|
||||
@@ -21,51 +21,51 @@
|
||||
#include "../../Demos/SerializeDemo/SerializeSetup.h"
|
||||
#include "../bullet2/MultiBodyDemo/TestJointTorqueSetup.h"
|
||||
|
||||
static BulletDemoInterface* TestJointTorqueCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* TestJointTorqueCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
CommonPhysicsSetup* physicsSetup = new TestJointTorqueSetup();
|
||||
return new BasicDemo(app, physicsSetup);
|
||||
}
|
||||
|
||||
static BulletDemoInterface* LuaDemoCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* LuaDemoCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
CommonPhysicsSetup* physicsSetup = new LuaPhysicsSetup(app);
|
||||
return new BasicDemo(app, physicsSetup);
|
||||
}
|
||||
|
||||
static BulletDemoInterface* MyCcdPhysicsDemoCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* MyCcdPhysicsDemoCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
CommonPhysicsSetup* physicsSetup = new CcdPhysicsSetup();
|
||||
return new BasicDemo(app, physicsSetup);
|
||||
}
|
||||
|
||||
static BulletDemoInterface* MyKinematicObjectCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* MyKinematicObjectCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
CommonPhysicsSetup* physicsSetup = new KinematicObjectSetup();
|
||||
return new BasicDemo(app, physicsSetup);
|
||||
}
|
||||
static BulletDemoInterface* MySerializeCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* MySerializeCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
CommonPhysicsSetup* physicsSetup = new SerializeSetup();
|
||||
return new BasicDemo(app, physicsSetup);
|
||||
}
|
||||
static BulletDemoInterface* MyConstraintCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* MyConstraintCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
CommonPhysicsSetup* physicsSetup = new ConstraintPhysicsSetup();
|
||||
return new BasicDemo(app, physicsSetup);
|
||||
}
|
||||
|
||||
static BulletDemoInterface* MyImportUrdfCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* MyImportUrdfCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
CommonPhysicsSetup* physicsSetup = new ImportUrdfDemo();
|
||||
return new BasicDemo(app, physicsSetup);
|
||||
}
|
||||
static BulletDemoInterface* MyImportObjCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* MyImportObjCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
CommonPhysicsSetup* physicsSetup = new ImportObjDemo(app);
|
||||
return new BasicDemo(app, physicsSetup);
|
||||
}
|
||||
static BulletDemoInterface* MyImportSTLCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* MyImportSTLCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
CommonPhysicsSetup* physicsSetup = new ImportSTLDemo(app);
|
||||
return new BasicDemo(app, physicsSetup);
|
||||
|
||||
@@ -1,5 +1,28 @@
|
||||
//#include "OpenGLWindow/OpenGLInclude.h"
|
||||
//#include "OpenGL/gl.h"
|
||||
#define USE_OPENGL2
|
||||
#ifdef USE_OPENGL2
|
||||
#include "OpenGLWindow/SimpleOpenGL2App.h"
|
||||
#else
|
||||
|
||||
#include "OpenGLWindow/SimpleOpenGL3App.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "OpenGLWindow/MacOpenGLWindow.h"
|
||||
#else
|
||||
|
||||
#include "GL/glew.h"
|
||||
#ifdef _WIN32
|
||||
#include "OpenGLWindow/Win32OpenGLWindow.h"
|
||||
#else
|
||||
//let's cross the fingers it is Linux/X11
|
||||
#include "OpenGLWindow/X11OpenGLWindow.h"
|
||||
#endif //_WIN32
|
||||
#endif//__APPLE__
|
||||
#include "Gwen/Renderers/OpenGL_DebugFont.h"
|
||||
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
#include "assert.h"
|
||||
#include <stdio.h>
|
||||
@@ -11,11 +34,172 @@
|
||||
#include "Bullet3AppSupport/GwenProfileWindow.h"
|
||||
#include "Bullet3AppSupport/GwenTextureWindow.h"
|
||||
#include "Bullet3AppSupport/GraphingTexture.h"
|
||||
#include "OpenGLWindow/CommonRenderInterface.h"
|
||||
#include "OpenGLWindow/SimpleCamera.h"
|
||||
|
||||
CommonGraphicsApp* app=0;
|
||||
|
||||
struct TestRenderer : public CommonRenderInterface
|
||||
{
|
||||
int m_width;
|
||||
int m_height;
|
||||
SimpleCamera m_camera;
|
||||
|
||||
TestRenderer(int width, int height)
|
||||
:m_width(width),
|
||||
m_height(height)
|
||||
{
|
||||
|
||||
}
|
||||
virtual void init()
|
||||
{
|
||||
|
||||
}
|
||||
virtual void updateCamera(int upAxis)
|
||||
{
|
||||
float projection[16];
|
||||
float view[16];
|
||||
m_camera.setAspectRatio((float)m_width/(float)m_height);
|
||||
m_camera.update();
|
||||
m_camera.getCameraProjectionMatrix(projection);
|
||||
m_camera.getCameraViewMatrix(view);
|
||||
GLfloat projMat[16];
|
||||
GLfloat viewMat[16];
|
||||
for (int i=0;i<16;i++)
|
||||
{
|
||||
viewMat[i] = view[i];
|
||||
projMat[i] = projection[i];
|
||||
}
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glMultMatrixf(projMat);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glMultMatrixf(viewMat);
|
||||
}
|
||||
virtual void removeAllInstances()
|
||||
{
|
||||
}
|
||||
virtual void setCameraDistance(float dist)
|
||||
{
|
||||
m_camera.setCameraDistance(dist);
|
||||
}
|
||||
virtual void setCameraPitch(float pitch)
|
||||
{
|
||||
m_camera.setCameraPitch(pitch);
|
||||
}
|
||||
virtual void setCameraTargetPosition(float x, float y, float z)
|
||||
{
|
||||
m_camera.setCameraTargetPosition(x,y,z);
|
||||
}
|
||||
|
||||
virtual void getCameraPosition(float cameraPos[4])
|
||||
{
|
||||
float pos[3];
|
||||
m_camera.getCameraPosition(pos);
|
||||
cameraPos[0] = pos[0];
|
||||
cameraPos[1] = pos[1];
|
||||
cameraPos[2] = pos[2];
|
||||
|
||||
}
|
||||
virtual void getCameraPosition(double cameraPos[4])
|
||||
{
|
||||
float pos[3];
|
||||
m_camera.getCameraPosition(pos);
|
||||
cameraPos[0] = pos[0];
|
||||
cameraPos[1] = pos[1];
|
||||
cameraPos[2] = pos[2];
|
||||
}
|
||||
|
||||
virtual void setCameraTargetPosition(float cameraPos[4])
|
||||
{
|
||||
m_camera.setCameraTargetPosition(cameraPos[0],cameraPos[1],cameraPos[2]);
|
||||
}
|
||||
virtual void getCameraTargetPosition(float cameraPos[4]) const
|
||||
{
|
||||
m_camera.getCameraTargetPosition(cameraPos);
|
||||
}
|
||||
virtual void getCameraTargetPosition(double cameraPos[4]) const
|
||||
{
|
||||
cameraPos[0] = 1;
|
||||
cameraPos[1] = 1;
|
||||
cameraPos[2] = 1;
|
||||
}
|
||||
|
||||
virtual void renderScene()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual int getScreenWidth()
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
virtual int getScreenHeight()
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual void drawLines(const float* positions, const float color[4], int numPoints, int pointStrideInBytes, const unsigned int* indices, int numIndices, float pointDrawSize)
|
||||
{
|
||||
int pointStrideInFloats = pointStrideInBytes/4;
|
||||
glLineWidth(pointDrawSize);
|
||||
for (int i=0;i<numIndices;i+=2)
|
||||
{
|
||||
int index0 = indices[i];
|
||||
int index1 = indices[i+1];
|
||||
|
||||
btVector3 fromColor(color[0],color[1],color[2]);
|
||||
btVector3 toColor(color[0],color[1],color[2]);
|
||||
|
||||
btVector3 from(positions[index0*pointStrideInFloats],positions[index0*pointStrideInFloats+1],positions[index0*pointStrideInFloats+2]);
|
||||
btVector3 to(positions[index1*pointStrideInFloats],positions[index1*pointStrideInFloats+1],positions[index1*pointStrideInFloats+2]);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(fromColor.getX(), fromColor.getY(), fromColor.getZ());
|
||||
glVertex3d(from.getX(), from.getY(), from.getZ());
|
||||
glColor3f(toColor.getX(), toColor.getY(), toColor.getZ());
|
||||
glVertex3d(to.getX(), to.getY(), to.getZ());
|
||||
glEnd();
|
||||
|
||||
}
|
||||
}
|
||||
virtual void drawLine(const float from[4], const float to[4], const float color[4], float lineWidth)
|
||||
{
|
||||
glLineWidth(lineWidth);
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(color[0],color[1],color[2]);
|
||||
glVertex3d(from[0],from[1],from[2]);
|
||||
glVertex3d(to[0],to[1],to[2]);
|
||||
glEnd();
|
||||
}
|
||||
virtual int registerShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType=B3_GL_TRIANGLES, int textureIndex=-1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void writeSingleInstanceTransformToCPU(const float* position, const float* orientation, int srcIndex)
|
||||
{
|
||||
}
|
||||
virtual void writeSingleInstanceTransformToCPU(const double* position, const double* orientation, int srcIndex)
|
||||
{
|
||||
}
|
||||
virtual void writeTransforms()
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
b3gWindowInterface* s_window = 0;
|
||||
CommonParameterInterface* s_parameterInterface=0;
|
||||
CommonRenderInterface* s_instancingRenderer=0;
|
||||
#define DEMO_SELECTION_COMBOBOX 13
|
||||
const char* startFileName = "bulletDemo.txt";
|
||||
static SimpleOpenGL3App* app=0;
|
||||
|
||||
static GwenUserInterface* gui = 0;
|
||||
static int sCurrentDemoIndex = 0;
|
||||
static int sCurrentHightlighted = 0;
|
||||
@@ -30,82 +214,14 @@ int midiBaseIndex = 176;
|
||||
//#include <float.h>
|
||||
//unsigned int fp_control_state = _controlfp(_EM_INEXACT, _MCW_EM);
|
||||
|
||||
#ifdef B3_USE_MIDI
|
||||
#include "../../btgui/MidiTest/RtMidi.h"
|
||||
bool chooseMidiPort( RtMidiIn *rtmidi )
|
||||
{
|
||||
if (!rtmidi)
|
||||
return false;
|
||||
|
||||
std::string portName;
|
||||
unsigned int i = 0, nPorts = rtmidi->getPortCount();
|
||||
if ( nPorts == 0 ) {
|
||||
std::cout << "No input ports available!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( nPorts == 1 ) {
|
||||
std::cout << "\nOpening " << rtmidi->getPortName() << std::endl;
|
||||
}
|
||||
else {
|
||||
for ( i=0; i<nPorts; i++ ) {
|
||||
portName = rtmidi->getPortName(i);
|
||||
std::cout << " Input port #" << i << ": " << portName << '\n';
|
||||
}
|
||||
|
||||
do {
|
||||
std::cout << "\nChoose a port number: ";
|
||||
std::cin >> i;
|
||||
} while ( i >= nPorts );
|
||||
}
|
||||
|
||||
// std::getline( std::cin, keyHit ); // used to clear out stdin
|
||||
rtmidi->openPort( i );
|
||||
|
||||
return true;
|
||||
}
|
||||
void PairMidiCallback( double deltatime, std::vector< unsigned char > *message, void *userData )
|
||||
{
|
||||
unsigned int nBytes = message->size();
|
||||
if (nBytes==3)
|
||||
{
|
||||
//if ( message->at(1)==16)
|
||||
{
|
||||
printf("midi %d at %f = %d\n", message->at(1), deltatime, message->at(2));
|
||||
//test->SetValue(message->at(2));
|
||||
#if KORG_MIDI
|
||||
if (message->at(0)>=midiBaseIndex && message->at(0)<(midiBaseIndex+8))
|
||||
{
|
||||
int sliderIndex = message->at(0)-midiBaseIndex;//-16;
|
||||
printf("sliderIndex = %d\n", sliderIndex);
|
||||
float sliderValue = message->at(2);
|
||||
printf("sliderValue = %f\n", sliderValue);
|
||||
app->m_parameterInterface->setSliderValue(sliderIndex,sliderValue);
|
||||
}
|
||||
#else
|
||||
//ICONTROLS
|
||||
if (message->at(0)==176)
|
||||
{
|
||||
int sliderIndex = message->at(1)-32;//-16;
|
||||
printf("sliderIndex = %d\n", sliderIndex);
|
||||
float sliderValue = message->at(2);
|
||||
printf("sliderValue = %f\n", sliderValue);
|
||||
app->m_parameterInterface->setSliderValue(sliderIndex,sliderValue);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //B3_USE_MIDI
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
b3KeyboardCallback prevKeyboardCallback = 0;
|
||||
|
||||
void MyKeyboardCallback(int key, int state)
|
||||
{
|
||||
|
||||
@@ -146,15 +262,16 @@ void MyKeyboardCallback(int key, int state)
|
||||
useShadowMap=!useShadowMap;
|
||||
}
|
||||
|
||||
if (key==B3G_ESCAPE && app && app->m_window)
|
||||
if (key==B3G_ESCAPE && s_window)
|
||||
{
|
||||
app->m_window->setRequestExit();
|
||||
s_window->setRequestExit();
|
||||
}
|
||||
|
||||
b3DefaultKeyboardCallback(key,state);
|
||||
|
||||
if (prevKeyboardCallback)
|
||||
prevKeyboardCallback(key,state);
|
||||
}
|
||||
|
||||
b3MouseMoveCallback prevMouseMoveCallback = 0;
|
||||
static void MyMouseMoveCallback( float x, float y)
|
||||
{
|
||||
bool handled = false;
|
||||
@@ -163,8 +280,14 @@ static void MyMouseMoveCallback( float x, float y)
|
||||
if (!handled && gui)
|
||||
handled = gui->mouseMoveCallback(x,y);
|
||||
if (!handled)
|
||||
b3DefaultMouseMoveCallback(x,y);
|
||||
{
|
||||
if (prevMouseMoveCallback)
|
||||
prevMouseMoveCallback(x,y);
|
||||
}
|
||||
}
|
||||
|
||||
b3MouseButtonCallback prevMouseButtonCallback = 0;
|
||||
|
||||
static void MyMouseButtonCallback(int button, int state, float x, float y)
|
||||
{
|
||||
bool handled = false;
|
||||
@@ -176,7 +299,11 @@ static void MyMouseButtonCallback(int button, int state, float x, float y)
|
||||
handled = gui->mouseButtonCallback(button,state,x,y);
|
||||
|
||||
if (!handled)
|
||||
b3DefaultMouseButtonCallback(button,state,x,y);
|
||||
{
|
||||
if (prevMouseButtonCallback )
|
||||
prevMouseButtonCallback (button,state,x,y);
|
||||
}
|
||||
// b3DefaultMouseButtonCallback(button,state,x,y);
|
||||
}
|
||||
|
||||
#include <string.h>
|
||||
@@ -187,17 +314,17 @@ void openURDFDemo(const char* filename)
|
||||
if (sCurrentDemo)
|
||||
{
|
||||
sCurrentDemo->exitPhysics();
|
||||
app->m_instancingRenderer->removeAllInstances();
|
||||
s_instancingRenderer->removeAllInstances();
|
||||
delete sCurrentDemo;
|
||||
sCurrentDemo=0;
|
||||
}
|
||||
|
||||
app->m_parameterInterface->removeAllParameters();
|
||||
s_parameterInterface->removeAllParameters();
|
||||
|
||||
ImportUrdfDemo* physicsSetup = new ImportUrdfDemo();
|
||||
physicsSetup->setFileName(filename);
|
||||
|
||||
sCurrentDemo = new BasicDemo(app, physicsSetup);
|
||||
sCurrentDemo = new BasicDemo(0, physicsSetup);
|
||||
|
||||
if (sCurrentDemo)
|
||||
{
|
||||
@@ -219,13 +346,13 @@ void selectDemo(int demoIndex)
|
||||
if (sCurrentDemo)
|
||||
{
|
||||
sCurrentDemo->exitPhysics();
|
||||
app->m_instancingRenderer->removeAllInstances();
|
||||
s_instancingRenderer->removeAllInstances();
|
||||
delete sCurrentDemo;
|
||||
sCurrentDemo=0;
|
||||
}
|
||||
if (allDemos[demoIndex].m_createFunc && app)
|
||||
if (allDemos[demoIndex].m_createFunc)
|
||||
{
|
||||
app->m_parameterInterface->removeAllParameters();
|
||||
s_parameterInterface->removeAllParameters();
|
||||
sCurrentDemo = (*allDemos[demoIndex].m_createFunc)(app);
|
||||
if (sCurrentDemo)
|
||||
{
|
||||
@@ -359,7 +486,7 @@ void fileOpenCallback()
|
||||
{
|
||||
|
||||
char filename[1024];
|
||||
int len = app->m_window->fileOpenDialog(filename,1024);
|
||||
int len = s_window->fileOpenDialog(filename,1024);
|
||||
if (len)
|
||||
{
|
||||
//todo(erwincoumans) check if it is actually URDF
|
||||
@@ -379,31 +506,66 @@ int main(int argc, char* argv[])
|
||||
int width = 1024;
|
||||
int height=768;
|
||||
|
||||
|
||||
app = new SimpleOpenGL3App("AllBullet2Demos",width,height);
|
||||
app->m_instancingRenderer->setCameraDistance(13);
|
||||
app->m_instancingRenderer->setCameraPitch(0);
|
||||
app->m_instancingRenderer->setCameraTargetPosition(b3MakeVector3(0,0,0));
|
||||
app->m_window->setMouseMoveCallback(MyMouseMoveCallback);
|
||||
app->m_window->setMouseButtonCallback(MyMouseButtonCallback);
|
||||
app->m_window->setKeyboardCallback(MyKeyboardCallback);
|
||||
// wci.m_resizeCallback = MyResizeCallback;
|
||||
|
||||
|
||||
#ifdef USE_OPENGL2
|
||||
app = new SimpleOpenGL2App("AllBullet2Demos",width,height);
|
||||
app->m_renderer = new TestRenderer(width,height);
|
||||
#else
|
||||
SimpleOpenGL3App* simpleApp = new SimpleOpenGL3App("AllBullet2Demos",width,height);
|
||||
app = simpleApp;
|
||||
#endif
|
||||
s_instancingRenderer = app->m_renderer;
|
||||
s_window = app->m_window;
|
||||
prevMouseMoveCallback = s_window->getMouseMoveCallback();
|
||||
s_window->setMouseMoveCallback(MyMouseMoveCallback);
|
||||
|
||||
prevMouseButtonCallback = s_window->getMouseButtonCallback();
|
||||
s_window->setMouseButtonCallback(MyMouseButtonCallback);
|
||||
prevKeyboardCallback = s_window->getKeyboardCallback();
|
||||
s_window->setKeyboardCallback(MyKeyboardCallback);
|
||||
|
||||
app->m_renderer->setCameraDistance(13);
|
||||
app->m_renderer->setCameraPitch(0);
|
||||
app->m_renderer->setCameraTargetPosition(0,0,0);
|
||||
|
||||
/*
|
||||
SimpleOpenGL3App* app = new SimpleOpenGL3App("AllBullet2Demos",width,height);
|
||||
s_instancingRenderer->setCameraDistance(13);
|
||||
s_instancingRenderer->setCameraPitch(0);
|
||||
s_instancingRenderer->setCameraTargetPosition(0,0,0);
|
||||
s_window->setMouseMoveCallback(MyMouseMoveCallback);
|
||||
s_window->setMouseButtonCallback(MyMouseButtonCallback);
|
||||
s_window->setKeyboardCallback(MyKeyboardCallback);
|
||||
|
||||
*/
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
|
||||
sth_stash* fontstash=app->getFontStash();
|
||||
|
||||
|
||||
gui = new GwenUserInterface;
|
||||
gui->init(width,height,fontstash,app->m_window->getRetinaScale());
|
||||
GL3TexLoader* myTexLoader = new GL3TexLoader;
|
||||
#ifdef USE_OPENGL2
|
||||
Gwen::Renderer::Base* gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont();
|
||||
#else
|
||||
sth_stash* fontstash=simpleApp->getFontStash();
|
||||
Gwen::Renderer::Base* gwenRenderer = new GwenOpenGL3CoreRenderer(simpleApp->m_primRenderer,fontstash,width,height,s_window->getRetinaScale(),myTexLoader);
|
||||
#endif
|
||||
//
|
||||
|
||||
gui->init(width,height,gwenRenderer,s_window->getRetinaScale());
|
||||
// gui->getInternalData()->m_explorerPage
|
||||
Gwen::Controls::TreeControl* tree = gui->getInternalData()->m_explorerTreeCtrl;
|
||||
|
||||
GL3TexLoader* myTexLoader = new GL3TexLoader;
|
||||
gui->getInternalData()->pRenderer->setTextureLoader(myTexLoader);
|
||||
|
||||
//gui->getInternalData()->pRenderer->setTextureLoader(myTexLoader);
|
||||
|
||||
|
||||
MyProfileWindow* profWindow = setupProfileWindow(gui->getInternalData());
|
||||
profileWindowSetVisible(profWindow,false);
|
||||
|
||||
#if 0
|
||||
{
|
||||
MyGraphInput input(gui->getInternalData());
|
||||
input.m_width=300;
|
||||
@@ -448,9 +610,8 @@ int main(int argc, char* argv[])
|
||||
setupTextureWindow(input);
|
||||
}
|
||||
//destroyTextureWindow(gw);
|
||||
|
||||
|
||||
app->m_parameterInterface = new GwenParameterInterface(gui->getInternalData());
|
||||
#endif
|
||||
s_parameterInterface = app->m_parameterInterface = new GwenParameterInterface(gui->getInternalData());
|
||||
|
||||
//gui->getInternalData()->m_demoPage;
|
||||
|
||||
@@ -520,13 +681,13 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
assert(glGetError()==GL_NO_ERROR);
|
||||
app->m_instancingRenderer->init();
|
||||
s_instancingRenderer->init();
|
||||
DrawGridData dg;
|
||||
dg.upAxis = app->getUpAxis();
|
||||
|
||||
{
|
||||
BT_PROFILE("Update Camera");
|
||||
app->m_instancingRenderer->updateCamera(dg.upAxis);
|
||||
s_instancingRenderer->updateCamera(dg.upAxis);
|
||||
}
|
||||
{
|
||||
BT_PROFILE("Draw Grid");
|
||||
@@ -571,20 +732,30 @@ int main(int argc, char* argv[])
|
||||
if (!pauseSimulation)
|
||||
processProfileData(profWindow,false);
|
||||
{
|
||||
#ifdef USE_OPENGL2
|
||||
{
|
||||
saveOpenGLState(width,height);
|
||||
}
|
||||
#endif
|
||||
BT_PROFILE("Draw Gwen GUI");
|
||||
gui->draw(app->m_instancingRenderer->getScreenWidth(),app->m_instancingRenderer->getScreenHeight());
|
||||
gui->draw(s_instancingRenderer->getScreenWidth(),s_instancingRenderer->getScreenHeight());
|
||||
#ifdef USE_OPENGL2
|
||||
restoreOpenGLState();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
toggle=1-toggle;
|
||||
{
|
||||
BT_PROFILE("Sync Parameters");
|
||||
app->m_parameterInterface->syncParameters();
|
||||
s_parameterInterface->syncParameters();
|
||||
}
|
||||
{
|
||||
BT_PROFILE("Swap Buffers");
|
||||
app->swapBuffer();
|
||||
}
|
||||
} while (!app->m_window->requestedExit());
|
||||
|
||||
|
||||
} while (!s_window->requestedExit());
|
||||
|
||||
// selectDemo(0);
|
||||
delete gui;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "OpenGLWindow/GLPrimitiveRenderer.h"
|
||||
#include "OpenGLWindow/GLInstancingRenderer.h"
|
||||
//#include "OpenGL3CoreRenderer.h"
|
||||
#include "OpenGLWindow/GwenOpenGL3CoreRenderer.h"
|
||||
//#include "b3GpuDynamicsWorld.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
@@ -739,7 +739,10 @@ int main(int argc, char* argv[])
|
||||
|
||||
if (gui)
|
||||
{
|
||||
gui->init(g_OpenGLWidth,g_OpenGLHeight,stash,window->getRetinaScale());
|
||||
Gwen::Renderer::Base* gwenRenderer = new GwenOpenGL3CoreRenderer(&prim,stash, g_OpenGLWidth,g_OpenGLHeight,window->getRetinaScale());
|
||||
|
||||
|
||||
gui->init(g_OpenGLWidth,g_OpenGLHeight,gwenRenderer,window->getRetinaScale());
|
||||
|
||||
printf("init fonts");
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "OpenGLWindow/SimpleOpenGL3App.h"
|
||||
#include "Wavefront2GLInstanceGraphicsShape.h"
|
||||
|
||||
ImportObjDemo::ImportObjDemo(SimpleOpenGL3App* app)
|
||||
ImportObjDemo::ImportObjDemo(CommonGraphicsApp* app)
|
||||
:m_app(app)
|
||||
{
|
||||
|
||||
@@ -75,11 +75,11 @@ void ImportObjDemo::initPhysics(GraphicsPhysicsBridge& gfxBridge)
|
||||
|
||||
btVector3 color(0,0,1);
|
||||
|
||||
int shapeId = m_app->m_instancingRenderer->registerShape(&gfxShape->m_vertices->at(0).xyzw[0], gfxShape->m_numvertices, &gfxShape->m_indices->at(0), gfxShape->m_numIndices);
|
||||
int shapeId = m_app->m_renderer->registerShape(&gfxShape->m_vertices->at(0).xyzw[0], gfxShape->m_numvertices, &gfxShape->m_indices->at(0), gfxShape->m_numIndices);
|
||||
|
||||
|
||||
//int id =
|
||||
m_app->m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
m_app->m_renderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
|
||||
/*
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
class ImportObjDemo : public CommonRigidBodySetup
|
||||
{
|
||||
struct SimpleOpenGL3App* m_app;
|
||||
struct CommonGraphicsApp* m_app;
|
||||
public:
|
||||
ImportObjDemo(SimpleOpenGL3App* app);
|
||||
ImportObjDemo(CommonGraphicsApp* app);
|
||||
virtual ~ImportObjDemo();
|
||||
|
||||
virtual void initPhysics(GraphicsPhysicsBridge& gfxBridge);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "OpenGLWindow/SimpleOpenGL3App.h"
|
||||
#include "LoadMeshFromSTL.h"
|
||||
|
||||
ImportSTLDemo::ImportSTLDemo(SimpleOpenGL3App* app)
|
||||
ImportSTLDemo::ImportSTLDemo(CommonGraphicsApp* app)
|
||||
:m_app(app)
|
||||
{
|
||||
|
||||
@@ -68,11 +68,11 @@ void ImportSTLDemo::initPhysics(GraphicsPhysicsBridge& gfxBridge)
|
||||
|
||||
btVector3 color(0,0,1);
|
||||
|
||||
int shapeId = m_app->m_instancingRenderer->registerShape(&gfxShape->m_vertices->at(0).xyzw[0], gfxShape->m_numvertices, &gfxShape->m_indices->at(0), gfxShape->m_numIndices);
|
||||
int shapeId = m_app->m_renderer->registerShape(&gfxShape->m_vertices->at(0).xyzw[0], gfxShape->m_numvertices, &gfxShape->m_indices->at(0), gfxShape->m_numIndices);
|
||||
|
||||
|
||||
// int id =
|
||||
m_app->m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
m_app->m_renderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
|
||||
/*
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
class ImportSTLDemo : public CommonRigidBodySetup
|
||||
{
|
||||
struct SimpleOpenGL3App* m_app;
|
||||
struct CommonGraphicsApp* m_app;
|
||||
public:
|
||||
ImportSTLDemo(SimpleOpenGL3App* app);
|
||||
ImportSTLDemo(CommonGraphicsApp* app);
|
||||
virtual ~ImportSTLDemo();
|
||||
|
||||
virtual void initPhysics(GraphicsPhysicsBridge& gfxBridge);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "Bullet3Common/b3CommandLineArgs.h"
|
||||
#include "assert.h"
|
||||
#include <stdio.h>
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
|
||||
char* gVideoFileName = 0;
|
||||
char* gPngFileName = 0;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
static const float scaling=0.35f;
|
||||
|
||||
BasicDemo::BasicDemo(SimpleOpenGL3App* app, CommonPhysicsSetup* physicsSetup)
|
||||
BasicDemo::BasicDemo(CommonGraphicsApp* app, CommonPhysicsSetup* physicsSetup)
|
||||
:Bullet2RigidBodyDemo(app,physicsSetup)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -16,13 +16,13 @@ class BasicDemo : public Bullet2RigidBodyDemo
|
||||
|
||||
public:
|
||||
|
||||
static BulletDemoInterface* MyCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* MyCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
CommonPhysicsSetup* physicsSetup = new BasicDemoPhysicsSetup();
|
||||
return new BasicDemo(app, physicsSetup);
|
||||
}
|
||||
|
||||
BasicDemo(SimpleOpenGL3App* app, CommonPhysicsSetup* physicsSetup);
|
||||
BasicDemo(CommonGraphicsApp* app, CommonPhysicsSetup* physicsSetup);
|
||||
virtual ~BasicDemo();
|
||||
|
||||
void createGround(int cubeShapeId);
|
||||
|
||||
@@ -19,35 +19,35 @@ class HingeDemo : public BasicDemo
|
||||
int m_hingeMethod;
|
||||
|
||||
public:
|
||||
static BulletDemoInterface* FeatherstoneCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* FeatherstoneCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
return new HingeDemo(app, FEATHERSTONE_HINGE);
|
||||
}
|
||||
static BulletDemoInterface* DantzigCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* DantzigCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
return new HingeDemo(app, DANTZIG_HINGE);
|
||||
}
|
||||
static BulletDemoInterface* LemkeCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* LemkeCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
return new HingeDemo(app, LEMKE_HINGE);
|
||||
}
|
||||
static BulletDemoInterface* PGSCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* PGSCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
return new HingeDemo(app, PGS_HINGE);
|
||||
}
|
||||
|
||||
static BulletDemoInterface* SICreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* SICreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
return new HingeDemo(app, SI_HINGE);
|
||||
}
|
||||
|
||||
|
||||
static BulletDemoInterface* InertiaCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* InertiaCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
return new HingeDemo(app, INERTIA_HINGE);
|
||||
}
|
||||
|
||||
HingeDemo(SimpleOpenGL3App* app, HINGE_CREATION_METHOD hingeMethod);
|
||||
HingeDemo(CommonGraphicsApp* app, HINGE_CREATION_METHOD hingeMethod);
|
||||
|
||||
class btMultiBody* createFeatherstoneHinge(class btMultiBodyDynamicsWorld* world, const struct btMultiBodySettings2& settings);
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@ class ChainDemo : public Bullet2RigidBodyDemo
|
||||
|
||||
public:
|
||||
|
||||
static BulletDemoInterface* MyCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* MyCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
return new ChainDemo(app);
|
||||
}
|
||||
|
||||
ChainDemo(SimpleOpenGL3App* app);
|
||||
ChainDemo(CommonGraphicsApp* app);
|
||||
virtual ~ChainDemo();
|
||||
|
||||
void createGround(int cubeShapeId);
|
||||
|
||||
@@ -48,7 +48,7 @@ static btVector4 colors[4] =
|
||||
|
||||
|
||||
|
||||
Bullet2MultiBodyDemo::Bullet2MultiBodyDemo(SimpleOpenGL3App* app)
|
||||
Bullet2MultiBodyDemo::Bullet2MultiBodyDemo(CommonGraphicsApp* app)
|
||||
:m_glApp(app),
|
||||
m_pickedBody(0),
|
||||
m_pickedConstraint(0),
|
||||
@@ -97,7 +97,7 @@ Bullet2MultiBodyDemo::~Bullet2MultiBodyDemo()
|
||||
|
||||
btVector3 Bullet2MultiBodyDemo::getRayTo(int x,int y)
|
||||
{
|
||||
if (!m_glApp->m_instancingRenderer)
|
||||
if (!m_glApp->m_renderer)
|
||||
{
|
||||
btAssert(0);
|
||||
return btVector3(0,0,0);
|
||||
@@ -110,8 +110,8 @@ btVector3 Bullet2MultiBodyDemo::getRayTo(int x,int y)
|
||||
float fov = b3Scalar(2.0) * b3Atan(tanFov);
|
||||
|
||||
btVector3 camPos,camTarget;
|
||||
m_glApp->m_instancingRenderer->getCameraPosition(camPos);
|
||||
m_glApp->m_instancingRenderer->getCameraTargetPosition(camTarget);
|
||||
m_glApp->m_renderer->getCameraPosition(camPos);
|
||||
m_glApp->m_renderer->getCameraTargetPosition(camTarget);
|
||||
|
||||
btVector3 rayFrom = camPos;
|
||||
btVector3 rayForward = (camTarget-camPos);
|
||||
@@ -136,8 +136,8 @@ btVector3 Bullet2MultiBodyDemo::getRayTo(int x,int y)
|
||||
vertical *= 2.f * farPlane * tanfov;
|
||||
|
||||
b3Scalar aspect;
|
||||
float width = m_glApp->m_instancingRenderer->getScreenWidth();
|
||||
float height = m_glApp->m_instancingRenderer->getScreenHeight();
|
||||
float width = m_glApp->m_renderer->getScreenWidth();
|
||||
float height = m_glApp->m_renderer->getScreenHeight();
|
||||
|
||||
aspect = width / height;
|
||||
|
||||
@@ -171,7 +171,7 @@ bool Bullet2MultiBodyDemo::mouseMoveCallback(float x,float y)
|
||||
btVector3 rayFrom;
|
||||
// btVector3 oldPivotInB = pickCon->getPivotInB();
|
||||
btVector3 newPivotB;
|
||||
m_glApp->m_instancingRenderer->getCameraPosition(rayFrom);
|
||||
m_glApp->m_renderer->getCameraPosition(rayFrom);
|
||||
btVector3 dir = newRayTo-rayFrom;
|
||||
dir.normalize();
|
||||
dir *= m_oldPickingDist;
|
||||
@@ -189,7 +189,7 @@ bool Bullet2MultiBodyDemo::mouseMoveCallback(float x,float y)
|
||||
// btVector3 oldPivotInB = m_pickingMultiBodyPoint2Point->getPivotInB();
|
||||
btVector3 newPivotB;
|
||||
btVector3 camPos;
|
||||
m_glApp->m_instancingRenderer->getCameraPosition(camPos);
|
||||
m_glApp->m_renderer->getCameraPosition(camPos);
|
||||
rayFrom = camPos;
|
||||
btVector3 dir = newRayTo-rayFrom;
|
||||
dir.normalize();
|
||||
@@ -210,7 +210,7 @@ bool Bullet2MultiBodyDemo::mouseButtonCallback(int button, int state, float x, f
|
||||
if(button==0)// && (m_data->m_altPressed==0 && m_data->m_controlPressed==0))
|
||||
{
|
||||
btVector3 camPos;
|
||||
m_glApp->m_instancingRenderer->getCameraPosition(camPos);
|
||||
m_glApp->m_renderer->getCameraPosition(camPos);
|
||||
|
||||
btVector3 rayFrom = camPos;
|
||||
btVector3 rayTo = getRayTo(x,y);
|
||||
@@ -314,7 +314,7 @@ bool Bullet2MultiBodyDemo::mouseButtonCallback(int button, int state, float x, f
|
||||
|
||||
|
||||
|
||||
FeatherstoneDemo1::FeatherstoneDemo1(SimpleOpenGL3App* app)
|
||||
FeatherstoneDemo1::FeatherstoneDemo1(CommonGraphicsApp* app)
|
||||
:Bullet2MultiBodyDemo(app)
|
||||
{
|
||||
}
|
||||
@@ -329,7 +329,7 @@ btMultiBody* FeatherstoneDemo1::createFeatherstoneMultiBody(class btMultiBodyDyn
|
||||
int curColor=0;
|
||||
|
||||
|
||||
int cubeShapeId = m_glApp->registerCubeShape();
|
||||
int cubeShapeId = m_glApp->registerCubeShape(1,1,1);
|
||||
|
||||
int n_links = settings.m_numLinks;
|
||||
float mass = 13.5*scaling;
|
||||
@@ -458,7 +458,7 @@ btMultiBody* FeatherstoneDemo1::createFeatherstoneMultiBody(class btMultiBodyDyn
|
||||
btVector4 color = colors[curColor++];
|
||||
curColor&=3;
|
||||
|
||||
int index = m_glApp->m_instancingRenderer->registerGraphicsInstance(cubeShapeId,tr.getOrigin(),tr.getRotation(),color,halfExtents);
|
||||
int index = m_glApp->m_renderer->registerGraphicsInstance(cubeShapeId,tr.getOrigin(),tr.getRotation(),color,halfExtents);
|
||||
col->setUserIndex(index);
|
||||
|
||||
|
||||
@@ -503,7 +503,7 @@ btMultiBody* FeatherstoneDemo1::createFeatherstoneMultiBody(class btMultiBodyDyn
|
||||
btVector4 color = colors[curColor++];
|
||||
curColor&=3;
|
||||
|
||||
int index = m_glApp->m_instancingRenderer->registerGraphicsInstance(cubeShapeId,tr.getOrigin(),tr.getRotation(),color,halfExtents);
|
||||
int index = m_glApp->m_renderer->registerGraphicsInstance(cubeShapeId,tr.getOrigin(),tr.getRotation(),color,halfExtents);
|
||||
col->setUserIndex(index);
|
||||
|
||||
|
||||
@@ -530,7 +530,7 @@ void FeatherstoneDemo1::addBoxes_testMultiDof()
|
||||
void FeatherstoneDemo1::createGround()
|
||||
{
|
||||
//create ground
|
||||
int cubeShapeId = m_glApp->registerCubeShape();
|
||||
int cubeShapeId = m_glApp->registerCubeShape(1,1,1);
|
||||
//float pos[]={0,0,0};
|
||||
//float orn[]={0,0,0,1};
|
||||
|
||||
@@ -555,7 +555,7 @@ void FeatherstoneDemo1::createGround()
|
||||
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia);
|
||||
btRigidBody* body = new btRigidBody(rbInfo);
|
||||
|
||||
int index = m_glApp->m_instancingRenderer->registerGraphicsInstance(cubeShapeId,groundTransform.getOrigin(),groundTransform.getRotation(),color,halfExtents);
|
||||
int index = m_glApp->m_renderer->registerGraphicsInstance(cubeShapeId,groundTransform.getOrigin(),groundTransform.getRotation(),color,halfExtents);
|
||||
body ->setUserIndex(index);
|
||||
|
||||
//add the body to the dynamics world
|
||||
@@ -579,7 +579,7 @@ void FeatherstoneDemo1::initPhysics()
|
||||
createFeatherstoneMultiBody(m_dynamicsWorld,settings);
|
||||
|
||||
|
||||
m_glApp->m_instancingRenderer->writeTransforms();
|
||||
m_glApp->m_renderer->writeTransforms();
|
||||
}
|
||||
|
||||
|
||||
@@ -602,13 +602,13 @@ void FeatherstoneDemo1::renderScene()
|
||||
int index = col->getUserIndex();
|
||||
if (index>=0)
|
||||
{
|
||||
m_glApp->m_instancingRenderer->writeSingleInstanceTransformToCPU(pos,orn,index);
|
||||
m_glApp->m_renderer->writeSingleInstanceTransformToCPU(pos,orn,index);
|
||||
}
|
||||
}
|
||||
m_glApp->m_instancingRenderer->writeTransforms();
|
||||
m_glApp->m_renderer->writeTransforms();
|
||||
}
|
||||
|
||||
m_glApp->m_instancingRenderer->renderScene();
|
||||
m_glApp->m_renderer->renderScene();
|
||||
}
|
||||
|
||||
void FeatherstoneDemo1::physicsDebugDraw()
|
||||
@@ -646,7 +646,7 @@ void FeatherstoneDemo1::stepSimulation(float deltaTime)
|
||||
|
||||
|
||||
|
||||
FeatherstoneDemo2::FeatherstoneDemo2(SimpleOpenGL3App* app)
|
||||
FeatherstoneDemo2::FeatherstoneDemo2(CommonGraphicsApp* app)
|
||||
:FeatherstoneDemo1(app)
|
||||
{
|
||||
}
|
||||
@@ -1032,7 +1032,7 @@ void FeatherstoneDemo2::initPhysics()
|
||||
//RagDoll2* doll = new RagDoll2(m_dynamicsWorld,offset,m_glApp);
|
||||
|
||||
|
||||
m_glApp->m_instancingRenderer->writeTransforms();
|
||||
m_glApp->m_renderer->writeTransforms();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class Bullet2MultiBodyDemo : public BulletDemoInterface
|
||||
{
|
||||
protected:
|
||||
|
||||
SimpleOpenGL3App* m_glApp;
|
||||
CommonGraphicsApp* m_glApp;
|
||||
|
||||
class btRigidBody* m_pickedBody;
|
||||
class btTypedConstraint* m_pickedConstraint;
|
||||
@@ -53,7 +53,7 @@ protected:
|
||||
//btAlignedObjectArray<btMultiBodyLinkCollider*> m_linkColliders;
|
||||
|
||||
public:
|
||||
Bullet2MultiBodyDemo(SimpleOpenGL3App* app);
|
||||
Bullet2MultiBodyDemo(CommonGraphicsApp* app);
|
||||
virtual void initPhysics();
|
||||
virtual void exitPhysics();
|
||||
virtual ~Bullet2MultiBodyDemo();
|
||||
@@ -71,11 +71,11 @@ class FeatherstoneDemo1 : public Bullet2MultiBodyDemo
|
||||
|
||||
public:
|
||||
|
||||
FeatherstoneDemo1(SimpleOpenGL3App* app);
|
||||
FeatherstoneDemo1(CommonGraphicsApp* app);
|
||||
virtual ~FeatherstoneDemo1();
|
||||
|
||||
|
||||
static BulletDemoInterface* MyCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* MyCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
return new FeatherstoneDemo1(app);
|
||||
}
|
||||
@@ -100,11 +100,11 @@ class FeatherstoneDemo2 : public FeatherstoneDemo1
|
||||
|
||||
public:
|
||||
|
||||
FeatherstoneDemo2(SimpleOpenGL3App* app);
|
||||
FeatherstoneDemo2(CommonGraphicsApp* app);
|
||||
virtual ~FeatherstoneDemo2();
|
||||
|
||||
|
||||
static BulletDemoInterface* MyCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* MyCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
return new FeatherstoneDemo2(app);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ static float friction = 1.;
|
||||
|
||||
|
||||
|
||||
MultiDofDemo::MultiDofDemo(SimpleOpenGL3App* app)
|
||||
MultiDofDemo::MultiDofDemo(CommonGraphicsApp* app)
|
||||
:FeatherstoneDemo1(app)
|
||||
{
|
||||
}
|
||||
@@ -75,8 +75,8 @@ void MultiDofDemo::initPhysics()
|
||||
|
||||
if(g_firstInit)
|
||||
{
|
||||
this->m_glApp->m_instancingRenderer->setCameraDistance(btScalar(10.*scaling));
|
||||
this->m_glApp->m_instancingRenderer->setCameraPitch(50);
|
||||
this->m_glApp->m_renderer->setCameraDistance(btScalar(10.*scaling));
|
||||
this->m_glApp->m_renderer->setCameraPitch(50);
|
||||
g_firstInit = false;
|
||||
}
|
||||
///collision configuration contains default setup for memory, collision setup
|
||||
@@ -159,7 +159,7 @@ void MultiDofDemo::initPhysics()
|
||||
///
|
||||
addColliders_testMultiDof(mbC, world, baseHalfExtents, linkHalfExtents);
|
||||
|
||||
int cubeShapeId = m_glApp->registerCubeShape();
|
||||
int cubeShapeId = m_glApp->registerCubeShape(1,1,1);
|
||||
/////////////////////////////////////////////////////////////////
|
||||
btScalar groundHeight = -51.55;
|
||||
if (!multibodyOnly)
|
||||
@@ -183,7 +183,7 @@ void MultiDofDemo::initPhysics()
|
||||
//add the body to the dynamics world
|
||||
m_dynamicsWorld->addRigidBody(body,1,1+2);//,1,1+2);
|
||||
|
||||
int index = m_glApp->m_instancingRenderer->registerGraphicsInstance(cubeShapeId,groundTransform.getOrigin(),groundTransform.getRotation(),btVector4(0,1,0,1),groundHalfExtents);
|
||||
int index = m_glApp->m_renderer->registerGraphicsInstance(cubeShapeId,groundTransform.getOrigin(),groundTransform.getRotation(),btVector4(0,1,0,1),groundHalfExtents);
|
||||
body->setUserIndex(index);
|
||||
|
||||
|
||||
@@ -223,12 +223,12 @@ void MultiDofDemo::initPhysics()
|
||||
|
||||
m_dynamicsWorld->addRigidBody(body);//,1,1+2);
|
||||
|
||||
int index = m_glApp->m_instancingRenderer->registerGraphicsInstance(cubeShapeId,startTransform.getOrigin(),startTransform.getRotation(),btVector4(1,1,0,1),halfExtents);
|
||||
int index = m_glApp->m_renderer->registerGraphicsInstance(cubeShapeId,startTransform.getOrigin(),startTransform.getRotation(),btVector4(1,1,0,1),halfExtents);
|
||||
body->setUserIndex(index);
|
||||
|
||||
}
|
||||
|
||||
m_glApp->m_instancingRenderer->writeTransforms();
|
||||
m_glApp->m_renderer->writeTransforms();
|
||||
/////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ btMultiBody* MultiDofDemo::createFeatherstoneMultiBody_testMultiDof(btMultiBodyD
|
||||
|
||||
void MultiDofDemo::addColliders_testMultiDof(btMultiBody *pMultiBody, btMultiBodyDynamicsWorld *pWorld, const btVector3 &baseHalfExtents, const btVector3 &linkHalfExtents)
|
||||
{
|
||||
int cubeShapeId = m_glApp->registerCubeShape();
|
||||
int cubeShapeId = m_glApp->registerCubeShape(1,1,1);
|
||||
|
||||
btAlignedObjectArray<btQuaternion> world_to_local;
|
||||
world_to_local.resize(pMultiBody->getNumLinks() + 1);
|
||||
@@ -325,7 +325,7 @@ void MultiDofDemo::addColliders_testMultiDof(btMultiBody *pMultiBody, btMultiBod
|
||||
|
||||
pWorld->addCollisionObject(col, 2,1+2);
|
||||
|
||||
int index = m_glApp->m_instancingRenderer->registerGraphicsInstance(cubeShapeId,tr.getOrigin(),tr.getRotation(),btVector4(0,0,1,1),baseHalfExtents);
|
||||
int index = m_glApp->m_renderer->registerGraphicsInstance(cubeShapeId,tr.getOrigin(),tr.getRotation(),btVector4(0,0,1,1),baseHalfExtents);
|
||||
col->setUserIndex(index);
|
||||
|
||||
|
||||
@@ -363,7 +363,7 @@ void MultiDofDemo::addColliders_testMultiDof(btMultiBody *pMultiBody, btMultiBod
|
||||
col->setWorldTransform(tr);
|
||||
col->setFriction(friction);
|
||||
pWorld->addCollisionObject(col,2,1+2);
|
||||
int index = m_glApp->m_instancingRenderer->registerGraphicsInstance(cubeShapeId,tr.getOrigin(),tr.getRotation(),btVector4(0,0,1,1),linkHalfExtents);
|
||||
int index = m_glApp->m_renderer->registerGraphicsInstance(cubeShapeId,tr.getOrigin(),tr.getRotation(),btVector4(0,0,1,1),linkHalfExtents);
|
||||
col->setUserIndex(index);
|
||||
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@ class MultiDofDemo : public FeatherstoneDemo1
|
||||
|
||||
public:
|
||||
|
||||
MultiDofDemo(SimpleOpenGL3App* app);
|
||||
MultiDofDemo(CommonGraphicsApp* app);
|
||||
virtual ~MultiDofDemo();
|
||||
|
||||
|
||||
static BulletDemoInterface* MyCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* MyCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
return new MultiDofDemo(app);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ static btVector4 colors[4] =
|
||||
btVector4(1,1,0,1),
|
||||
};
|
||||
|
||||
LuaPhysicsSetup::LuaPhysicsSetup(class SimpleOpenGL3App* app)
|
||||
LuaPhysicsSetup::LuaPhysicsSetup(struct CommonGraphicsApp* app)
|
||||
:m_glApp(app),
|
||||
m_config(0),
|
||||
m_dispatcher(0),
|
||||
@@ -93,7 +93,7 @@ static int gCreateCubeShape(lua_State *L)
|
||||
btCollisionShape* colShape = new btBoxShape(halfExtents);
|
||||
|
||||
CustomShapeData* shapeData = new CustomShapeData();
|
||||
shapeData->m_shapeIndex = sLuaDemo->m_glApp->registerCubeShape();
|
||||
shapeData->m_shapeIndex = sLuaDemo->m_glApp->registerCubeShape(1,1,1);
|
||||
shapeData->m_localScaling = halfExtents;
|
||||
|
||||
colShape->setUserPointer(shapeData);
|
||||
@@ -252,7 +252,7 @@ static int gCreateRigidBody (lua_State *L)
|
||||
if (shapeData)
|
||||
{
|
||||
|
||||
rbd ->m_graphicsInstanceIndex = sLuaDemo->m_glApp->m_instancingRenderer->registerGraphicsInstance(shapeData->m_shapeIndex,startTransform.getOrigin(),startTransform.getRotation(),color,shapeData->m_localScaling);
|
||||
rbd ->m_graphicsInstanceIndex = sLuaDemo->m_glApp->m_renderer->registerGraphicsInstance(shapeData->m_shapeIndex,startTransform.getOrigin(),startTransform.getRotation(),color,shapeData->m_localScaling);
|
||||
body->setUserIndex(rbd->m_graphicsInstanceIndex);
|
||||
}
|
||||
}
|
||||
@@ -389,7 +389,7 @@ void LuaPhysicsSetup::initPhysics(GraphicsPhysicsBridge& gfxBridge)
|
||||
b3Error("Cannot find Lua file%s\n",sLuaFileName);
|
||||
}
|
||||
|
||||
m_glApp->m_instancingRenderer->writeTransforms();
|
||||
m_glApp->m_renderer->writeTransforms();
|
||||
}
|
||||
|
||||
|
||||
@@ -447,10 +447,10 @@ void LuaPhysicsSetup::syncPhysicsToGraphics(GraphicsPhysicsBridge& gfxBridge)
|
||||
int index = colObj->getUserIndex();
|
||||
if (index >= 0)
|
||||
{
|
||||
m_glApp->m_instancingRenderer->writeSingleInstanceTransformToCPU(pos, orn, index);
|
||||
m_glApp->m_renderer->writeSingleInstanceTransformToCPU(pos, orn, index);
|
||||
}
|
||||
}
|
||||
m_glApp->m_instancingRenderer->writeTransforms();
|
||||
m_glApp->m_renderer->writeTransforms();
|
||||
}
|
||||
|
||||
btRigidBody* LuaPhysicsSetup::createRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape, const btVector4& color)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
struct LuaPhysicsSetup : public CommonPhysicsSetup
|
||||
{
|
||||
|
||||
LuaPhysicsSetup(class SimpleOpenGL3App* app);
|
||||
LuaPhysicsSetup(struct CommonGraphicsApp* app);
|
||||
virtual ~LuaPhysicsSetup();
|
||||
|
||||
class btDefaultCollisionConfiguration* m_config;
|
||||
@@ -17,7 +17,7 @@ struct LuaPhysicsSetup : public CommonPhysicsSetup
|
||||
class btDbvtBroadphase* m_bp;
|
||||
class btNNCGConstraintSolver* m_solver;
|
||||
class btDiscreteDynamicsWorld* m_dynamicsWorld;
|
||||
class SimpleOpenGL3App* m_glApp;
|
||||
struct CommonGraphicsApp* m_glApp;
|
||||
|
||||
virtual void initPhysics(GraphicsPhysicsBridge& gfxBridge);
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
#include "../BasicDemo/BasicDemo.h"
|
||||
|
||||
struct BulletDemoInterface;
|
||||
struct SimpleOpenGL3App;
|
||||
struct CommonGraphicsApp;
|
||||
|
||||
class RagDollSetup : public CommonRigidBodySetup
|
||||
{
|
||||
public:
|
||||
|
||||
static BulletDemoInterface* MyCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* MyCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
CommonPhysicsSetup* physicsSetup = new RagDollSetup();
|
||||
return new BasicDemo(app, physicsSetup);
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#include "Bullet2RigidBodyDemo.h"
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include "OpenGLWindow/SimpleOpenGL3App.h"
|
||||
|
||||
#include "OpenGLWindow/CommonGraphicsApp.h"
|
||||
#include "OpenGLWindow/CommonRenderInterface.h"
|
||||
#include "Bullet3Common/b3Scalar.h"
|
||||
|
||||
#include "BulletCollision/CollisionShapes/btShapeHull.h"//to create a tesselation of a generic btConvexShape
|
||||
#include "MyDebugDrawer.h"
|
||||
struct GraphicsVertex
|
||||
@@ -13,10 +17,10 @@ struct GraphicsVertex
|
||||
|
||||
struct MyGraphicsPhysicsBridge : public GraphicsPhysicsBridge
|
||||
{
|
||||
SimpleOpenGL3App* m_glApp;
|
||||
CommonGraphicsApp* m_glApp;
|
||||
MyDebugDrawer* m_debugDraw;
|
||||
|
||||
MyGraphicsPhysicsBridge(SimpleOpenGL3App* glApp)
|
||||
MyGraphicsPhysicsBridge(CommonGraphicsApp* glApp)
|
||||
:m_glApp(glApp), m_debugDraw(0)
|
||||
{
|
||||
}
|
||||
@@ -31,7 +35,7 @@ struct MyGraphicsPhysicsBridge : public GraphicsPhysicsBridge
|
||||
int graphicsShapeId = shape->getUserIndex();
|
||||
btAssert(graphicsShapeId >= 0);
|
||||
btVector3 localScaling = shape->getLocalScaling();
|
||||
int graphicsInstanceId = m_glApp->m_instancingRenderer->registerGraphicsInstance(graphicsShapeId, startTransform.getOrigin(), startTransform.getRotation(), color, localScaling);
|
||||
int graphicsInstanceId = m_glApp->m_renderer->registerGraphicsInstance(graphicsShapeId, startTransform.getOrigin(), startTransform.getRotation(), color, localScaling);
|
||||
body->setUserIndex(graphicsInstanceId);
|
||||
}
|
||||
virtual void createCollisionShapeGraphicsObject(btCollisionShape* collisionShape)
|
||||
@@ -110,7 +114,7 @@ struct MyGraphicsPhysicsBridge : public GraphicsPhysicsBridge
|
||||
}
|
||||
|
||||
|
||||
int shapeId = m_glApp->m_instancingRenderer->registerShape(&gvertices[0].pos[0],gvertices.size(),&indices[0],indices.size());
|
||||
int shapeId = m_glApp->m_renderer->registerShape(&gvertices[0].pos[0],gvertices.size(),&indices[0],indices.size());
|
||||
convex->setUserIndex(shapeId);
|
||||
}
|
||||
}
|
||||
@@ -132,10 +136,10 @@ struct MyGraphicsPhysicsBridge : public GraphicsPhysicsBridge
|
||||
int index = colObj->getUserIndex();
|
||||
if (index >= 0)
|
||||
{
|
||||
m_glApp->m_instancingRenderer->writeSingleInstanceTransformToCPU(pos, orn, index);
|
||||
m_glApp->m_renderer->writeSingleInstanceTransformToCPU(pos, orn, index);
|
||||
}
|
||||
}
|
||||
m_glApp->m_instancingRenderer->writeTransforms();
|
||||
m_glApp->m_renderer->writeTransforms();
|
||||
}
|
||||
|
||||
virtual void createPhysicsDebugDrawer(btDiscreteDynamicsWorld* rbWorld)
|
||||
@@ -164,7 +168,7 @@ struct MyGraphicsPhysicsBridge : public GraphicsPhysicsBridge
|
||||
}
|
||||
};
|
||||
|
||||
Bullet2RigidBodyDemo::Bullet2RigidBodyDemo(SimpleOpenGL3App* app, CommonPhysicsSetup* physicsSetup)
|
||||
Bullet2RigidBodyDemo::Bullet2RigidBodyDemo(CommonGraphicsApp* app, CommonPhysicsSetup* physicsSetup)
|
||||
: m_physicsSetup(physicsSetup),
|
||||
m_controlPressed(false),
|
||||
m_altPressed(false),
|
||||
@@ -177,7 +181,7 @@ void Bullet2RigidBodyDemo::initPhysics()
|
||||
MyGraphicsPhysicsBridge glBridge(m_glApp);
|
||||
glBridge.setUpAxis(1);
|
||||
m_physicsSetup->initPhysics(glBridge);
|
||||
m_glApp->m_instancingRenderer->writeTransforms();
|
||||
m_glApp->m_renderer->writeTransforms();
|
||||
|
||||
}
|
||||
|
||||
@@ -201,7 +205,7 @@ void Bullet2RigidBodyDemo::renderScene()
|
||||
MyGraphicsPhysicsBridge glBridge(m_glApp);
|
||||
m_physicsSetup->syncPhysicsToGraphics(glBridge);
|
||||
|
||||
m_glApp->m_instancingRenderer->renderScene();
|
||||
m_glApp->m_renderer->renderScene();
|
||||
|
||||
}
|
||||
|
||||
@@ -216,7 +220,7 @@ Bullet2RigidBodyDemo::~Bullet2RigidBodyDemo()
|
||||
|
||||
btVector3 Bullet2RigidBodyDemo::getRayTo(int x,int y)
|
||||
{
|
||||
if (!m_glApp->m_instancingRenderer)
|
||||
if (!m_glApp->m_renderer)
|
||||
{
|
||||
btAssert(0);
|
||||
return btVector3(0,0,0);
|
||||
@@ -229,8 +233,8 @@ btVector3 Bullet2RigidBodyDemo::getRayTo(int x,int y)
|
||||
float fov = b3Scalar(2.0) * b3Atan(tanFov);
|
||||
|
||||
btVector3 camPos,camTarget;
|
||||
m_glApp->m_instancingRenderer->getCameraPosition(camPos);
|
||||
m_glApp->m_instancingRenderer->getCameraTargetPosition(camTarget);
|
||||
m_glApp->m_renderer->getCameraPosition(camPos);
|
||||
m_glApp->m_renderer->getCameraTargetPosition(camTarget);
|
||||
|
||||
btVector3 rayFrom = camPos;
|
||||
btVector3 rayForward = (camTarget-camPos);
|
||||
@@ -257,8 +261,8 @@ btVector3 Bullet2RigidBodyDemo::getRayTo(int x,int y)
|
||||
vertical *= 2.f * farPlane * tanfov;
|
||||
|
||||
b3Scalar aspect;
|
||||
float width = m_glApp->m_instancingRenderer->getScreenWidth();
|
||||
float height = m_glApp->m_instancingRenderer->getScreenHeight();
|
||||
float width = m_glApp->m_renderer->getScreenWidth();
|
||||
float height = m_glApp->m_renderer->getScreenHeight();
|
||||
|
||||
aspect = width / height;
|
||||
|
||||
@@ -281,7 +285,7 @@ bool Bullet2RigidBodyDemo::mouseMoveCallback(float x,float y)
|
||||
{
|
||||
btVector3 rayTo = getRayTo(x, y);
|
||||
btVector3 rayFrom;
|
||||
m_glApp->m_instancingRenderer->getCameraPosition(rayFrom);
|
||||
m_glApp->m_renderer->getCameraPosition(rayFrom);
|
||||
m_physicsSetup->movePickedBody(rayFrom,rayTo);
|
||||
|
||||
return false;
|
||||
@@ -295,7 +299,7 @@ bool Bullet2RigidBodyDemo::mouseButtonCallback(int button, int state, float x, f
|
||||
if(button==0 && (!m_altPressed && !m_controlPressed))
|
||||
{
|
||||
btVector3 camPos;
|
||||
m_glApp->m_instancingRenderer->getCameraPosition(camPos);
|
||||
m_glApp->m_renderer->getCameraPosition(camPos);
|
||||
|
||||
btVector3 rayFrom = camPos;
|
||||
btVector3 rayTo = getRayTo(x,y);
|
||||
|
||||
@@ -19,9 +19,9 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
struct SimpleOpenGL3App* m_glApp;
|
||||
struct CommonGraphicsApp* m_glApp;
|
||||
|
||||
Bullet2RigidBodyDemo(SimpleOpenGL3App* app, CommonPhysicsSetup* physicsSetup);
|
||||
Bullet2RigidBodyDemo(CommonGraphicsApp* app, CommonPhysicsSetup* physicsSetup);
|
||||
virtual void initPhysics();
|
||||
virtual void exitPhysics();
|
||||
virtual void renderScene();
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#ifndef DEMO_INTERFACE_H
|
||||
#define DEMO_INTERFACE_H
|
||||
|
||||
struct SimpleOpenGL3App;
|
||||
struct CommonGraphicsApp;
|
||||
|
||||
class BulletDemoInterface
|
||||
{
|
||||
public:
|
||||
|
||||
typedef class BulletDemoInterface* (CreateFunc)(SimpleOpenGL3App* app);
|
||||
typedef class BulletDemoInterface* (CreateFunc)(CommonGraphicsApp* app);
|
||||
|
||||
virtual ~BulletDemoInterface()
|
||||
{
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
class EmptyBulletDemo : public BulletDemoInterface
|
||||
{
|
||||
public:
|
||||
static BulletDemoInterface* MyCreateFunc(SimpleOpenGL3App* app)
|
||||
static BulletDemoInterface* MyCreateFunc(CommonGraphicsApp* app)
|
||||
{
|
||||
return new EmptyBulletDemo();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "LinearMath/btIDebugDraw.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
#include "OpenGLWindow/CommonGraphicsApp.h"
|
||||
|
||||
#define BT_LINE_BATCH_SIZE 512
|
||||
|
||||
struct MyDebugVec3
|
||||
@@ -20,7 +22,7 @@ struct MyDebugVec3
|
||||
};
|
||||
class MyDebugDrawer : public btIDebugDraw
|
||||
{
|
||||
SimpleOpenGL3App* m_glApp;
|
||||
CommonGraphicsApp* m_glApp;
|
||||
int m_debugMode;
|
||||
|
||||
btAlignedObjectArray<MyDebugVec3> m_linePoints;
|
||||
@@ -29,7 +31,7 @@ class MyDebugDrawer : public btIDebugDraw
|
||||
|
||||
public:
|
||||
|
||||
MyDebugDrawer(SimpleOpenGL3App* app)
|
||||
MyDebugDrawer(CommonGraphicsApp* app)
|
||||
: m_glApp(app)
|
||||
,m_debugMode(btIDebugDraw::DBG_DrawWireframe|btIDebugDraw::DBG_DrawAabb),
|
||||
m_currentLineColor(-1,-1,-1)
|
||||
@@ -92,7 +94,7 @@ public:
|
||||
debugColor[1] = m_currentLineColor.y();
|
||||
debugColor[2] = m_currentLineColor.z();
|
||||
debugColor[3] = 1.f;
|
||||
m_glApp->m_instancingRenderer->drawLines(&m_linePoints[0].x,debugColor,
|
||||
m_glApp->m_renderer->drawLines(&m_linePoints[0].x,debugColor,
|
||||
m_linePoints.size(),sizeof(MyDebugVec3),
|
||||
&m_lineIndices[0],
|
||||
m_lineIndices.size(),
|
||||
|
||||
@@ -31,11 +31,12 @@
|
||||
|
||||
struct GwenInternalData
|
||||
{
|
||||
struct sth_stash;
|
||||
class GwenOpenGL3CoreRenderer* pRenderer;
|
||||
//struct sth_stash;
|
||||
//class GwenOpenGL3CoreRenderer* pRenderer;
|
||||
Gwen::Renderer::Base* pRenderer;
|
||||
Gwen::Skin::Simple skin;
|
||||
Gwen::Controls::Canvas* pCanvas;
|
||||
GLPrimitiveRenderer* m_primRenderer;
|
||||
//GLPrimitiveRenderer* m_primRenderer;
|
||||
Gwen::Controls::TabButton* m_demoPage;
|
||||
Gwen::Controls::TabButton* m_explorerPage;
|
||||
Gwen::Controls::TreeControl* m_explorerTreeCtrl;
|
||||
|
||||
@@ -27,13 +27,10 @@ GwenUserInterface::~GwenUserInterface()
|
||||
|
||||
delete m_data->pCanvas;
|
||||
|
||||
GLPrimitiveRenderer* prim = m_data->m_primRenderer;
|
||||
GwenOpenGL3CoreRenderer* coreRend = m_data->pRenderer;
|
||||
|
||||
delete m_data;
|
||||
|
||||
delete prim;
|
||||
delete coreRend;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -161,11 +158,11 @@ void GwenUserInterface::registerFileOpenCallback(b3FileOpenCallback callback)
|
||||
m_data->m_menuItems->m_fileOpenCallback = callback;
|
||||
}
|
||||
|
||||
void GwenUserInterface::init(int width, int height,struct sth_stash* stash,float retinaScale)
|
||||
void GwenUserInterface::init(int width, int height,Gwen::Renderer::Base* renderer,float retinaScale)
|
||||
{
|
||||
m_data->m_curYposition = 20;
|
||||
m_data->m_primRenderer = new GLPrimitiveRenderer(width,height);
|
||||
m_data->pRenderer = new GwenOpenGL3CoreRenderer(m_data->m_primRenderer,stash,width,height,retinaScale);
|
||||
//m_data->m_primRenderer = new GLPrimitiveRenderer(width,height);
|
||||
m_data->pRenderer = renderer;//new GwenOpenGL3CoreRenderer(m_data->m_primRenderer,stash,width,height,retinaScale);
|
||||
|
||||
m_data->skin.SetRender( m_data->pRenderer );
|
||||
|
||||
@@ -357,7 +354,7 @@ void GwenUserInterface::draw(int width, int height)
|
||||
if (m_data->pCanvas)
|
||||
{
|
||||
m_data->pCanvas->SetSize(width,height);
|
||||
m_data->m_primRenderer->setScreenSize(width,height);
|
||||
//m_data->m_primRenderer->setScreenSize(width,height);
|
||||
m_data->pRenderer->Resize(width,height);
|
||||
m_data->pCanvas->RenderCanvas();
|
||||
//restoreOpenGLState();
|
||||
|
||||
@@ -7,7 +7,13 @@ typedef void (*b3ComboBoxCallback) (int combobox, const char* item);
|
||||
typedef void (*b3ToggleButtonCallback)(int button, int state);
|
||||
typedef void (*b3FileOpenCallback)();
|
||||
|
||||
|
||||
namespace Gwen
|
||||
{
|
||||
namespace Renderer
|
||||
{
|
||||
class Base;
|
||||
};
|
||||
};
|
||||
class GwenUserInterface
|
||||
{
|
||||
GwenInternalData* m_data;
|
||||
@@ -18,7 +24,7 @@ class GwenUserInterface
|
||||
|
||||
virtual ~GwenUserInterface();
|
||||
|
||||
void init(int width, int height,struct sth_stash* stash,float retinaScale);
|
||||
void init(int width, int height,Gwen::Renderer::Base* gwenRenderer,float retinaScale);
|
||||
|
||||
void draw(int width, int height);
|
||||
|
||||
|
||||
@@ -308,14 +308,14 @@ int main()
|
||||
b3gDefaultOpenGLWindow* window = new b3gDefaultOpenGLWindow();
|
||||
window->setKeyboardCallback(keyCallback);
|
||||
b3gWindowConstructionInfo wci;
|
||||
wci.m_openglVersion = 3;
|
||||
wci.m_openglVersion = 2;
|
||||
wci.m_width = sWidth;
|
||||
wci.m_height = sHeight;
|
||||
// wci.m_resizeCallback = MyResizeCallback;
|
||||
|
||||
window->createWindow(wci);
|
||||
window->setResizeCallback(MyResizeCallback);
|
||||
window->setWindowTitle("render test");
|
||||
|
||||
|
||||
int majorGlVersion, minorGlVersion;
|
||||
|
||||
@@ -324,6 +324,16 @@ int main()
|
||||
printf("Exit: Error cannot extract OpenGL version from GL_VERSION string\n");
|
||||
exit(0);
|
||||
}
|
||||
char title[1024];
|
||||
if (wci.m_openglVersion>2)
|
||||
{
|
||||
sprintf(title,"Gwen with OpenGL %d.%d\n",majorGlVersion,minorGlVersion);
|
||||
} else
|
||||
{
|
||||
sprintf(title,"Gwen with OpenGL %d\n",wci.m_openglVersion);
|
||||
}
|
||||
window->setWindowTitle(title);
|
||||
|
||||
if (majorGlVersion>=3 && wci.m_openglVersion>=3)
|
||||
{
|
||||
float retinaScale = 1.f;
|
||||
@@ -360,10 +370,7 @@ int main()
|
||||
|
||||
skin.SetRender( gwenRenderer );
|
||||
|
||||
pCanvas = new Gwen::Controls::Canvas( &skin );
|
||||
pCanvas->SetSize( sWidth, sHeight);
|
||||
pCanvas->SetDrawBackground( true );
|
||||
pCanvas->SetBackgroundColor( Gwen::Color( 150, 170, 170, 255 ) );
|
||||
|
||||
|
||||
glClearColor(1,0,0,1);
|
||||
|
||||
|
||||
51
btgui/OpenGLWindow/CommonGraphicsApp.h
Normal file
51
btgui/OpenGLWindow/CommonGraphicsApp.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef COMMON_GRAPHICS_APP_H
|
||||
#define COMMON_GRAPHICS_APP_H
|
||||
|
||||
struct DrawGridData
|
||||
{
|
||||
int gridSize;
|
||||
float upOffset;
|
||||
int upAxis;
|
||||
float gridColor[4];
|
||||
|
||||
DrawGridData()
|
||||
:gridSize(10),
|
||||
upOffset(0.001f),
|
||||
upAxis(1)
|
||||
{
|
||||
gridColor[0] = 0.6f;
|
||||
gridColor[1] = 0.6f;
|
||||
gridColor[2] = 0.6f;
|
||||
gridColor[3] = 1.f;
|
||||
}
|
||||
};
|
||||
|
||||
struct CommonGraphicsApp
|
||||
{
|
||||
CommonGraphicsApp()
|
||||
:m_window(0),
|
||||
m_renderer(0),
|
||||
m_parameterInterface(0)
|
||||
{
|
||||
}
|
||||
virtual ~CommonGraphicsApp()
|
||||
{
|
||||
}
|
||||
|
||||
class b3gWindowInterface* m_window;
|
||||
struct CommonRenderInterface* m_renderer;
|
||||
struct CommonParameterInterface* m_parameterInterface;
|
||||
|
||||
virtual void drawGrid(DrawGridData data=DrawGridData()) = 0;
|
||||
virtual void setUpAxis(int axis) = 0;
|
||||
virtual int getUpAxis() const = 0;
|
||||
|
||||
virtual void swapBuffer() = 0;
|
||||
virtual void drawText( const char* txt, int posX, int posY) = 0;
|
||||
|
||||
virtual int registerCubeShape(float halfExtentsX,float halfExtentsY, float halfExtentsZ)=0;
|
||||
virtual int registerGraphicsSphereShape(float radius, bool usePointSprites, int largeSphereThreshold, int mediumSphereThreshold)=0;
|
||||
};
|
||||
|
||||
|
||||
#endif //COMMON_GRAPHICS_APP_H
|
||||
50
btgui/OpenGLWindow/CommonRenderInterface.h
Normal file
50
btgui/OpenGLWindow/CommonRenderInterface.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef COMMON_RENDER_INTERFACE_H
|
||||
#define COMMON_RENDER_INTERFACE_H
|
||||
|
||||
enum
|
||||
{
|
||||
B3_GL_TRIANGLES = 1,
|
||||
B3_GL_POINTS
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
B3_DEFAULT_RENDERMODE=1,
|
||||
//B3_WIREFRAME_RENDERMODE,
|
||||
B3_CREATE_SHADOWMAP_RENDERMODE,
|
||||
B3_USE_SHADOWMAP_RENDERMODE,
|
||||
};
|
||||
|
||||
struct CommonRenderInterface
|
||||
{
|
||||
virtual void init()=0;
|
||||
virtual void updateCamera(int upAxis)=0;
|
||||
virtual void removeAllInstances() = 0;
|
||||
virtual void setCameraDistance(float dist) = 0;
|
||||
virtual void setCameraPitch(float pitch) = 0;
|
||||
virtual void setCameraTargetPosition(float x, float y, float z)=0;
|
||||
|
||||
|
||||
virtual void getCameraPosition(float cameraPos[4])=0;
|
||||
virtual void getCameraPosition(double cameraPos[4])=0;
|
||||
|
||||
virtual void setCameraTargetPosition(float cameraPos[4])=0;
|
||||
virtual void getCameraTargetPosition(float cameraPos[4]) const=0;
|
||||
virtual void getCameraTargetPosition(double cameraPos[4]) const=0;
|
||||
|
||||
virtual void renderScene()=0;
|
||||
|
||||
virtual int getScreenWidth() = 0;
|
||||
virtual int getScreenHeight() = 0;
|
||||
|
||||
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling)=0;
|
||||
virtual void drawLines(const float* positions, const float color[4], int numPoints, int pointStrideInBytes, const unsigned int* indices, int numIndices, float pointDrawSize)=0;
|
||||
virtual void drawLine(const float from[4], const float to[4], const float color[4], float lineWidth) = 0;
|
||||
virtual int registerShape(const float* vertices, int numvertices, const int* indices, int numIndices,int primitiveType=B3_GL_TRIANGLES, int textureIndex=-1)=0;
|
||||
|
||||
virtual void writeSingleInstanceTransformToCPU(const float* position, const float* orientation, int srcIndex)=0;
|
||||
virtual void writeSingleInstanceTransformToCPU(const double* position, const double* orientation, int srcIndex)=0;
|
||||
virtual void writeTransforms()=0;
|
||||
};
|
||||
#endif//COMMON_RENDER_INTERFACE_H
|
||||
|
||||
@@ -951,7 +951,7 @@ void GLInstancingRenderer::init()
|
||||
}
|
||||
|
||||
|
||||
void b3CreateFrustum(
|
||||
static void b3CreateFrustum(
|
||||
float left,
|
||||
float right,
|
||||
float bottom,
|
||||
@@ -984,14 +984,14 @@ void b3CreateFrustum(
|
||||
}
|
||||
|
||||
|
||||
void b3Matrix4x4Mul(GLfloat aIn[4][4], GLfloat bIn[4][4], GLfloat result[4][4])
|
||||
static void b3Matrix4x4Mul(GLfloat aIn[4][4], GLfloat bIn[4][4], GLfloat result[4][4])
|
||||
{
|
||||
for (int j=0;j<4;j++)
|
||||
for (int i=0;i<4;i++)
|
||||
result[j][i] = aIn[0][i] * bIn[j][0] + aIn[1][i] * bIn[j][1] + aIn[2][i] * bIn[j][2] + aIn[3][i] * bIn[j][3];
|
||||
}
|
||||
|
||||
void b3Matrix4x4Mul16(GLfloat aIn[16], GLfloat bIn[16], GLfloat result[16])
|
||||
static void b3Matrix4x4Mul16(GLfloat aIn[16], GLfloat bIn[16], GLfloat result[16])
|
||||
{
|
||||
for (int j=0;j<4;j++)
|
||||
for (int i=0;i<4;i++)
|
||||
@@ -999,7 +999,7 @@ void b3Matrix4x4Mul16(GLfloat aIn[16], GLfloat bIn[16], GLfloat result[16])
|
||||
}
|
||||
|
||||
|
||||
void b3CreateDiagonalMatrix(GLfloat value, GLfloat result[4][4])
|
||||
static void b3CreateDiagonalMatrix(GLfloat value, GLfloat result[4][4])
|
||||
{
|
||||
for (int i=0;i<4;i++)
|
||||
{
|
||||
@@ -1016,7 +1016,7 @@ void b3CreateDiagonalMatrix(GLfloat value, GLfloat result[4][4])
|
||||
}
|
||||
}
|
||||
|
||||
void b3CreateOrtho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar, GLfloat result[4][4])
|
||||
static void b3CreateOrtho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar, GLfloat result[4][4])
|
||||
{
|
||||
b3CreateDiagonalMatrix(1.f,result);
|
||||
|
||||
@@ -1028,7 +1028,7 @@ void b3CreateOrtho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLf
|
||||
result[3][2] = - (zFar + zNear) / (zFar - zNear);
|
||||
}
|
||||
|
||||
void b3CreateLookAt(const b3Vector3& eye, const b3Vector3& center,const b3Vector3& up, GLfloat result[16])
|
||||
static void b3CreateLookAt(const b3Vector3& eye, const b3Vector3& center,const b3Vector3& up, GLfloat result[16])
|
||||
{
|
||||
b3Vector3 f = (center - eye).normalized();
|
||||
b3Vector3 u = up.normalized();
|
||||
@@ -1172,9 +1172,13 @@ float GLInstancingRenderer::getCameraPitch() const
|
||||
return m_data->m_azi;
|
||||
}
|
||||
|
||||
void GLInstancingRenderer::setCameraTargetPosition(float x, float y, float z)
|
||||
{
|
||||
m_data->m_cameraTargetPosition = b3MakeVector3(x,y,z);
|
||||
}
|
||||
void GLInstancingRenderer::setCameraTargetPosition(float cameraPos[4])
|
||||
{
|
||||
m_data->m_cameraTargetPosition = b3MakeVector3(cameraPos[0],cameraPos[1],cameraPos[2]);
|
||||
setCameraTargetPosition(cameraPos[0],cameraPos[1],cameraPos[2]);
|
||||
}
|
||||
|
||||
void GLInstancingRenderer::getCameraTargetPosition(float cameraPos[4]) const
|
||||
|
||||
@@ -17,6 +17,7 @@ subject to the following restrictions:
|
||||
#define GL_INSTANCING_RENDERER_H
|
||||
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
#include "OpenGLWindow/CommonRenderInterface.h"
|
||||
|
||||
|
||||
void b3DefaultMouseButtonCallback( int button, int state, float x, float y);
|
||||
@@ -24,21 +25,9 @@ void b3DefaultMouseMoveCallback( float x, float y);
|
||||
void b3DefaultKeyboardCallback(int key, int state);
|
||||
void b3DefaultWheelCallback( float deltax, float deltay);
|
||||
|
||||
enum
|
||||
{
|
||||
B3_GL_TRIANGLES = 1,
|
||||
B3_GL_POINTS
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
B3_DEFAULT_RENDERMODE=1,
|
||||
//B3_WIREFRAME_RENDERMODE,
|
||||
B3_CREATE_SHADOWMAP_RENDERMODE,
|
||||
B3_USE_SHADOWMAP_RENDERMODE,
|
||||
};
|
||||
|
||||
class GLInstancingRenderer
|
||||
class GLInstancingRenderer : public CommonRenderInterface
|
||||
{
|
||||
|
||||
b3AlignedObjectArray<struct b3GraphicsInstance*> m_graphicsInstances;
|
||||
@@ -129,6 +118,7 @@ public:
|
||||
float getCameraDistance() const;
|
||||
|
||||
//set the camera 'target'
|
||||
void setCameraTargetPosition(float x, float y, float z);
|
||||
void setCameraTargetPosition(float cameraPos[4]);
|
||||
void getCameraTargetPosition(float cameraPos[4]) const;
|
||||
void getCameraTargetPosition(double cameraPos[4]) const
|
||||
@@ -148,11 +138,11 @@ public:
|
||||
float getCameraPitch() const;
|
||||
|
||||
void resize(int width, int height);
|
||||
int getScreenWidth()
|
||||
virtual int getScreenWidth()
|
||||
{
|
||||
return m_screenWidth;
|
||||
}
|
||||
int getScreenHeight()
|
||||
virtual int getScreenHeight()
|
||||
{
|
||||
return m_screenHeight;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef _GL_PRIMITIVE_RENDERER_H
|
||||
#define _GL_PRIMITIVE_RENDERER_H
|
||||
|
||||
#include "OpenGLInclude.h"
|
||||
//#include "OpenGLInclude.h"
|
||||
|
||||
class GLPrimitiveRenderer
|
||||
{
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "Gwen/Gwen.h"
|
||||
#include "Gwen/BaseRender.h"
|
||||
#include "GLPrimitiveRenderer.h"
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
|
||||
struct sth_stash;
|
||||
#include "fontstash.h"
|
||||
#include "Gwen/Texture.h"
|
||||
@@ -74,14 +76,14 @@ class GwenOpenGL3CoreRenderer : public Gwen::Renderer::Base
|
||||
GLuint m_fontTextureId;
|
||||
MyTextureLoader* m_textureLoader;
|
||||
public:
|
||||
GwenOpenGL3CoreRenderer (GLPrimitiveRenderer* primRender, sth_stash* font,float screenWidth, float screenHeight, float retinaScale)
|
||||
GwenOpenGL3CoreRenderer (GLPrimitiveRenderer* primRender, sth_stash* font,float screenWidth, float screenHeight, float retinaScale, MyTextureLoader* loader=0)
|
||||
:m_primitiveRenderer(primRender),
|
||||
m_font(font),
|
||||
m_screenWidth(screenWidth),
|
||||
m_screenHeight(screenHeight),
|
||||
m_retinaScale(retinaScale),
|
||||
m_useTrueTypeFont(false),
|
||||
m_textureLoader(0)
|
||||
m_textureLoader(loader)
|
||||
{
|
||||
///only enable true type fonts on Macbook Retina, it looks gorgeous
|
||||
if (retinaScale==2.0f)
|
||||
@@ -323,10 +325,6 @@ public:
|
||||
return Gwen::Renderer::Base::MeasureText(pFont,text);
|
||||
}
|
||||
|
||||
void setTextureLoader(MyTextureLoader* loader)
|
||||
{
|
||||
m_textureLoader = loader;
|
||||
}
|
||||
|
||||
virtual void LoadTexture( Gwen::Texture* pTexture )
|
||||
{
|
||||
|
||||
@@ -56,6 +56,21 @@ public:
|
||||
{
|
||||
m_keyboardCallback = keyboardCallback;
|
||||
}
|
||||
|
||||
virtual b3MouseMoveCallback getMouseMoveCallback()
|
||||
{
|
||||
return m_mouseMoveCallback;
|
||||
}
|
||||
virtual b3MouseButtonCallback getMouseButtonCallback()
|
||||
{
|
||||
return m_mouseButtonCallback;
|
||||
}
|
||||
virtual b3ResizeCallback getResizeCallback();
|
||||
virtual b3WheelCallback getWheelCallback()
|
||||
{
|
||||
return m_wheelCallback;
|
||||
}
|
||||
|
||||
b3KeyboardCallback getKeyboardCallback()
|
||||
{
|
||||
return m_keyboardCallback;
|
||||
|
||||
@@ -53,6 +53,7 @@ void dumpInfo(void)
|
||||
-(float) GetWindowWidth;
|
||||
-(float) GetWindowHeight;
|
||||
-(void) setResizeCallback:(b3ResizeCallback) callback;
|
||||
-(b3ResizeCallback) getResizeCallback;
|
||||
@end
|
||||
|
||||
float loop;
|
||||
@@ -70,6 +71,11 @@ float loop;
|
||||
return m_lastHeight;
|
||||
}
|
||||
|
||||
-(b3ResizeCallback) getResizeCallback
|
||||
{
|
||||
return m_resizeCallback;
|
||||
}
|
||||
|
||||
-(void)setResizeCallback:(b3ResizeCallback)callback
|
||||
{
|
||||
m_resizeCallback = callback;
|
||||
@@ -1057,4 +1063,7 @@ void MacOpenGLWindow::setResizeCallback(b3ResizeCallback resizeCallback)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
b3ResizeCallback MacOpenGLWindow::getResizeCallback()
|
||||
{
|
||||
return [m_internalData->m_myview getResizeCallback];
|
||||
}
|
||||
|
||||
260
btgui/OpenGLWindow/SimpleCamera.cpp
Normal file
260
btgui/OpenGLWindow/SimpleCamera.cpp
Normal file
@@ -0,0 +1,260 @@
|
||||
#include "OpenGLWindow/SimpleCamera.h"
|
||||
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
#include "Bullet3Common/b3Quaternion.h"
|
||||
#include "Bullet3Common/b3Matrix3x3.h"
|
||||
|
||||
struct SimpleCameraInternalData
|
||||
{
|
||||
SimpleCameraInternalData()
|
||||
:m_cameraTargetPosition(b3MakeVector3(0,0,0)),
|
||||
m_cameraDistance(20),
|
||||
m_cameraUp(b3MakeVector3(0,1,0)),
|
||||
m_cameraUpAxis(1),
|
||||
m_cameraForward(b3MakeVector3(1,0,0)),
|
||||
m_frustumZNear(1),
|
||||
m_frustumZFar(10000),
|
||||
m_yaw(20),
|
||||
m_pitch(0),
|
||||
m_aspect(1)
|
||||
{
|
||||
}
|
||||
b3Vector3 m_cameraTargetPosition;
|
||||
float m_cameraDistance;
|
||||
b3Vector3 m_cameraUp;
|
||||
b3Vector3 m_cameraForward;
|
||||
int m_cameraUpAxis;
|
||||
//the m_cameraPosition is a cached value, recomputed from other values
|
||||
b3Vector3 m_cameraPosition;
|
||||
float m_yaw;
|
||||
|
||||
float m_pitch;
|
||||
float m_aspect;
|
||||
float m_frustumZNear;
|
||||
float m_frustumZFar;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
SimpleCamera::SimpleCamera()
|
||||
{
|
||||
m_data = new SimpleCameraInternalData;
|
||||
}
|
||||
SimpleCamera::~SimpleCamera()
|
||||
{
|
||||
delete m_data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void b3CreateFrustum(
|
||||
float left,
|
||||
float right,
|
||||
float bottom,
|
||||
float top,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
float frustum[16])
|
||||
{
|
||||
|
||||
frustum[0*4+0] = (float(2) * nearVal) / (right - left);
|
||||
frustum[0*4+1] = float(0);
|
||||
frustum[0*4+2] = float(0);
|
||||
frustum[0*4+3] = float(0);
|
||||
|
||||
frustum[1*4+0] = float(0);
|
||||
frustum[1*4+1] = (float(2) * nearVal) / (top - bottom);
|
||||
frustum[1*4+2] = float(0);
|
||||
frustum[1*4+3] = float(0);
|
||||
|
||||
frustum[2*4+0] = (right + left) / (right - left);
|
||||
frustum[2*4+1] = (top + bottom) / (top - bottom);
|
||||
frustum[2*4+2] = -(farVal + nearVal) / (farVal - nearVal);
|
||||
frustum[2*4+3] = float(-1);
|
||||
|
||||
frustum[3*4+0] = float(0);
|
||||
frustum[3*4+1] = float(0);
|
||||
frustum[3*4+2] = -(float(2) * farVal * nearVal) / (farVal - nearVal);
|
||||
frustum[3*4+3] = float(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void b3CreateDiagonalMatrix(float value, float result[4][4])
|
||||
{
|
||||
for (int i=0;i<4;i++)
|
||||
{
|
||||
for (int j=0;j<4;j++)
|
||||
{
|
||||
if (i==j)
|
||||
{
|
||||
result[i][j] = value;
|
||||
} else
|
||||
{
|
||||
result[i][j] = 0.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void b3CreateOrtho(float left, float right, float bottom, float top, float zNear, float zFar, float result[4][4])
|
||||
{
|
||||
b3CreateDiagonalMatrix(1.f,result);
|
||||
|
||||
result[0][0] = 2.f / (right - left);
|
||||
result[1][1] = 2.f / (top - bottom);
|
||||
result[2][2] = - 2.f / (zFar - zNear);
|
||||
result[3][0] = - (right + left) / (right - left);
|
||||
result[3][1] = - (top + bottom) / (top - bottom);
|
||||
result[3][2] = - (zFar + zNear) / (zFar - zNear);
|
||||
}
|
||||
|
||||
static void b3CreateLookAt(const b3Vector3& eye, const b3Vector3& center,const b3Vector3& up, float result[16])
|
||||
{
|
||||
b3Vector3 f = (center - eye).normalized();
|
||||
b3Vector3 u = up.normalized();
|
||||
b3Vector3 s = (f.cross(u)).normalized();
|
||||
u = s.cross(f);
|
||||
|
||||
result[0*4+0] = s.x;
|
||||
result[1*4+0] = s.y;
|
||||
result[2*4+0] = s.z;
|
||||
|
||||
result[0*4+1] = u.x;
|
||||
result[1*4+1] = u.y;
|
||||
result[2*4+1] = u.z;
|
||||
|
||||
result[0*4+2] =-f.x;
|
||||
result[1*4+2] =-f.y;
|
||||
result[2*4+2] =-f.z;
|
||||
|
||||
result[0*4+3] = 0.f;
|
||||
result[1*4+3] = 0.f;
|
||||
result[2*4+3] = 0.f;
|
||||
|
||||
result[3*4+0] = -s.dot(eye);
|
||||
result[3*4+1] = -u.dot(eye);
|
||||
result[3*4+2] = f.dot(eye);
|
||||
result[3*4+3] = 1.f;
|
||||
}
|
||||
|
||||
void SimpleCamera::setCameraUpAxis(int upAxis)
|
||||
{
|
||||
m_data->m_cameraUpAxis = upAxis;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void SimpleCamera::update()
|
||||
{
|
||||
|
||||
int forwardAxis(-1);
|
||||
switch (m_data->m_cameraUpAxis)
|
||||
{
|
||||
case 1:
|
||||
forwardAxis = 2;
|
||||
m_data->m_cameraUp = b3MakeVector3(0,1,0);
|
||||
//gLightPos = b3MakeVector3(-50.f,100,30);
|
||||
break;
|
||||
case 2:
|
||||
forwardAxis = 1;
|
||||
m_data->m_cameraUp = b3MakeVector3(0,0,1);
|
||||
//gLightPos = b3MakeVector3(-50.f,30,100);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
b3Assert(0);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
b3Vector3 eyePos = b3MakeVector3(0,0,0);
|
||||
eyePos[forwardAxis] = -m_data->m_cameraDistance;
|
||||
|
||||
m_data->m_cameraForward = b3MakeVector3(eyePos[0],eyePos[1],eyePos[2]);
|
||||
if (m_data->m_cameraForward.length2() < B3_EPSILON)
|
||||
{
|
||||
m_data->m_cameraForward.setValue(1.f,0.f,0.f);
|
||||
} else
|
||||
{
|
||||
m_data->m_cameraForward.normalize();
|
||||
}
|
||||
|
||||
|
||||
// m_azi=m_azi+0.01;
|
||||
b3Scalar rele = m_data->m_yaw * b3Scalar(0.01745329251994329547);// rads per deg
|
||||
b3Scalar razi = m_data->m_pitch * b3Scalar(0.01745329251994329547);// rads per deg
|
||||
|
||||
|
||||
b3Quaternion rot(m_data->m_cameraUp,razi);
|
||||
|
||||
|
||||
b3Vector3 right = m_data->m_cameraUp.cross(m_data->m_cameraForward);
|
||||
b3Quaternion roll(right,-rele);
|
||||
|
||||
eyePos = b3Matrix3x3(rot) * b3Matrix3x3(roll) * eyePos;
|
||||
|
||||
m_data->m_cameraPosition = eyePos;
|
||||
m_data->m_cameraPosition+= m_data->m_cameraTargetPosition;
|
||||
|
||||
}
|
||||
|
||||
void SimpleCamera::getCameraProjectionMatrix(float projectionMatrix[16]) const
|
||||
{
|
||||
b3CreateFrustum(-m_data->m_aspect * m_data->m_frustumZNear, m_data->m_aspect * m_data->m_frustumZNear, -m_data->m_frustumZNear,m_data->m_frustumZNear, m_data->m_frustumZNear, m_data->m_frustumZFar,projectionMatrix);
|
||||
}
|
||||
void SimpleCamera::getCameraViewMatrix(float viewMatrix[16]) const
|
||||
{
|
||||
b3CreateLookAt(m_data->m_cameraPosition,m_data->m_cameraTargetPosition,m_data->m_cameraUp,viewMatrix);
|
||||
}
|
||||
|
||||
void SimpleCamera::getCameraTargetPosition(float pos[3]) const
|
||||
{
|
||||
pos[0] =m_data->m_cameraTargetPosition[0];
|
||||
pos[1] =m_data->m_cameraTargetPosition[1];
|
||||
pos[2] =m_data->m_cameraTargetPosition[2];
|
||||
}
|
||||
void SimpleCamera::getCameraPosition(float pos[3]) const
|
||||
{
|
||||
pos[0] =m_data->m_cameraPosition[0];
|
||||
pos[1] =m_data->m_cameraPosition[1];
|
||||
pos[2] =m_data->m_cameraPosition[2];
|
||||
}
|
||||
|
||||
void SimpleCamera::setCameraTargetPosition(float x,float y,float z)
|
||||
{
|
||||
m_data->m_cameraTargetPosition.setValue(x,y,z);
|
||||
update();
|
||||
}
|
||||
void SimpleCamera::setCameraDistance(float dist)
|
||||
{
|
||||
m_data->m_cameraDistance = dist;
|
||||
update();
|
||||
}
|
||||
void SimpleCamera::setCameraUpVector(float x,float y ,float z)
|
||||
{
|
||||
m_data->m_cameraUp.setValue(x,y,z);
|
||||
update();
|
||||
}
|
||||
|
||||
void SimpleCamera::setCameraYaw(float yaw)
|
||||
{
|
||||
m_data->m_yaw = yaw;
|
||||
update();
|
||||
}
|
||||
|
||||
void SimpleCamera::setCameraPitch(float pitch)
|
||||
{
|
||||
m_data->m_pitch = pitch;
|
||||
update();
|
||||
}
|
||||
|
||||
void SimpleCamera::setAspectRatio(float ratio)
|
||||
{
|
||||
m_data->m_aspect = ratio;
|
||||
update();
|
||||
}
|
||||
36
btgui/OpenGLWindow/SimpleCamera.h
Normal file
36
btgui/OpenGLWindow/SimpleCamera.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef SIMPLE_CAMERA_H
|
||||
#define SIMPLE_CAMERA_H
|
||||
|
||||
struct CommonCameraInterface
|
||||
{
|
||||
virtual void getCameraProjectionMatrix(float m[16])const = 0;
|
||||
virtual void getCameraViewMatrix(float m[16]) const = 0;
|
||||
};
|
||||
|
||||
struct SimpleCamera : public CommonCameraInterface
|
||||
{
|
||||
struct SimpleCameraInternalData* m_data;
|
||||
|
||||
SimpleCamera();
|
||||
virtual ~SimpleCamera();
|
||||
|
||||
void update();
|
||||
virtual void getCameraProjectionMatrix(float m[16]) const;
|
||||
virtual void getCameraViewMatrix(float m[16]) const;
|
||||
|
||||
virtual void getCameraTargetPosition(float pos[3]) const;
|
||||
virtual void getCameraPosition(float pos[3]) const;
|
||||
|
||||
virtual void setCameraTargetPosition(float x,float y,float z);
|
||||
virtual void setCameraDistance(float dist);
|
||||
virtual void setCameraUpVector(float x,float y, float z);
|
||||
///the setCameraUpAxis will call the 'setCameraUpVector' and 'setCameraForwardVector'
|
||||
virtual void setCameraUpAxis(int axis);
|
||||
virtual void setCameraYaw(float yaw);
|
||||
|
||||
virtual void setCameraPitch(float pitch);
|
||||
virtual void setAspectRatio(float ratio);
|
||||
|
||||
};
|
||||
|
||||
#endif //SIMPLE_CAMERA_H
|
||||
196
btgui/OpenGLWindow/SimpleOpenGL2App.cpp
Normal file
196
btgui/OpenGLWindow/SimpleOpenGL2App.cpp
Normal file
@@ -0,0 +1,196 @@
|
||||
#include "OpenGLWindow/SimpleOpenGL2App.h"
|
||||
#include "OpenGLWindow/OpenGLInclude.h"
|
||||
|
||||
#include "Bullet3Common/b3Logging.h"//b3Assert?
|
||||
#include "Bullet3Common/b3Scalar.h"
|
||||
#include "Bullet3Common/b3AlignedObjectArray.h"
|
||||
#include "Bullet3Common/b3Vector3.h"
|
||||
|
||||
|
||||
#include "stdlib.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "OpenGLWindow/MacOpenGLWindow.h"
|
||||
#else
|
||||
|
||||
#include "OpenGLWindow/GlewWindows/GL/glew.h"
|
||||
//#include "GL/glew.h"
|
||||
#ifdef _WIN32
|
||||
#include "OpenGLWindow/Win32OpenGLWindow.h"
|
||||
#else
|
||||
//let's cross the fingers it is Linux/X11
|
||||
#include "OpenGLWindow/X11OpenGLWindow.h"
|
||||
#endif //_WIN32
|
||||
#endif//__APPLE__
|
||||
#include <stdio.h>
|
||||
#include "OpenGLWindow/CommonRenderInterface.h"
|
||||
|
||||
struct SimpleOpenGL2AppInternalData
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
SimpleOpenGL2App::SimpleOpenGL2App(const char* title, int width, int height)
|
||||
{
|
||||
m_data = new SimpleOpenGL2AppInternalData;
|
||||
|
||||
m_window = new b3gDefaultOpenGLWindow();
|
||||
b3gWindowConstructionInfo ci;
|
||||
ci.m_title = title;
|
||||
ci.m_openglVersion = 2;
|
||||
ci.m_width = width;
|
||||
ci.m_height = height;
|
||||
m_window->createWindow(ci);
|
||||
|
||||
m_window->setWindowTitle(title);
|
||||
|
||||
#ifndef __APPLE__
|
||||
#ifndef _WIN32
|
||||
//some Linux implementations need the 'glewExperimental' to be true
|
||||
glewExperimental = GL_TRUE;
|
||||
#endif
|
||||
|
||||
|
||||
if (glewInit() != GLEW_OK)
|
||||
{
|
||||
b3Error("glewInit failed");
|
||||
exit(1);
|
||||
}
|
||||
if (!GLEW_VERSION_2_1) // check that the machine supports the 2.1 API.
|
||||
{
|
||||
b3Error("GLEW_VERSION_2_1 needs to support 2_1");
|
||||
exit(1); // or handle the error in a nicer way
|
||||
}
|
||||
|
||||
#endif
|
||||
glGetError();//don't remove this call, it is needed for Ubuntu
|
||||
glClearColor(0.9,0.9,1,1);
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
//m_primRenderer = new GLPrimitiveRenderer(width,height);
|
||||
m_parameterInterface = 0;
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
//m_instancingRenderer = new GLInstancingRenderer(128*1024,32*1024*1024);
|
||||
//m_instancingRenderer->init();
|
||||
//m_instancingRenderer->resize(width,height);
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
//m_instancingRenderer->InitShaders();
|
||||
|
||||
}
|
||||
|
||||
SimpleOpenGL2App::~SimpleOpenGL2App()
|
||||
{
|
||||
delete m_data;
|
||||
}
|
||||
|
||||
void SimpleOpenGL2App::drawGrid(DrawGridData data)
|
||||
{
|
||||
int gridSize = data.gridSize;
|
||||
float upOffset = data.upOffset;
|
||||
int upAxis = data.upAxis;
|
||||
float gridColor[4];
|
||||
gridColor[0] = data.gridColor[0];
|
||||
gridColor[1] = data.gridColor[1];
|
||||
gridColor[2] = data.gridColor[2];
|
||||
gridColor[3] = data.gridColor[3];
|
||||
|
||||
int sideAxis=-1;
|
||||
int forwardAxis=-1;
|
||||
|
||||
switch (upAxis)
|
||||
{
|
||||
case 1:
|
||||
forwardAxis=2;
|
||||
sideAxis=0;
|
||||
break;
|
||||
case 2:
|
||||
forwardAxis=1;
|
||||
sideAxis=0;
|
||||
break;
|
||||
default:
|
||||
b3Assert(0);
|
||||
};
|
||||
//b3Vector3 gridColor = b3MakeVector3(0.5,0.5,0.5);
|
||||
|
||||
b3AlignedObjectArray<unsigned int> indices;
|
||||
b3AlignedObjectArray<b3Vector3> vertices;
|
||||
int lineIndex=0;
|
||||
for(int i=-gridSize;i<=gridSize;i++)
|
||||
{
|
||||
{
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
b3Vector3 from = b3MakeVector3(0,0,0);
|
||||
from[sideAxis] = float(i);
|
||||
from[upAxis] = upOffset;
|
||||
from[forwardAxis] = float(-gridSize);
|
||||
b3Vector3 to=b3MakeVector3(0,0,0);
|
||||
to[sideAxis] = float(i);
|
||||
to[upAxis] = upOffset;
|
||||
to[forwardAxis] = float(gridSize);
|
||||
vertices.push_back(from);
|
||||
indices.push_back(lineIndex++);
|
||||
vertices.push_back(to);
|
||||
indices.push_back(lineIndex++);
|
||||
// m_renderer->drawLine(from,to,gridColor);
|
||||
}
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
{
|
||||
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
b3Vector3 from=b3MakeVector3(0,0,0);
|
||||
from[sideAxis] = float(-gridSize);
|
||||
from[upAxis] = upOffset;
|
||||
from[forwardAxis] = float(i);
|
||||
b3Vector3 to=b3MakeVector3(0,0,0);
|
||||
to[sideAxis] = float(gridSize);
|
||||
to[upAxis] = upOffset;
|
||||
to[forwardAxis] = float(i);
|
||||
vertices.push_back(from);
|
||||
indices.push_back(lineIndex++);
|
||||
vertices.push_back(to);
|
||||
indices.push_back(lineIndex++);
|
||||
// m_renderer->drawLine(from,to,gridColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
m_renderer->drawLines(&vertices[0].x,
|
||||
gridColor,
|
||||
vertices.size(),sizeof(b3Vector3),&indices[0],indices.size(),1);
|
||||
|
||||
|
||||
m_renderer->drawLine(b3MakeVector3(0,0,0),b3MakeVector3(1,0,0),b3MakeVector3(1,0,0),3);
|
||||
m_renderer->drawLine(b3MakeVector3(0,0,0),b3MakeVector3(0,1,0),b3MakeVector3(0,1,0),3);
|
||||
m_renderer->drawLine(b3MakeVector3(0,0,0),b3MakeVector3(0,0,1),b3MakeVector3(0,0,1),3);
|
||||
|
||||
// void GLInstancingRenderer::drawPoints(const float* positions, const float color[4], int numPoints, int pointStrideInBytes, float pointDrawSize)
|
||||
|
||||
//we don't use drawPoints because all points would have the same color
|
||||
// b3Vector3 points[3] = { b3MakeVector3(1, 0, 0), b3MakeVector3(0, 1, 0), b3MakeVector3(0, 0, 1) };
|
||||
// m_instancingRenderer->drawPoints(&points[0].x, b3MakeVector3(1, 0, 0), 3, sizeof(b3Vector3), 6);
|
||||
}
|
||||
void SimpleOpenGL2App::setUpAxis(int axis)
|
||||
{
|
||||
}
|
||||
int SimpleOpenGL2App::getUpAxis() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void SimpleOpenGL2App::swapBuffer()
|
||||
{
|
||||
m_window->endRendering();
|
||||
m_window->startRendering();
|
||||
|
||||
}
|
||||
void SimpleOpenGL2App::drawText( const char* txt, int posX, int posY)
|
||||
{
|
||||
|
||||
}
|
||||
31
btgui/OpenGLWindow/SimpleOpenGL2App.h
Normal file
31
btgui/OpenGLWindow/SimpleOpenGL2App.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef SIMPLE_OPENGL2_APP_H
|
||||
#define SIMPLE_OPENGL2_APP_H
|
||||
|
||||
#include "OpenGLWindow/CommonGraphicsApp.h"
|
||||
|
||||
class SimpleOpenGL2App : public CommonGraphicsApp
|
||||
{
|
||||
protected:
|
||||
struct SimpleOpenGL2AppInternalData* m_data;
|
||||
|
||||
public:
|
||||
SimpleOpenGL2App(const char* title, int width, int height);
|
||||
virtual ~SimpleOpenGL2App();
|
||||
|
||||
virtual void drawGrid(DrawGridData data=DrawGridData());
|
||||
virtual void setUpAxis(int axis);
|
||||
virtual int getUpAxis() const;
|
||||
|
||||
virtual void swapBuffer();
|
||||
virtual void drawText( const char* txt, int posX, int posY);
|
||||
|
||||
virtual int registerCubeShape(float halfExtentsX,float halfExtentsY, float halfExtentsZ)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual int registerGraphicsSphereShape(float radius, bool usePointSprites, int largeSphereThreshold, int mediumSphereThreshold)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif //SIMPLE_OPENGL2_APP_H
|
||||
@@ -140,6 +140,7 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height)
|
||||
b3Assert(glGetError() ==GL_NO_ERROR);
|
||||
|
||||
m_instancingRenderer = new GLInstancingRenderer(128*1024,32*1024*1024);
|
||||
m_renderer = m_instancingRenderer ;
|
||||
m_instancingRenderer->init();
|
||||
m_instancingRenderer->resize(width,height);
|
||||
|
||||
|
||||
@@ -5,33 +5,16 @@
|
||||
#include "OpenGLWindow/GLPrimitiveRenderer.h"
|
||||
#include "OpenGLWindow/b3gWindowInterface.h"
|
||||
|
||||
struct DrawGridData
|
||||
{
|
||||
int gridSize;
|
||||
float upOffset;
|
||||
int upAxis;
|
||||
float gridColor[4];
|
||||
#include "OpenGLWindow/CommonGraphicsApp.h"
|
||||
|
||||
DrawGridData()
|
||||
:gridSize(10),
|
||||
upOffset(0.001f),
|
||||
upAxis(1)
|
||||
{
|
||||
gridColor[0] = 0.6f;
|
||||
gridColor[1] = 0.6f;
|
||||
gridColor[2] = 0.6f;
|
||||
gridColor[3] = 1.f;
|
||||
}
|
||||
};
|
||||
|
||||
struct SimpleOpenGL3App
|
||||
struct SimpleOpenGL3App : public CommonGraphicsApp
|
||||
{
|
||||
struct SimpleInternalData* m_data;
|
||||
|
||||
class b3gWindowInterface* m_window;
|
||||
class GLPrimitiveRenderer* m_primRenderer;
|
||||
class GLInstancingRenderer* m_instancingRenderer;
|
||||
struct CommonParameterInterface* m_parameterInterface;
|
||||
|
||||
|
||||
SimpleOpenGL3App(const char* title, int width,int height);
|
||||
virtual ~SimpleOpenGL3App();
|
||||
@@ -43,11 +26,11 @@ struct SimpleOpenGL3App
|
||||
void dumpFramesToVideo(const char* mp4Filename);
|
||||
|
||||
void drawGrid(DrawGridData data=DrawGridData());
|
||||
void setUpAxis(int axis);
|
||||
int getUpAxis() const;
|
||||
virtual void setUpAxis(int axis);
|
||||
virtual int getUpAxis() const;
|
||||
|
||||
void swapBuffer();
|
||||
void drawText( const char* txt, int posX, int posY);
|
||||
virtual void swapBuffer();
|
||||
virtual void drawText( const char* txt, int posX, int posY);
|
||||
struct sth_stash* getFontStash();
|
||||
|
||||
|
||||
|
||||
@@ -46,8 +46,13 @@ void Win32OpenGLWindow::enableOpenGL()
|
||||
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||
pfd.iPixelType = PFD_TYPE_RGBA;
|
||||
pfd.cColorBits = 32;
|
||||
pfd.cDepthBits = 16;
|
||||
pfd.cStencilBits = 1;
|
||||
pfd.cRedBits = 8;
|
||||
pfd.cGreenBits = 8;
|
||||
pfd.cBlueBits = 8;
|
||||
pfd.cAlphaBits = 8;
|
||||
|
||||
pfd.cDepthBits = 24;
|
||||
pfd.cStencilBits = 8;//1;
|
||||
pfd.iLayerType = PFD_MAIN_PLANE;
|
||||
format = ChoosePixelFormat( m_data->m_hDC, &pfd );
|
||||
SetPixelFormat( m_data->m_hDC, format, &pfd );
|
||||
@@ -115,15 +120,15 @@ void Win32OpenGLWindow::closeWindow()
|
||||
void Win32OpenGLWindow::startRendering()
|
||||
{
|
||||
pumpMessage();
|
||||
//don't clear all 3 buffers because some AMD drivers are buggy
|
||||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); //clear buffers
|
||||
|
||||
//glCullFace(GL_BACK);
|
||||
//glFrontFace(GL_CCW);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -709,5 +709,21 @@ b3KeyboardCallback Win32Window::getKeyboardCallback()
|
||||
return m_data->m_keyboardCallback;
|
||||
}
|
||||
|
||||
b3MouseMoveCallback Win32Window::getMouseMoveCallback()
|
||||
{
|
||||
return m_data->m_mouseMoveCallback;
|
||||
}
|
||||
b3MouseButtonCallback Win32Window::getMouseButtonCallback()
|
||||
{
|
||||
return m_data->m_mouseButtonCallback;
|
||||
}
|
||||
b3ResizeCallback Win32Window::getResizeCallback()
|
||||
{
|
||||
return m_data->m_resizeCallback;
|
||||
}
|
||||
b3WheelCallback Win32Window::getWheelCallback()
|
||||
{
|
||||
return m_data->m_wheelCallback;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,10 @@ public:
|
||||
virtual void setWheelCallback(b3WheelCallback wheelCallback);
|
||||
virtual void setKeyboardCallback( b3KeyboardCallback keyboardCallback);
|
||||
|
||||
virtual b3MouseMoveCallback getMouseMoveCallback();
|
||||
virtual b3MouseButtonCallback getMouseButtonCallback();
|
||||
virtual b3ResizeCallback getResizeCallback();
|
||||
virtual b3WheelCallback getWheelCallback();
|
||||
virtual b3KeyboardCallback getKeyboardCallback();
|
||||
|
||||
virtual void setRenderCallback( b3RenderCallback renderCallback);
|
||||
|
||||
@@ -964,10 +964,29 @@ void X11OpenGLWindow::setKeyboardCallback( b3KeyboardCallback keyboardCallback)
|
||||
|
||||
}
|
||||
|
||||
b3MouseMoveCallback X11OpenGLWindow::getMouseMoveCallback()
|
||||
{
|
||||
return m_data->m_mouseMoveCallback;
|
||||
}
|
||||
b3MouseButtonCallback X11OpenGLWindow::getMouseButtonCallback()
|
||||
{
|
||||
return m_data->m_mouseButtonCallback;
|
||||
}
|
||||
b3ResizeCallback X11OpenGLWindow::getResizeCallback()
|
||||
{
|
||||
return m_data->m_resizeCallback;
|
||||
}
|
||||
b3WheelCallback X11OpenGLWindow::getWheelCallback()
|
||||
{
|
||||
return m_data->m_wheelCallback;
|
||||
}
|
||||
|
||||
|
||||
b3KeyboardCallback X11OpenGLWindow::getKeyboardCallback()
|
||||
{
|
||||
return m_data->m_keyboardCallback;
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int X11OpenGLWindow::fileOpenDialog(char* filename, int maxNameLength)
|
||||
|
||||
@@ -53,6 +53,11 @@ public:
|
||||
virtual void setResizeCallback(b3ResizeCallback resizeCallback);
|
||||
virtual void setWheelCallback(b3WheelCallback wheelCallback);
|
||||
virtual void setKeyboardCallback( b3KeyboardCallback keyboardCallback);
|
||||
|
||||
virtual b3MouseMoveCallback getMouseMoveCallback();
|
||||
virtual b3MouseButtonCallback getMouseButtonCallback();
|
||||
virtual b3ResizeCallback getResizeCallback();
|
||||
virtual b3WheelCallback getWheelCallback();
|
||||
virtual b3KeyboardCallback getKeyboardCallback();
|
||||
|
||||
virtual void setRenderCallback( b3RenderCallback renderCallback);
|
||||
|
||||
@@ -98,9 +98,17 @@ class b3gWindowInterface
|
||||
|
||||
|
||||
virtual void setMouseMoveCallback(b3MouseMoveCallback mouseCallback)=0;
|
||||
virtual b3MouseMoveCallback getMouseMoveCallback()=0;
|
||||
|
||||
virtual void setMouseButtonCallback(b3MouseButtonCallback mouseCallback)=0;
|
||||
virtual b3MouseButtonCallback getMouseButtonCallback()=0;
|
||||
|
||||
virtual void setResizeCallback(b3ResizeCallback resizeCallback)=0;
|
||||
virtual b3ResizeCallback getResizeCallback()=0;
|
||||
|
||||
virtual void setWheelCallback(b3WheelCallback wheelCallback)=0;
|
||||
virtual b3WheelCallback getWheelCallback()=0;
|
||||
|
||||
virtual void setKeyboardCallback( b3KeyboardCallback keyboardCallback)=0;
|
||||
virtual b3KeyboardCallback getKeyboardCallback()=0;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
rem premake4 --with-pe vs2010
|
||||
rem premake4 --bullet2demos vs2010
|
||||
premake4 vs2010
|
||||
|
||||
mkdir vs2010\cache
|
||||
|
||||
Reference in New Issue
Block a user