decouple some dependency using a callback.
This commit is contained in:
@@ -12,6 +12,10 @@ struct CommonParameterInterface;
|
||||
struct CommonRenderInterface;
|
||||
struct CommonGraphicsApp;
|
||||
|
||||
|
||||
|
||||
typedef void (*VisualizerFlagCallback)(int flag, bool enable);
|
||||
|
||||
///The Bullet 2 GraphicsPhysicsBridge let's the graphics engine create graphics representation and synchronize
|
||||
struct GUIHelperInterface
|
||||
{
|
||||
@@ -79,6 +83,7 @@ struct GUIHelperInterface
|
||||
|
||||
virtual void removeUserDebugItem( int debugItemUniqueId){};
|
||||
virtual void removeAllUserDebugItems( ){};
|
||||
virtual void setVisualizerFlagCallback(VisualizerFlagCallback callback){}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -358,6 +358,24 @@ void OpenGLExampleBrowser::registerFileImporter(const char* extension, CommonExa
|
||||
fi.m_createFunc = createFunc;
|
||||
gFileImporterByExtension.push_back(fi);
|
||||
}
|
||||
#include "../SharedMemory/SharedMemoryPublic.h"
|
||||
|
||||
void OpenGLExampleBrowserVisualizerFlagCallback(int flag, bool enable)
|
||||
{
|
||||
if (flag == COV_ENABLE_SHADOWS)
|
||||
{
|
||||
useShadowMap = enable;
|
||||
}
|
||||
if (flag == COV_ENABLE_GUI)
|
||||
{
|
||||
renderGui = enable;
|
||||
}
|
||||
|
||||
if (flag == COV_ENABLE_WIREFRAME)
|
||||
{
|
||||
visualWireframe = enable;
|
||||
}
|
||||
}
|
||||
|
||||
void openFileDemo(const char* filename)
|
||||
{
|
||||
@@ -365,6 +383,8 @@ void openFileDemo(const char* filename)
|
||||
deleteDemo();
|
||||
|
||||
s_guiHelper= new OpenGLGuiHelper(s_app, sUseOpenGL2);
|
||||
s_guiHelper->setVisualizerFlagCallback(OpenGLExampleBrowserVisualizerFlagCallback);
|
||||
|
||||
s_parameterInterface->removeAllParameters();
|
||||
|
||||
|
||||
@@ -419,6 +439,8 @@ void selectDemo(int demoIndex)
|
||||
}
|
||||
int option = gAllExamples->getExampleOption(demoIndex);
|
||||
s_guiHelper= new OpenGLGuiHelper(s_app, sUseOpenGL2);
|
||||
s_guiHelper->setVisualizerFlagCallback(OpenGLExampleBrowserVisualizerFlagCallback);
|
||||
|
||||
CommonExampleOptions options(s_guiHelper, option);
|
||||
options.m_sharedMem = sSharedMem;
|
||||
sCurrentDemo = (*func)(options);
|
||||
|
||||
@@ -154,9 +154,11 @@ struct OpenGLGuiHelperInternalData
|
||||
btAlignedObjectArray<unsigned char> m_rgbaPixelBuffer1;
|
||||
btAlignedObjectArray<float> m_depthBuffer1;
|
||||
|
||||
VisualizerFlagCallback m_visualizerFlagCallback;
|
||||
OpenGLGuiHelperInternalData()
|
||||
:m_vrMode(false),
|
||||
m_vrSkipShadowPass(0)
|
||||
m_vrSkipShadowPass(0),
|
||||
m_visualizerFlagCallback(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -374,27 +376,17 @@ void OpenGLGuiHelper::setUpAxis(int axis)
|
||||
|
||||
}
|
||||
|
||||
extern bool useShadowMap;
|
||||
extern bool visualWireframe;
|
||||
extern bool renderGui;
|
||||
#include "../SharedMemory/SharedMemoryPublic.h"
|
||||
|
||||
void OpenGLGuiHelper::setVisualizerFlagCallback(VisualizerFlagCallback callback)
|
||||
{
|
||||
m_data->m_visualizerFlagCallback = callback;
|
||||
}
|
||||
|
||||
|
||||
void OpenGLGuiHelper::setVisualizerFlag(int flag, int enable)
|
||||
{
|
||||
//temporary direct access
|
||||
if (flag == COV_ENABLE_SHADOWS)
|
||||
{
|
||||
useShadowMap = enable;
|
||||
}
|
||||
if (flag == COV_ENABLE_GUI)
|
||||
{
|
||||
renderGui = enable;
|
||||
}
|
||||
|
||||
if (flag == COV_ENABLE_WIREFRAME)
|
||||
{
|
||||
visualWireframe = enable;
|
||||
}
|
||||
if (m_data->m_visualizerFlagCallback)
|
||||
(m_data->m_visualizerFlagCallback)(flag,enable);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ struct OpenGLGuiHelper : public GUIHelperInterface
|
||||
|
||||
virtual void setUpAxis(int axis);
|
||||
|
||||
void setVisualizerFlag(int flag, int enable);
|
||||
|
||||
virtual void resetCamera(float camDist, float pitch, float yaw, float camPosX,float camPosY, float camPosZ);
|
||||
|
||||
@@ -82,6 +81,9 @@ struct OpenGLGuiHelper : public GUIHelperInterface
|
||||
|
||||
void setVRMode(bool vrMode);
|
||||
|
||||
void setVisualizerFlag(int flag, int enable);
|
||||
|
||||
virtual void setVisualizerFlagCallback(VisualizerFlagCallback callback);
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user