run GUI on main thread for Mac OSX/__APPLE__, due to OS limitation
add b3CreateInProcessPhysicsServerAndConnectMainThread to test.c
This commit is contained in:
@@ -229,3 +229,46 @@ void btShutDownExampleBrowser(btInProcessExampleBrowserInternalData* data)
|
||||
delete data;
|
||||
}
|
||||
|
||||
struct btInProcessExampleBrowserMainThreadInternalData
|
||||
{
|
||||
ExampleEntries m_examples;
|
||||
DefaultBrowser* m_exampleBrowser;
|
||||
SharedMemoryInterface* m_sharedMem;
|
||||
b3Clock m_clock;
|
||||
};
|
||||
|
||||
btInProcessExampleBrowserMainThreadInternalData* btCreateInProcessExampleBrowserMainThread(int argc,char** argv)
|
||||
{
|
||||
btInProcessExampleBrowserMainThreadInternalData* data = new btInProcessExampleBrowserMainThreadInternalData;
|
||||
data->m_examples.initExampleEntries();
|
||||
data->m_exampleBrowser = new DefaultBrowser(&data->m_examples);
|
||||
data->m_sharedMem = new InProcessMemory;
|
||||
data->m_exampleBrowser->setSharedMemoryInterface(data->m_sharedMem );
|
||||
bool init = data->m_exampleBrowser->init(argc,argv);
|
||||
data->m_clock.reset();
|
||||
return data;
|
||||
}
|
||||
|
||||
bool btIsExampleBrowserMainThreadTerminated(btInProcessExampleBrowserMainThreadInternalData* data)
|
||||
{
|
||||
return data->m_exampleBrowser->requestedExit();
|
||||
}
|
||||
|
||||
void btUpdateInProcessExampleBrowserMainThread(btInProcessExampleBrowserMainThreadInternalData* data)
|
||||
{
|
||||
float deltaTimeInSeconds = data->m_clock.getTimeMicroseconds()/1000000.f;
|
||||
data->m_clock.reset();
|
||||
data->m_exampleBrowser->update(deltaTimeInSeconds);
|
||||
}
|
||||
void btShutDownExampleBrowserMainThread(btInProcessExampleBrowserMainThreadInternalData* data)
|
||||
{
|
||||
|
||||
data->m_exampleBrowser->setSharedMemoryInterface(0);
|
||||
delete data->m_exampleBrowser;
|
||||
delete data;
|
||||
}
|
||||
|
||||
class SharedMemoryInterface* btGetSharedMemoryInterfaceMainThread(btInProcessExampleBrowserMainThreadInternalData* data)
|
||||
{
|
||||
return data->m_sharedMem;
|
||||
}
|
||||
|
||||
@@ -12,4 +12,22 @@ void btShutDownExampleBrowser(btInProcessExampleBrowserInternalData* data);
|
||||
class SharedMemoryInterface* btGetSharedMemoryInterface(btInProcessExampleBrowserInternalData* data);
|
||||
|
||||
|
||||
///////////////////////
|
||||
|
||||
|
||||
struct btInProcessExampleBrowserMainThreadInternalData;
|
||||
|
||||
btInProcessExampleBrowserMainThreadInternalData* btCreateInProcessExampleBrowserMainThread(int argc,char** argv2);
|
||||
|
||||
bool btIsExampleBrowserMainThreadTerminated(btInProcessExampleBrowserMainThreadInternalData* data);
|
||||
|
||||
void btUpdateInProcessExampleBrowserMainThread(btInProcessExampleBrowserMainThreadInternalData* data);
|
||||
|
||||
void btShutDownExampleBrowserMainThread(btInProcessExampleBrowserMainThreadInternalData* data);
|
||||
|
||||
class SharedMemoryInterface* btGetSharedMemoryInterfaceMainThread(btInProcessExampleBrowserMainThreadInternalData* data);
|
||||
|
||||
|
||||
//////////////////////
|
||||
|
||||
#endif //IN_PROCESS_EXAMPLE_BROWSER_H
|
||||
|
||||
@@ -1,4 +1,24 @@
|
||||
|
||||
|
||||
#include "InProcessExampleBrowserMainThread.h"
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
btInProcessExampleBrowserMainThreadInternalData* data = btCreateInProcessExampleBrowserMainThread(argc,argv);
|
||||
|
||||
while (!btIsExampleBrowserMainThreadTerminated(data))
|
||||
{
|
||||
btUpdateInProcessExampleBrowserMainThread(data, 1./60.);
|
||||
}
|
||||
btShutDownExampleBrowserMainThread(data);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
//#define EXAMPLE_CONSOLE_ONLY
|
||||
#ifdef EXAMPLE_CONSOLE_ONLY
|
||||
#include "EmptyBrowser.h"
|
||||
@@ -43,3 +63,4 @@ int main(int argc, char* argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -1,5 +1,63 @@
|
||||
project "App_BulletExampleBrowser"
|
||||
|
||||
language "C++"
|
||||
|
||||
kind "ConsoleApp"
|
||||
|
||||
hasCL = findOpenCL("clew")
|
||||
|
||||
if (hasCL) then
|
||||
|
||||
-- project ("App_Bullet3_OpenCL_Demos_" .. vendor)
|
||||
|
||||
initOpenCL("clew")
|
||||
|
||||
end
|
||||
|
||||
links{"BulletExampleBrowserLib","gwen", "OpenGL_Window","BulletSoftBody", "BulletInverseDynamicsUtils", "BulletInverseDynamics", "BulletDynamics","BulletCollision","LinearMath","Bullet3Common"}
|
||||
initOpenGL()
|
||||
initGlew()
|
||||
|
||||
includedirs {
|
||||
".",
|
||||
"../../src",
|
||||
"../ThirdPartyLibs",
|
||||
}
|
||||
|
||||
|
||||
if os.is("MacOSX") then
|
||||
links{"Cocoa.framework"}
|
||||
end
|
||||
|
||||
if (hasCL) then
|
||||
links {
|
||||
"Bullet3OpenCL_clew",
|
||||
"Bullet3Dynamics",
|
||||
"Bullet3Collision",
|
||||
"Bullet3Geometry",
|
||||
"Bullet3Common",
|
||||
}
|
||||
end
|
||||
|
||||
if _OPTIONS["lua"] then
|
||||
includedirs{"../ThirdPartyLibs/lua-5.2.3/src"}
|
||||
links {"lua-5.2.3"}
|
||||
defines {"ENABLE_LUA"}
|
||||
files {"../LuaDemo/LuaPhysicsSetup.cpp"}
|
||||
end
|
||||
|
||||
files {
|
||||
"main.cpp",
|
||||
"ExampleEntries.cpp",
|
||||
}
|
||||
|
||||
if os.is("Linux") then
|
||||
initX11()
|
||||
end
|
||||
|
||||
|
||||
|
||||
project "BulletExampleBrowserLib"
|
||||
project "BulletExampleBrowserLib"
|
||||
|
||||
hasCL = findOpenCL("clew")
|
||||
|
||||
@@ -145,61 +203,4 @@ if os.is("Linux") then
|
||||
end
|
||||
|
||||
|
||||
project "App_BulletExampleBrowser"
|
||||
|
||||
language "C++"
|
||||
|
||||
kind "ConsoleApp"
|
||||
|
||||
hasCL = findOpenCL("clew")
|
||||
|
||||
if (hasCL) then
|
||||
|
||||
-- project ("App_Bullet3_OpenCL_Demos_" .. vendor)
|
||||
|
||||
initOpenCL("clew")
|
||||
|
||||
end
|
||||
|
||||
links{"BulletExampleBrowserLib","gwen", "OpenGL_Window","BulletSoftBody", "BulletInverseDynamicsUtils", "BulletInverseDynamics", "BulletDynamics","BulletCollision","LinearMath","Bullet3Common"}
|
||||
initOpenGL()
|
||||
initGlew()
|
||||
|
||||
includedirs {
|
||||
".",
|
||||
"../../src",
|
||||
"../ThirdPartyLibs",
|
||||
}
|
||||
|
||||
|
||||
if os.is("MacOSX") then
|
||||
links{"Cocoa.framework"}
|
||||
end
|
||||
|
||||
if (hasCL) then
|
||||
links {
|
||||
"Bullet3OpenCL_clew",
|
||||
"Bullet3Dynamics",
|
||||
"Bullet3Collision",
|
||||
"Bullet3Geometry",
|
||||
"Bullet3Common",
|
||||
}
|
||||
end
|
||||
|
||||
if _OPTIONS["lua"] then
|
||||
includedirs{"../ThirdPartyLibs/lua-5.2.3/src"}
|
||||
links {"lua-5.2.3"}
|
||||
defines {"ENABLE_LUA"}
|
||||
files {"../LuaDemo/LuaPhysicsSetup.cpp"}
|
||||
end
|
||||
|
||||
files {
|
||||
"main.cpp",
|
||||
"ExampleEntries.cpp",
|
||||
}
|
||||
|
||||
if os.is("Linux") then
|
||||
initX11()
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user