diff --git a/examples/OpenGLWindow/SimpleOpenGL3App.cpp b/examples/OpenGLWindow/SimpleOpenGL3App.cpp index baaac584a..a5eedf32c 100644 --- a/examples/OpenGLWindow/SimpleOpenGL3App.cpp +++ b/examples/OpenGLWindow/SimpleOpenGL3App.cpp @@ -4,6 +4,11 @@ #include "ShapeData.h" +#ifdef BT_USE_EGL +#include "EGLOpenGLWindow.h" +#else +#endif //BT_USE_EGL + #ifdef B3_USE_GLFW #include "GLFWOpenGLWindow.h" #else @@ -19,10 +24,6 @@ //let's cross the fingers it is Linux/X11 #include "X11OpenGLWindow.h" #define BT_USE_X11 // for runtime backend selection, move to build? -#ifdef BT_USE_EGL -#include "EGLOpenGLWindow.h" -#else -#endif //BT_USE_EGL #endif //_WIN32 #endif//__APPLE__ #endif //B3_USE_GLFW diff --git a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp index 09bfa5e46..3a837f508 100644 --- a/examples/SharedMemory/PhysicsServerCommandProcessor.cpp +++ b/examples/SharedMemory/PhysicsServerCommandProcessor.cpp @@ -68,6 +68,11 @@ #endif +#ifdef STATIC_EGLRENDERER_PLUGIN +#include "plugins/eglPlugin/eglRendererPlugin.h" +#endif//STATIC_EGLRENDERER_PLUGIN + + #ifndef SKIP_STATIC_TINYRENDERER_PLUGIN #include "plugins/tinyRendererPlugin/tinyRendererPlugin.h" #endif @@ -1709,10 +1714,20 @@ struct PhysicsServerCommandProcessorInternalData } #endif //ENABLE_STATIC_GRPC_PLUGIN +#ifdef STATIC_EGLRENDERER_PLUGIN +{ + int renderPluginId = m_pluginManager.registerStaticLinkedPlugin("eglRendererPlugin", initPlugin_eglRendererPlugin, exitPlugin_eglRendererPlugin, executePluginCommand_eglRendererPlugin,0,0,getRenderInterface_eglRendererPlugin,0); + m_pluginManager.selectPluginRenderer(renderPluginId); +} +#endif//STATIC_EGLRENDERER_PLUGIN + + #ifndef SKIP_STATIC_TINYRENDERER_PLUGIN + { int renderPluginId = m_pluginManager.registerStaticLinkedPlugin("tinyRendererPlugin", initPlugin_tinyRendererPlugin, exitPlugin_tinyRendererPlugin, executePluginCommand_tinyRendererPlugin,0,0,getRenderInterface_tinyRendererPlugin,0); m_pluginManager.selectPluginRenderer(renderPluginId); + } #endif } diff --git a/examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp b/examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp index ce657d8bd..2e764d187 100644 --- a/examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp +++ b/examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp @@ -13,10 +13,6 @@ subject to the following restrictions: #include "eglRendererVisualShapeConverter.h" - - - - #include "../Importers/ImportURDFDemo/URDFImporterInterface.h" #include "btBulletCollisionCommon.h" #include "../Importers/ImportObjDemo/LoadMeshFromObj.h" @@ -251,7 +247,8 @@ void EGLRendererVisualShapeConverter::setLightSpecularCoeff(float specularCoeff) m_data->m_hasLightSpecularCoeff = true; } -void convertURDFToVisualShape(const UrdfShape* visual, const char* urdfPathPrefix, const btTransform& visualTransform, btAlignedObjectArray& verticesOut, btAlignedObjectArray& indicesOut, btAlignedObjectArray& texturesOut, b3VisualShapeData& visualShapeOut) +///todo: merge into single file with TinyRendererVisualShapeConverter +static void convertURDFToVisualShape2(const UrdfShape* visual, const char* urdfPathPrefix, const btTransform& visualTransform, btAlignedObjectArray& verticesOut, btAlignedObjectArray& indicesOut, btAlignedObjectArray& texturesOut, b3VisualShapeData& visualShapeOut) { visualShapeOut.m_visualGeometryType = visual->m_geometry.m_type; @@ -737,8 +734,8 @@ void EGLRendererVisualShapeConverter::convertVisualShapes( visualShape.m_rgbaColor[2] = rgbaColor[2]; visualShape.m_rgbaColor[3] = rgbaColor[3]; { - B3_PROFILE("convertURDFToVisualShape"); - convertURDFToVisualShape(vis, pathPrefix, localInertiaFrame.inverse()*childTrans, vertices, indices, textures, visualShape); + B3_PROFILE("convertURDFToVisualShape2"); + convertURDFToVisualShape2(vis, pathPrefix, localInertiaFrame.inverse()*childTrans, vertices, indices, textures, visualShape); } m_data->m_visualShapes.push_back(visualShape); diff --git a/setup.py b/setup.py index aa92ccdea..3a6a5193a 100644 --- a/setup.py +++ b/setup.py @@ -42,9 +42,11 @@ CXX_FLAGS += '-DBT_USE_DOUBLE_PRECISION ' CXX_FLAGS += '-DBT_ENABLE_ENET ' CXX_FLAGS += '-DBT_ENABLE_CLSOCKET ' CXX_FLAGS += '-DB3_DUMP_PYTHON_VERSION ' +CXX_FLAGS += '-DSTATIC_EGLRENDERER_PLUGIN ' #comment to disable static egl plugin CXX_FLAGS += '-DBT_USE_EGL ' # uncomment for EGL (old EGL versions fail) + # libraries += [current_python] libraries = [] @@ -405,6 +407,12 @@ sources = ["examples/pybullet/pybullet.c"]\ +["examples/ThirdPartyLibs/Gwen/Platforms/Windows.cpp"]\ +["examples/ThirdPartyLibs/Gwen/Renderers/OpenGL_DebugFont.cpp"]\ + +if 'STATIC_EGLRENDERER_PLUGIN' in CXX_FLAGS: + sources += ['examples/SharedMemory/plugins/eglPlugin/eglRendererPlugin.cpp']\ + + ['examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp'] + + if _platform == "linux" or _platform == "linux2": libraries += ['dl','pthread'] CXX_FLAGS += '-D_LINUX ' @@ -413,8 +421,7 @@ if _platform == "linux" or _platform == "linux2": CXX_FLAGS += '-DGLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1 ' CXX_FLAGS += '-DDYNAMIC_LOAD_X11_FUNCTIONS ' CXX_FLAGS += '-DHAS_SOCKLEN_T ' - CXX_FLAGS += '-fno-inline-functions-called-once ' - CXX_FLAGS += '-fPIC ' # for plugins + CXX_FLAGS += '-fno-inline-functions-called-once' sources = sources + ["examples/ThirdPartyLibs/enet/unix.c"]\ +["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\ +["examples/ThirdPartyLibs/glad/gl.c"]\ @@ -430,6 +437,7 @@ elif _platform == "win32": print("win32!") libraries += ['Ws2_32','Winmm','User32','Opengl32','kernel32','glu32','Gdi32','Comdlg32'] CXX_FLAGS += '-DWIN32 ' + CXX_FLAGS += '-D_WIN32 ' CXX_FLAGS += '-DGLEW_STATIC ' sources = sources + ["examples/ThirdPartyLibs/enet/win32.c"]\ +["examples/OpenGLWindow/Win32Window.cpp"]\ @@ -480,56 +488,6 @@ print("packages") print(find_packages('examples/pybullet/gym')) print("-----") -egl_renderer_sources = \ -["examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp"]\ -+["examples/SharedMemory/plugins/eglPlugin/eglRendererPlugin.cpp"]\ -+["examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp"]\ -+["examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp"]\ -+["examples/Importers/ImportMeshUtility/b3ImportMeshUtility.cpp"]\ -+["examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp"]\ -+["examples/TinyRenderer/geometry.cpp"]\ -+["examples/TinyRenderer/model.cpp"]\ -+["examples/TinyRenderer/tgaimage.cpp"]\ -+["examples/TinyRenderer/our_gl.cpp"]\ -+["examples/TinyRenderer/TinyRenderer.cpp"]\ -+["examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp"]\ -+["examples/ThirdPartyLibs/stb_image/stb_image.cpp"]\ -+["examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp"]\ -+["examples/OpenGLWindow/SimpleCamera.cpp"]\ -+["examples/Utils/b3Clock.cpp"]\ -+["examples/Utils/b3ResourcePath.cpp"]\ -+["src/BulletCollision/CollisionShapes/btShapeHull.cpp"]\ -+["src/BulletCollision/CollisionShapes/btConvexHullShape.cpp"]\ -+["src/BulletCollision/CollisionShapes/btBoxShape.cpp"]\ -+["src/BulletCollision/CollisionShapes/btSphereShape.cpp"]\ -+["src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp"]\ -+["src/BulletCollision/CollisionShapes/btConvexShape.cpp"]\ -+["src/BulletCollision/CollisionShapes/btCollisionShape.cpp"]\ -+["src/BulletCollision/CollisionShapes/btConvexPolyhedron.cpp"]\ -+["src/BulletCollision/CollisionShapes/btConvexInternalShape.cpp"]\ -+["src/Bullet3Common/b3Logging.cpp"]\ -+["src/LinearMath/btAlignedAllocator.cpp"]\ -+["src/LinearMath/btGeometryUtil.cpp"]\ -+["src/LinearMath/btConvexHull.cpp"]\ -+["src/LinearMath/btConvexHullComputer.cpp"]\ -+["src/Bullet3Common/b3AlignedAllocator.cpp"] \ -+["examples/ThirdPartyLibs/glad/gl.c"]\ -+['examples/ThirdPartyLibs/glad/egl.c'] \ -+["examples/ThirdPartyLibs/glad/glx.c"] \ -+["examples/OpenGLWindow/GLInstancingRenderer.cpp"]\ -+["examples/OpenGLWindow/EGLOpenGLWindow.cpp"]\ -+["examples/OpenGLWindow/GLRenderToTexture.cpp"] \ -+["examples/OpenGLWindow/LoadShader.cpp"] \ -+["src/LinearMath/btQuickprof.cpp"] \ - -eglRender = Extension("eglRenderer", - sources = egl_renderer_sources, - libraries = libraries, - extra_compile_args=(CXX_FLAGS+'-DBT_USE_EGL -DSTB_AGAIN -DB3_DEBUG').split(), - include_dirs = include_dirs + ["src","examples/ThirdPartyLibs","examples/ThirdPartyLibs/glad", "examples/ThirdPartyLibs/enet/include","examples/ThirdPartyLibs/clsocket/src"] - ) - - setup( name = 'pybullet', version='2.1.4', @@ -541,7 +499,7 @@ setup( license='zlib', platforms='any', keywords=['game development', 'virtual reality', 'physics simulation', 'robotics', 'collision detection', 'opengl'], - ext_modules = [eglRender, Extension("pybullet", + ext_modules = [Extension("pybullet", sources = sources, libraries = libraries, extra_compile_args=CXX_FLAGS.split(), @@ -564,4 +522,4 @@ setup( package_dir = { '': 'examples/pybullet/gym'}, packages=[x for x in find_packages('examples/pybullet/gym')], package_data = { 'pybullet_data': need_files } -) +) \ No newline at end of file