quick draft implementation for SharedMemoryInProcessPhysicsC_API
This commit is contained in:
41
examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.cpp
Normal file
41
examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
#include "SharedMemoryInProcessPhysicsC_API.h"
|
||||
#include "PhysicsClientSharedMemory.h"
|
||||
#include"ExampleBrowser/InProcessExampleBrowser.h"
|
||||
|
||||
|
||||
class InProcessPhysicsClientSharedMemory : public PhysicsClientSharedMemory
|
||||
{
|
||||
btInProcessExampleBrowserInternalData* m_data;
|
||||
public:
|
||||
|
||||
InProcessPhysicsClientSharedMemory(int argc, char* argv[])
|
||||
{
|
||||
int newargc = argc+2;
|
||||
char** newargv = (char**)malloc(sizeof(void*)*newargc);
|
||||
for (int i=0;i<argc;i++)
|
||||
newargv[i] = argv[i];
|
||||
|
||||
char* t0 = (char*)"--logtostderr";
|
||||
char* t1 = (char*)"--start_demo_name=Physics Server";
|
||||
newargv[argc] = t0;
|
||||
newargv[argc+1] = t1;
|
||||
m_data = btCreateInProcessExampleBrowser(newargc,newargv);
|
||||
}
|
||||
|
||||
virtual ~InProcessPhysicsClientSharedMemory()
|
||||
{
|
||||
btShutDownExampleBrowser(m_data);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnect(int argc, char* argv[])
|
||||
{
|
||||
|
||||
InProcessPhysicsClientSharedMemory* cl = new InProcessPhysicsClientSharedMemory(argc, argv);
|
||||
cl->setSharedMemoryKey(SHARED_MEMORY_KEY);
|
||||
cl->connect();
|
||||
return (b3PhysicsClientHandle ) cl;
|
||||
}
|
||||
|
||||
19
examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.h
Normal file
19
examples/SharedMemory/SharedMemoryInProcessPhysicsC_API.h
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
#ifndef IN_PROCESS_PHYSICS_C_API_H
|
||||
#define IN_PROCESS_PHYSICS_C_API_H
|
||||
|
||||
#include "PhysicsClientC_API.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
///think more about naming. The b3ConnectPhysicsLoopback
|
||||
b3PhysicsClientHandle b3CreateInProcessPhysicsServerAndConnect(int argc, char* argv[]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //IN_PROCESS_PHYSICS_C_API_H
|
||||
Reference in New Issue
Block a user