make OpenGL2 version work (still very rudimentary, no filled rendering, only debug wireframe)
This commit is contained in:
@@ -32,6 +32,8 @@ struct CommonRenderInterface
|
|||||||
virtual int getScreenWidth() = 0;
|
virtual int getScreenWidth() = 0;
|
||||||
virtual int getScreenHeight() = 0;
|
virtual int getScreenHeight() = 0;
|
||||||
|
|
||||||
|
virtual void resize(int width, int height) = 0;
|
||||||
|
|
||||||
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling)=0;
|
virtual int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling)=0;
|
||||||
virtual int registerGraphicsInstance(int shapeIndex, const double* position, const double* quaternion, const double* color, const double* scaling)=0;
|
virtual int registerGraphicsInstance(int shapeIndex, const double* position, const double* quaternion, const double* color, const double* 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 drawLines(const float* positions, const float color[4], int numPoints, int pointStrideInBytes, const unsigned int* indices, int numIndices, float pointDrawSize)=0;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ static ExampleInterface* sCurrentDemo = 0;
|
|||||||
static b3AlignedObjectArray<const char*> allNames;
|
static b3AlignedObjectArray<const char*> allNames;
|
||||||
|
|
||||||
static class ExampleEntries* gAllExamples=0;
|
static class ExampleEntries* gAllExamples=0;
|
||||||
|
static bool sUseOpenGL2 = false;
|
||||||
bool drawGUI=true;
|
bool drawGUI=true;
|
||||||
extern bool useShadowMap;
|
extern bool useShadowMap;
|
||||||
static bool visualWireframe=false;
|
static bool visualWireframe=false;
|
||||||
@@ -525,9 +525,11 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
|||||||
int height=768;
|
int height=768;
|
||||||
|
|
||||||
SimpleOpenGL3App* simpleApp=0;
|
SimpleOpenGL3App* simpleApp=0;
|
||||||
bool useOpenGL2=false;
|
sUseOpenGL2 =args.CheckCmdLineFlag("opengl2");
|
||||||
if (useOpenGL2)
|
|
||||||
|
if (sUseOpenGL2 )
|
||||||
{
|
{
|
||||||
|
|
||||||
s_app = new SimpleOpenGL2App("AllBullet2Demos",width,height);
|
s_app = new SimpleOpenGL2App("AllBullet2Demos",width,height);
|
||||||
s_app->m_renderer = new SimpleOpenGL2Renderer(width,height);
|
s_app->m_renderer = new SimpleOpenGL2Renderer(width,height);
|
||||||
} else
|
} else
|
||||||
@@ -567,7 +569,7 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
|||||||
GL3TexLoader* myTexLoader = new GL3TexLoader;
|
GL3TexLoader* myTexLoader = new GL3TexLoader;
|
||||||
|
|
||||||
Gwen::Renderer::Base* gwenRenderer = 0;
|
Gwen::Renderer::Base* gwenRenderer = 0;
|
||||||
if (useOpenGL2)
|
if (sUseOpenGL2 )
|
||||||
{
|
{
|
||||||
gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont();
|
gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont();
|
||||||
} else
|
} else
|
||||||
@@ -709,7 +711,10 @@ void OpenGLExampleBrowser::update(float deltaTime)
|
|||||||
if (renderGrid)
|
if (renderGrid)
|
||||||
{
|
{
|
||||||
BT_PROFILE("Draw Grid");
|
BT_PROFILE("Draw Grid");
|
||||||
|
glPolygonOffset(3.0, 3);
|
||||||
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||||
s_app->drawGrid(dg);
|
s_app->drawGrid(dg);
|
||||||
|
|
||||||
}
|
}
|
||||||
static int frameCount = 0;
|
static int frameCount = 0;
|
||||||
frameCount++;
|
frameCount++;
|
||||||
@@ -754,16 +759,17 @@ void OpenGLExampleBrowser::update(float deltaTime)
|
|||||||
// processProfileData(profWindow,false);
|
// processProfileData(profWindow,false);
|
||||||
|
|
||||||
{
|
{
|
||||||
// if (useOpenGL2)
|
if (sUseOpenGL2)
|
||||||
//{
|
{
|
||||||
// saveOpenGLState(width,height);
|
|
||||||
//}
|
saveOpenGLState(s_instancingRenderer->getScreenWidth(),s_instancingRenderer->getScreenHeight());
|
||||||
|
}
|
||||||
BT_PROFILE("Draw Gwen GUI");
|
BT_PROFILE("Draw Gwen GUI");
|
||||||
gui->draw(s_instancingRenderer->getScreenWidth(),s_instancingRenderer->getScreenHeight());
|
gui->draw(s_instancingRenderer->getScreenWidth(),s_instancingRenderer->getScreenHeight());
|
||||||
//if (useOpenGL2)
|
if (sUseOpenGL2)
|
||||||
//{
|
{
|
||||||
// restoreOpenGLState();
|
restoreOpenGLState();
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toggle=1-toggle;
|
toggle=1-toggle;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ subject to the following restrictions:
|
|||||||
#include "btBulletDynamicsCommon.h"
|
#include "btBulletDynamicsCommon.h"
|
||||||
|
|
||||||
#include "LinearMath/btQuickprof.h"
|
#include "LinearMath/btQuickprof.h"
|
||||||
#include "LinearMath/btIDebugDraw.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ void BspDemo::initPhysics(const char* bspfilename)
|
|||||||
m_solver = new btSequentialImpulseConstraintSolver();
|
m_solver = new btSequentialImpulseConstraintSolver();
|
||||||
//ConstraintSolver* solver = new OdeConstraintSolver;
|
//ConstraintSolver* solver = new OdeConstraintSolver;
|
||||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
||||||
|
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
|
||||||
m_dynamicsWorld->setGravity(grav);
|
m_dynamicsWorld->setGravity(grav);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,46 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "../CommonInterfaces/CommonRenderInterface.h"
|
#include "../CommonInterfaces/CommonRenderInterface.h"
|
||||||
|
|
||||||
|
static SimpleOpenGL2App* gApp2=0;
|
||||||
|
|
||||||
|
static void Simple2ResizeCallback( float widthf, float heightf)
|
||||||
|
{
|
||||||
|
int width = (int)widthf;
|
||||||
|
int height = (int)heightf;
|
||||||
|
if (gApp2->m_renderer)
|
||||||
|
gApp2->m_renderer->resize(width,height);
|
||||||
|
//gApp2->m_renderer->setScreenSize(width,height);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Simple2KeyboardCallback(int key, int state)
|
||||||
|
{
|
||||||
|
if (key==B3G_ESCAPE && gApp2 && gApp2->m_window)
|
||||||
|
{
|
||||||
|
gApp2->m_window->setRequestExit();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//gApp2->defaultKeyboardCallback(key,state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Simple2MouseButtonCallback( int button, int state, float x, float y)
|
||||||
|
{
|
||||||
|
gApp2->defaultMouseButtonCallback(button,state,x,y);
|
||||||
|
}
|
||||||
|
void Simple2MouseMoveCallback( float x, float y)
|
||||||
|
{
|
||||||
|
gApp2->defaultMouseMoveCallback(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Simple2WheelCallback( float deltax, float deltay)
|
||||||
|
{
|
||||||
|
gApp2->defaultWheelCallback(deltax,deltay);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct SimpleOpenGL2AppInternalData
|
struct SimpleOpenGL2AppInternalData
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -32,6 +72,7 @@ struct SimpleOpenGL2AppInternalData
|
|||||||
|
|
||||||
SimpleOpenGL2App::SimpleOpenGL2App(const char* title, int width, int height)
|
SimpleOpenGL2App::SimpleOpenGL2App(const char* title, int width, int height)
|
||||||
{
|
{
|
||||||
|
gApp2 = this;
|
||||||
m_data = new SimpleOpenGL2AppInternalData;
|
m_data = new SimpleOpenGL2AppInternalData;
|
||||||
|
|
||||||
m_window = new b3gDefaultOpenGLWindow();
|
m_window = new b3gDefaultOpenGLWindow();
|
||||||
@@ -81,10 +122,17 @@ SimpleOpenGL2App::SimpleOpenGL2App(const char* title, int width, int height)
|
|||||||
|
|
||||||
//m_instancingRenderer->InitShaders();
|
//m_instancingRenderer->InitShaders();
|
||||||
|
|
||||||
|
m_window->setMouseMoveCallback(Simple2MouseMoveCallback);
|
||||||
|
m_window->setMouseButtonCallback(Simple2MouseButtonCallback);
|
||||||
|
m_window->setKeyboardCallback(Simple2KeyboardCallback);
|
||||||
|
m_window->setWheelCallback(Simple2WheelCallback);
|
||||||
|
m_window->setResizeCallback(Simple2ResizeCallback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleOpenGL2App::~SimpleOpenGL2App()
|
SimpleOpenGL2App::~SimpleOpenGL2App()
|
||||||
{
|
{
|
||||||
|
gApp2 = 0;
|
||||||
delete m_data;
|
delete m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,12 @@ struct SimpleOpenGL2Renderer : public CommonRenderInterface
|
|||||||
virtual CommonCameraInterface* getActiveCamera();
|
virtual CommonCameraInterface* getActiveCamera();
|
||||||
virtual void setActiveCamera(CommonCameraInterface* cam);
|
virtual void setActiveCamera(CommonCameraInterface* cam);
|
||||||
|
|
||||||
|
virtual void resize(int width, int height)
|
||||||
|
{
|
||||||
|
m_width = width;
|
||||||
|
m_height = height;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void removeAllInstances();
|
virtual void removeAllInstances();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user