bullet3/examples/CommonInterfaces/CommonExampleInterface.h
erwin coumans 984c880b2c move 'main' functions into a separate folder, to make it easier to create standalone demos (console app without gui, or opengl app, and possibly even other versions, like a software renderer, producing pictures in the cloud)
Add a line in an example cpp file to allow a standalone version.
See examples/BasicExample.cpp: B3_STANDALONE_EXAMPLE(BasicExampleCreateFunc)
2016-05-01 14:52:27 -07:00

65 lines
1.7 KiB
C++

#ifndef COMMON_EXAMPLE_INTERFACE_H
#define COMMON_EXAMPLE_INTERFACE_H
struct CommonExampleOptions
{
struct GUIHelperInterface* m_guiHelper;
//Those are optional, some examples will use them others don't. Each example should work with them being 0.
int m_option;
const char* m_fileName;
class SharedMemoryInterface* m_sharedMem;
CommonExampleOptions(struct GUIHelperInterface* helper, int option=0)
:m_guiHelper(helper),
m_option(option),
m_fileName(0),
m_sharedMem(0)
{
}
};
class CommonExampleInterface
{
public:
typedef class CommonExampleInterface* (CreateFunc)(CommonExampleOptions& options);
virtual ~CommonExampleInterface()
{
}
virtual void initPhysics()=0;
virtual void exitPhysics()=0;
virtual void stepSimulation(float deltaTime)=0;
virtual void renderScene()=0;
virtual void physicsDebugDraw(int debugFlags)=0;//for now we reuse the flags in Bullet/src/LinearMath/btIDebugDraw.h
//reset camera is only called when switching demo. this way you can restart (initPhysics) and watch in a specific location easier
virtual void resetCamera(){};
virtual bool mouseMoveCallback(float x,float y)=0;
virtual bool mouseButtonCallback(int button, int state, float x, float y)=0;
virtual bool keyboardCallback(int key, int state)=0;
};
CommonExampleInterface* StandaloneExampleCreateFunc(CommonExampleOptions& options);
#ifdef B3_USE_STANDALONE_EXAMPLE
#define B3_STANDALONE_EXAMPLE(ExampleFunc) CommonExampleInterface* StandaloneExampleCreateFunc(CommonExampleOptions& options)\
{\
return ExampleFunc(options);\
}
#else//B3_USE_STANDALONE_EXAMPLE
#define B3_STANDALONE_EXAMPLE(ExampleFunc)
#endif //B3_USE_STANDALONE_EXAMPLE
#endif //COMMON_EXAMPLE_INTERFACE_H