From 684a9f6a999e45b576923dc4b20e6550444fdaa4 Mon Sep 17 00:00:00 2001 From: erwincoumans Date: Mon, 10 Sep 2018 23:18:34 -0700 Subject: [PATCH] move stb_image/stb_image_write.cpp into a cpp file instead of random files with the magic 'STB_IMAGE_WRITE_IMPLEMENTATION' define move setup.py back to eglRenderer extension, use pkgutil.get_loader('eglRenderer').get_filename() disable dlmopen by default, unless B3_USE_DLMOPEN is defined. --- examples/ExampleBrowser/CMakeLists.txt | 2 +- examples/ExampleBrowser/premake4.lua | 2 +- examples/OpenGLWindow/CMakeLists.txt | 1 + .../OpenGLWindow/GLInstancingRenderer.cpp | 5 +- .../opengl_fontstashcallbacks.cpp | 1 - examples/OpenGLWindow/premake4.lua | 5 +- examples/SharedMemory/b3PluginManager.cpp | 22 +-- .../plugins/eglPlugin/eglRendererPlugin.cpp | 20 +++ .../eglRendererVisualShapeConverter.cpp | 2 +- .../plugins/eglPlugin/premake4.lua | 5 +- examples/SharedMemory/premake4.lua | 3 +- .../stb_image/stb_image_write.cpp | 2 + examples/pybullet/CMakeLists.txt | 1 + examples/pybullet/examples/eglRenderTest.py | 40 ++++++ examples/pybullet/examples/testrender_egl.py | 6 +- examples/pybullet/premake4.lua | 1 + setup.py | 133 +++++++++++++++--- test/GwenOpenGLTest/OpenGLSample.cpp | 2 +- test/GwenOpenGLTest/premake4.lua | 1 + 19 files changed, 210 insertions(+), 44 deletions(-) create mode 100644 examples/ThirdPartyLibs/stb_image/stb_image_write.cpp create mode 100644 examples/pybullet/examples/eglRenderTest.py diff --git a/examples/ExampleBrowser/CMakeLists.txt b/examples/ExampleBrowser/CMakeLists.txt index 2416b51a2..8298f4137 100644 --- a/examples/ExampleBrowser/CMakeLists.txt +++ b/examples/ExampleBrowser/CMakeLists.txt @@ -344,7 +344,7 @@ SET(BulletExampleBrowser_SRCS ../ThirdPartyLibs/stb_image/stb_image.cpp ../ThirdPartyLibs/stb_image/stb_image.h - + ../ThirdPartyLibs/stb_image/stb_image_write.cpp ../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp ../ThirdPartyLibs/tinyxml2/tinyxml2.cpp diff --git a/examples/ExampleBrowser/premake4.lua b/examples/ExampleBrowser/premake4.lua index c6474c6fd..d5f1e02fe 100644 --- a/examples/ExampleBrowser/premake4.lua +++ b/examples/ExampleBrowser/premake4.lua @@ -182,7 +182,7 @@ project "App_BulletExampleBrowser" "../MultiBody/MultiBodyConstraintFeedback.cpp", "../MultiBody/InvertedPendulumPDControl.cpp", "../RigidBody/RigidBodySoftContact.cpp", - "../ThirdPartyLibs/stb_image/*", + "../ThirdPartyLibs/stb_image/stb_image.cpp", "../ThirdPartyLibs/Wavefront/tiny_obj_loader.*", "../ThirdPartyLibs/BussIK/*", "../GyroscopicDemo/GyroscopicSetup.cpp", diff --git a/examples/OpenGLWindow/CMakeLists.txt b/examples/OpenGLWindow/CMakeLists.txt index 35ea9ff3b..91a9a014f 100644 --- a/examples/OpenGLWindow/CMakeLists.txt +++ b/examples/OpenGLWindow/CMakeLists.txt @@ -51,6 +51,7 @@ IF(BUILD_EGL) SET(OpenGLWindow_SRCS ${OpenGLWindow_SRCS} ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad/egl.c) ENDIF(BUILD_EGL) +SET(OpenGLWindow_SRCS ${OpenGLWindow_SRCS} ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/stb_image/stb_image_write.cpp) ADD_LIBRARY(OpenGLWindow ${OpenGLWindow_SRCS} ${OpenGLWindow_HDRS}) diff --git a/examples/OpenGLWindow/GLInstancingRenderer.cpp b/examples/OpenGLWindow/GLInstancingRenderer.cpp index ddea108bb..4f0c3bd1d 100644 --- a/examples/OpenGLWindow/GLInstancingRenderer.cpp +++ b/examples/OpenGLWindow/GLInstancingRenderer.cpp @@ -80,6 +80,7 @@ float shadowMapWorldSize=10; #include "Shaders/linesVS.h" #include "GLRenderToTexture.h" +#include "stb_image/stb_image_write.h" @@ -1542,10 +1543,6 @@ void GLInstancingRenderer::updateCamera(int upAxis) -#ifdef STB_AGAIN // first defn in examples/OpenGLWindow/opengl_fontstashcallbacks.cpp -#define STB_IMAGE_WRITE_IMPLEMENTATION -#endif //STB_AGAIN -#include "stb_image/stb_image_write.h" void writeTextureToPng(int textureWidth, int textureHeight, const char* fileName, int numComponents) { diff --git a/examples/OpenGLWindow/opengl_fontstashcallbacks.cpp b/examples/OpenGLWindow/opengl_fontstashcallbacks.cpp index ba67c064d..13c98f54c 100644 --- a/examples/OpenGLWindow/opengl_fontstashcallbacks.cpp +++ b/examples/OpenGLWindow/opengl_fontstashcallbacks.cpp @@ -9,7 +9,6 @@ #include #include #include -#define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image/stb_image_write.h" diff --git a/examples/OpenGLWindow/premake4.lua b/examples/OpenGLWindow/premake4.lua index e0b163678..d42247d37 100644 --- a/examples/OpenGLWindow/premake4.lua +++ b/examples/OpenGLWindow/premake4.lua @@ -25,9 +25,12 @@ "*.h", "OpenGLWindow/*.c", "OpenGLWindow/*.h", - "OpenGLWindow/GL/*.h" + "OpenGLWindow/GL/*.h", + "../ThirdPartyLibs/stb_image/stb_image_write.cpp", } + + if not os.is("Windows") then excludes { "Win32OpenGLWindow.cpp", diff --git a/examples/SharedMemory/b3PluginManager.cpp b/examples/SharedMemory/b3PluginManager.cpp index b5a34bb37..667aa59d7 100644 --- a/examples/SharedMemory/b3PluginManager.cpp +++ b/examples/SharedMemory/b3PluginManager.cpp @@ -18,13 +18,13 @@ #define B3_DYNLIB_IMPORT GetProcAddress #else #include - + typedef void* B3_DYNLIB_HANDLE; -#ifdef __APPLE__ - #define B3_DYNLIB_OPEN(path) dlopen(path, RTLD_NOW | RTLD_GLOBAL) -#else +#ifdef B3_USE_DLMOPEN #define B3_DYNLIB_OPEN(path) dlmopen(LM_ID_NEWLM, path, RTLD_LAZY) +#else + #define B3_DYNLIB_OPEN(path) dlopen(path, RTLD_NOW | RTLD_GLOBAL) #endif #define B3_DYNLIB_CLOSE dlclose #define B3_DYNLIB_IMPORT dlsym @@ -40,16 +40,16 @@ struct b3Plugin PFN_INIT m_initFunc; PFN_EXIT m_exitFunc; PFN_EXECUTE m_executeCommandFunc; - + PFN_TICK m_preTickFunc; PFN_TICK m_postTickFunc; PFN_TICK m_processNotificationsFunc; PFN_TICK m_processClientCommandsFunc; PFN_GET_RENDER_INTERFACE m_getRendererFunc; - + void* m_userPointer; - + b3Plugin() :m_pluginHandle(0), m_ownsPluginHandle(false), @@ -332,7 +332,7 @@ void b3PluginManager::tickPlugins(double timeStep, b3PluginManagerTickMode tickM { continue; } - + PFN_TICK tick = 0; switch (tickMode) { @@ -355,7 +355,7 @@ void b3PluginManager::tickPlugins(double timeStep, b3PluginManagerTickMode tickM { } } - + if (tick) { b3PluginContext context = { 0 }; @@ -437,7 +437,7 @@ int b3PluginManager::registerStaticLinkedPlugin(const char* pluginPath, PFN_INIT { b3Plugin orgPlugin; - + int pluginUniqueId = m_data->m_plugins.allocHandle(); b3PluginHandle* pluginHandle = m_data->m_plugins.getHandle(pluginUniqueId); pluginHandle->m_pluginHandle = 0; @@ -453,7 +453,7 @@ int b3PluginManager::registerStaticLinkedPlugin(const char* pluginPath, PFN_INIT pluginHandle->m_pluginHandle = 0; pluginHandle->m_pluginPath = pluginPath; pluginHandle->m_userPointer = 0; - + if (pluginHandle->m_processNotificationsFunc) { diff --git a/examples/SharedMemory/plugins/eglPlugin/eglRendererPlugin.cpp b/examples/SharedMemory/plugins/eglPlugin/eglRendererPlugin.cpp index 3ca472901..aee061da9 100644 --- a/examples/SharedMemory/plugins/eglPlugin/eglRendererPlugin.cpp +++ b/examples/SharedMemory/plugins/eglPlugin/eglRendererPlugin.cpp @@ -1,4 +1,12 @@ +#ifdef EGL_ADD_PYTHON_INIT +#if defined(__APPLE__) && (!defined(B3_NO_PYTHON_FRAMEWORK)) +#include +#else +#include +#endif +#endif //EGL_ADD_PYTHON_INIT + //eglRenderer plugin //see Bullet/examples/pybullet/examples/eglRendererTest.py @@ -52,3 +60,15 @@ B3_SHARED_API struct UrdfRenderingInterface* getRenderInterface_eglRendererPlugi return &obj->m_renderer; } + +#ifdef EGL_ADD_PYTHON_INIT +PyMODINIT_FUNC +#if PY_MAJOR_VERSION >= 3 +PyInit_eglRenderer(void) +#else +initeglRenderer(void) +#endif +{ + return 0; +} +#endif //EGL_ADD_PYTHON_INIT diff --git a/examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp b/examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp index f97da5134..de6289ecd 100644 --- a/examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp +++ b/examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp @@ -795,7 +795,7 @@ void EGLRendererVisualShapeConverter::convertVisualShapes( // register mesh to m_instancingRenderer too. int shapeIndex = m_data->m_instancingRenderer->registerShape(&vertices[0].xyzw[0], vertices.size(), &indices[0], indices.size(),B3_GL_TRIANGLES, textureIndex); - btVector3 scaling(1,1,1); + double scaling[3]={1,1,1}; visuals->m_graphicsInstanceId = m_data->m_instancingRenderer->registerGraphicsInstance(shapeIndex, &visualShape.m_localVisualFrame[0], &visualShape.m_localVisualFrame[3], &visualShape.m_rgbaColor[0],scaling); m_data->m_instancingRenderer->writeTransforms(); diff --git a/examples/SharedMemory/plugins/eglPlugin/premake4.lua b/examples/SharedMemory/plugins/eglPlugin/premake4.lua index a7f49943a..1642d665a 100644 --- a/examples/SharedMemory/plugins/eglPlugin/premake4.lua +++ b/examples/SharedMemory/plugins/eglPlugin/premake4.lua @@ -6,7 +6,7 @@ project ("pybullet_eglRendererPlugin") initEGL() includedirs {".","../../../../src", "../../../../examples", - "../../../ThirdPartyLibs", "../../examples/ThirdPartyLibs/glad"} + "../../../ThirdPartyLibs", "../../../ThirdPartyLibs/glad"} defines {"PHYSICS_IN_PROCESS_EXAMPLE_BROWSER", "STB_AGAIN"} hasCL = findOpenCL("clew") @@ -25,7 +25,8 @@ project ("pybullet_eglRendererPlugin") end if os.is("Linux") then - files {"../../../ThirdPartyLibs/glad/glx.c",} + files {"../../../OpenGLWindow/EGLOpenGLWindow.cpp"} + end files { diff --git a/examples/SharedMemory/premake4.lua b/examples/SharedMemory/premake4.lua index 417ff1447..9d4bb28b9 100644 --- a/examples/SharedMemory/premake4.lua +++ b/examples/SharedMemory/premake4.lua @@ -98,7 +98,8 @@ myfiles = "../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp", "../ThirdPartyLibs/tinyxml2/tinyxml2.cpp", "../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp", - "../ThirdPartyLibs/stb_image/stb_image.cpp", + "../ThirdPartyLibs/stb_image/stb_image.cpp", + "../ThirdPartyLibs/stb_image/stb_image_write.cpp", } diff --git a/examples/ThirdPartyLibs/stb_image/stb_image_write.cpp b/examples/ThirdPartyLibs/stb_image/stb_image_write.cpp new file mode 100644 index 000000000..2009b05d5 --- /dev/null +++ b/examples/ThirdPartyLibs/stb_image/stb_image_write.cpp @@ -0,0 +1,2 @@ +#define STB_IMAGE_WRITE_IMPLEMENTATION +#include "stb_image_write.h" \ No newline at end of file diff --git a/examples/pybullet/CMakeLists.txt b/examples/pybullet/CMakeLists.txt index f3cacc5b3..2417a3ab2 100644 --- a/examples/pybullet/CMakeLists.txt +++ b/examples/pybullet/CMakeLists.txt @@ -73,6 +73,7 @@ SET(pybullet_SRCS ../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp ../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h ../../examples/ThirdPartyLibs/stb_image/stb_image.cpp + ../../examples/ThirdPartyLibs/stb_image/stb_image_write.cpp ../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp ../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp ../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp diff --git a/examples/pybullet/examples/eglRenderTest.py b/examples/pybullet/examples/eglRenderTest.py new file mode 100644 index 000000000..8adb64cb9 --- /dev/null +++ b/examples/pybullet/examples/eglRenderTest.py @@ -0,0 +1,40 @@ + +import pybullet as p +import time +import pkgutil +egl = pkgutil.get_loader('eglRenderer') + +p.connect(p.SHARED_MEMORY_SERVER) + +plugin = p.loadPlugin(egl.get_filename(), "_eglRendererPlugin") +print("plugin=",plugin) + +p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 0) +p.configureDebugVisualizer(p.COV_ENABLE_GUI, 0) + +p.setGravity(0,0,-10) +p.loadURDF("plane.urdf",[0,0,-1]) +p.loadURDF("r2d2.urdf") + +pixelWidth = 320 +pixelHeight = 220 +camTargetPos = [0,0,0] +camDistance = 4 +pitch = -10.0 +roll=0 +upAxisIndex = 2 + + +while (p.isConnected()): + + for yaw in range (0,360,10) : + p.stepSimulation() + #viewMatrix = [1.0, 0.0, -0.0, 0.0, -0.0, 0.1736481785774231, -0.9848078489303589, 0.0, 0.0, 0.9848078489303589, 0.1736481785774231, 0.0, -0.0, -5.960464477539063e-08, -4.0, 1.0] + viewMatrix = p.computeViewMatrixFromYawPitchRoll(camTargetPos, camDistance, yaw, pitch, roll, upAxisIndex) + projectionMatrix = [1.0825318098068237, 0.0, 0.0, 0.0, 0.0, 1.732050895690918, 0.0, 0.0, 0.0, 0.0, -1.0002000331878662, -1.0, 0.0, 0.0, -0.020002000033855438, 0.0] + img_arr = p.getCameraImage(pixelWidth, pixelHeight, viewMatrix=viewMatrix, projectionMatrix=projectionMatrix, shadow=1,lightDirection=[1,1,1]) + #time.sleep(.1) + #print("img_arr=",img_arr) + + +p.unloadPlugin(plugin) \ No newline at end of file diff --git a/examples/pybullet/examples/testrender_egl.py b/examples/pybullet/examples/testrender_egl.py index c4947f2b9..1f7fb00ae 100644 --- a/examples/pybullet/examples/testrender_egl.py +++ b/examples/pybullet/examples/testrender_egl.py @@ -9,7 +9,7 @@ import numpy as np import matplotlib.pyplot as plt import pybullet import time - +import pkgutil plt.ion() @@ -20,7 +20,9 @@ ax = plt.gca() pybullet.connect(pybullet.DIRECT) -pybullet.loadPlugin("eglRendererPlugin") +egl = pkgutil.get_loader('eglRenderer') + +pybullet.loadPlugin(egl.get_filename(), "_eglRendererPlugin") pybullet.loadURDF("plane.urdf",[0,0,-1]) pybullet.loadURDF("r2d2.urdf") diff --git a/examples/pybullet/premake4.lua b/examples/pybullet/premake4.lua index 3ee6e9b82..81eb423ea 100644 --- a/examples/pybullet/premake4.lua +++ b/examples/pybullet/premake4.lua @@ -153,6 +153,7 @@ if not _OPTIONS["no-enet"] then "../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp", "../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h", "../../examples/ThirdPartyLibs/stb_image/stb_image.cpp", + "../../examples/ThirdPartyLibs/stb_image/stb_image_write.cpp", "../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp", "../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp", "../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp", diff --git a/setup.py b/setup.py index 296572a94..95ca0e41e 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,33 @@ - from setuptools import find_packages from sys import platform as _platform import sys -import glob +from glob import glob from distutils.core import setup from distutils.extension import Extension from distutils.util import get_platform -from glob import glob + + +# monkey-patch for parallel compilation +import multiprocessing +import multiprocessing.pool +def parallelCCompile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): + # those lines are copied from distutils.ccompiler.CCompiler directly + macros, objects, extra_postargs, pp_opts, build = self._setup_compile(output_dir, macros, include_dirs, sources, depends, extra_postargs) + cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) + # parallel code + N = 2*multiprocessing.cpu_count()# number of parallel compilations + def _single_compile(obj): + try: src, ext = build[obj] + except KeyError: return + self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) + # convert to list, imap is evaluated on-demand + list(multiprocessing.pool.ThreadPool(N).imap(_single_compile,objects)) + return objects +import distutils.ccompiler +distutils.ccompiler.CCompiler.compile=parallelCCompile + #see http://stackoverflow.com/a/8719066/295157 import os @@ -23,7 +42,7 @@ 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 ' +CXX_FLAGS += '-DEGL_ADD_PYTHON_INIT ' # libraries += [current_python] @@ -50,8 +69,6 @@ sources = ["examples/pybullet/pybullet.c"]\ +["examples/TinyRenderer/tgaimage.cpp"]\ +["examples/TinyRenderer/our_gl.cpp"]\ +["examples/TinyRenderer/TinyRenderer.cpp"]\ -+["examples/SharedMemory/plugins/eglPlugin/eglRendererPlugin.cpp"]\ -+["examples/SharedMemory/plugins/eglPlugin/eglRendererVisualShapeConverter.cpp"]\ +["examples/SharedMemory/plugins/pdControlPlugin/pdControlPlugin.cpp"]\ +["examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.cpp"]\ +["examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.cpp"]\ @@ -86,6 +103,7 @@ sources = ["examples/pybullet/pybullet.c"]\ +["examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp"]\ +["examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp"]\ +["examples/ThirdPartyLibs/stb_image/stb_image.cpp"]\ ++["examples/ThirdPartyLibs/stb_image/stb_image_write.cpp"]\ +["examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp"]\ +["examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp"]\ +["examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp"]\ @@ -388,33 +406,93 @@ sources = ["examples/pybullet/pybullet.c"]\ +["examples/ThirdPartyLibs/Gwen/Platforms/Windows.cpp"]\ +["examples/ThirdPartyLibs/Gwen/Renderers/OpenGL_DebugFont.cpp"]\ + + +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/stb_image/stb_image_write.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/OpenGLWindow/GLInstancingRenderer.cpp"]\ ++["examples/OpenGLWindow/GLRenderToTexture.cpp"] \ ++["examples/OpenGLWindow/LoadShader.cpp"] \ ++["src/LinearMath/btQuickprof.cpp"] + + + if _platform == "linux" or _platform == "linux2": - libraries = ['dl','pthread'] + libraries += ['dl','pthread'] CXX_FLAGS += '-D_LINUX ' CXX_FLAGS += '-DGLEW_STATIC ' CXX_FLAGS += '-DGLEW_INIT_OPENGL11_FUNCTIONS=1 ' 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 += '-DBT_USE_EGL ' - CXX_FLAGS += '-fno-inline-functions-called-once' sources = sources + ["examples/ThirdPartyLibs/enet/unix.c"]\ - +["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\ - +["examples/ThirdPartyLibs/glad/gl.c"]\ - +["examples/ThirdPartyLibs/glad/glx.c"]\ - +["examples/ThirdPartyLibs/glad/egl.c"]\ - +["examples/OpenGLWindow/EGLOpenGLWindow.cpp"] - + +["examples/ThirdPartyLibs/glad/gl.c"] + include_dirs += ["examples/ThirdPartyLibs/optionalX11"] + if 'BT_USE_EGL' in CXX_FLAGS: + # linking with bullet's Glew libraries causes segfault + # for some reason. + sources += ['examples/ThirdPartyLibs/glad/egl.c'] + sources += ['examples/OpenGLWindow/EGLOpenGLWindow.cpp'] + egl_renderer_sources = egl_renderer_sources\ + +["examples/OpenGLWindow/EGLOpenGLWindow.cpp"]\ + +['examples/ThirdPartyLibs/glad/egl.c'] + else: + sources = sources + ["examples/ThirdPartyLibs/glad/glx.c"]\ + +["examples/OpenGLWindow/X11OpenGLWindow.cpp"] + egl_renderer_sources = egl_renderer_sources\ + +["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\ + +["examples/ThirdPartyLibs/glad/glx.c"] + elif _platform == "win32": print("win32!") - libraries = ['Ws2_32','Winmm','User32','Opengl32','kernel32','glu32','Gdi32','Comdlg32'] + libraries += ['Ws2_32','Winmm','User32','Opengl32','kernel32','glu32','Gdi32','Comdlg32'] CXX_FLAGS += '-DWIN32 ' CXX_FLAGS += '-DGLEW_STATIC ' sources = sources + ["examples/ThirdPartyLibs/enet/win32.c"]\ +["examples/OpenGLWindow/Win32Window.cpp"]\ +["examples/OpenGLWindow/Win32OpenGLWindow.cpp"]\ +["examples/ThirdPartyLibs/glad/gl.c"] + egl_renderer_sources = egl_renderer_sources\ + +["examples/ThirdPartyLibs/enet/win32.c"]\ + +["examples/OpenGLWindow/Win32Window.cpp"]\ + +["examples/OpenGLWindow/Win32OpenGLWindow.cpp"] elif _platform == "darwin": print("darwin!") os.environ['LDFLAGS'] = '-framework Cocoa -framework OpenGL' @@ -426,9 +504,12 @@ elif _platform == "darwin": +["examples/OpenGLWindow/MacOpenGLWindow.cpp"]\ +["examples/ThirdPartyLibs/glad/gl.c"]\ +["examples/OpenGLWindow/MacOpenGLWindowObjC.m"] + egl_renderer_sources = egl_renderer_sources\ + +["examples/OpenGLWindow/MacOpenGLWindow.cpp"]\ + +["examples/OpenGLWindow/MacOpenGLWindowObjC.m"] else: print("bsd!") - libraries = ['GL','GLEW','pthread'] + libraries += ['GL','GLEW','pthread'] os.environ['LDFLAGS'] = '-L/usr/X11R6/lib' CXX_FLAGS += '-D_BSD ' CXX_FLAGS += '-I/usr/X11R6/include ' @@ -437,7 +518,13 @@ else: sources = ["examples/ThirdPartyLibs/enet/unix.c"]\ +["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\ +["examples/ThirdPartyLibs/glad/gl.c"]\ + +["examples/ThirdPartyLibs/glad/glx.c"]\ + sources + egl_renderer_sources = egl_renderer_sources\ + +["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\ + +["examples/ThirdPartyLibs/glad/gl.c"]\ + +["examples/ThirdPartyLibs/glad/glx.c"] + setup_py_dir = os.path.dirname(os.path.realpath(__file__)) @@ -459,6 +546,16 @@ print("packages") print(find_packages('examples/pybullet/gym')) print("-----") + + +eglRender = Extension("eglRenderer", + sources = egl_renderer_sources, + libraries = libraries, + extra_compile_args=(CXX_FLAGS+'-DBT_USE_EGL ').split(), + include_dirs = include_dirs + ["src","examples", "examples/ThirdPartyLibs","examples/ThirdPartyLibs/glad", "examples/ThirdPartyLibs/enet/include","examples/ThirdPartyLibs/clsocket/src"] + ) + + setup( name = 'pybullet', version='2.1.4', @@ -469,8 +566,8 @@ setup( author_email='erwincoumans@google.com', license='zlib', platforms='any', - keywords=['game development', 'virtual reality', 'physics simulation', 'robotics', 'collision detection', 'opengl'], - ext_modules = [Extension("pybullet", + keywords=['game development', 'virtual reality', 'physics simulation', 'robotics', 'reinforcement learning', 'collision detection', 'opengl'], + ext_modules = [eglRender, Extension("pybullet", sources = sources, libraries = libraries, extra_compile_args=CXX_FLAGS.split(), diff --git a/test/GwenOpenGLTest/OpenGLSample.cpp b/test/GwenOpenGLTest/OpenGLSample.cpp index 4150795c9..1a609a584 100644 --- a/test/GwenOpenGLTest/OpenGLSample.cpp +++ b/test/GwenOpenGLTest/OpenGLSample.cpp @@ -356,7 +356,7 @@ int main() #ifndef _WIN32 //we need glewExperimental on Linux #endif // _WIN32 - gladLoadGLInternalLoader(); + gladLoaderLoadGL(); #endif #endif //B3_USE_GLFW //we ned to call glGetError twice, because of some Ubuntu/Intel/OpenGL issue diff --git a/test/GwenOpenGLTest/premake4.lua b/test/GwenOpenGLTest/premake4.lua index df71f70e6..6bc3a9d19 100644 --- a/test/GwenOpenGLTest/premake4.lua +++ b/test/GwenOpenGLTest/premake4.lua @@ -41,6 +41,7 @@ "../../examples/OpenGLWindow/opengl_fontstashcallbacks.h", "../../examples/Utils/b3Clock.cpp", "../../examples/Utils/b3Clock.h", + "../../examples/ThirdPartyLibs/stb_image/stb_image_write.cpp", "**.cpp", "**.h", }