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.
This commit is contained in:
erwincoumans
2018-09-10 23:18:34 -07:00
parent f26d4fdc4c
commit 684a9f6a99
19 changed files with 210 additions and 44 deletions

View File

@@ -344,7 +344,7 @@ SET(BulletExampleBrowser_SRCS
../ThirdPartyLibs/stb_image/stb_image.cpp ../ThirdPartyLibs/stb_image/stb_image.cpp
../ThirdPartyLibs/stb_image/stb_image.h ../ThirdPartyLibs/stb_image/stb_image.h
../ThirdPartyLibs/stb_image/stb_image_write.cpp
../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp ../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp
../ThirdPartyLibs/tinyxml2/tinyxml2.cpp ../ThirdPartyLibs/tinyxml2/tinyxml2.cpp

View File

@@ -182,7 +182,7 @@ project "App_BulletExampleBrowser"
"../MultiBody/MultiBodyConstraintFeedback.cpp", "../MultiBody/MultiBodyConstraintFeedback.cpp",
"../MultiBody/InvertedPendulumPDControl.cpp", "../MultiBody/InvertedPendulumPDControl.cpp",
"../RigidBody/RigidBodySoftContact.cpp", "../RigidBody/RigidBodySoftContact.cpp",
"../ThirdPartyLibs/stb_image/*", "../ThirdPartyLibs/stb_image/stb_image.cpp",
"../ThirdPartyLibs/Wavefront/tiny_obj_loader.*", "../ThirdPartyLibs/Wavefront/tiny_obj_loader.*",
"../ThirdPartyLibs/BussIK/*", "../ThirdPartyLibs/BussIK/*",
"../GyroscopicDemo/GyroscopicSetup.cpp", "../GyroscopicDemo/GyroscopicSetup.cpp",

View File

@@ -51,6 +51,7 @@ IF(BUILD_EGL)
SET(OpenGLWindow_SRCS ${OpenGLWindow_SRCS} ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad/egl.c) SET(OpenGLWindow_SRCS ${OpenGLWindow_SRCS} ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/glad/egl.c)
ENDIF(BUILD_EGL) 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}) ADD_LIBRARY(OpenGLWindow ${OpenGLWindow_SRCS} ${OpenGLWindow_HDRS})

View File

@@ -80,6 +80,7 @@ float shadowMapWorldSize=10;
#include "Shaders/linesVS.h" #include "Shaders/linesVS.h"
#include "GLRenderToTexture.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) void writeTextureToPng(int textureWidth, int textureHeight, const char* fileName, int numComponents)
{ {

View File

@@ -9,7 +9,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image/stb_image_write.h" #include "stb_image/stb_image_write.h"

View File

@@ -25,9 +25,12 @@
"*.h", "*.h",
"OpenGLWindow/*.c", "OpenGLWindow/*.c",
"OpenGLWindow/*.h", "OpenGLWindow/*.h",
"OpenGLWindow/GL/*.h" "OpenGLWindow/GL/*.h",
"../ThirdPartyLibs/stb_image/stb_image_write.cpp",
} }
if not os.is("Windows") then if not os.is("Windows") then
excludes { excludes {
"Win32OpenGLWindow.cpp", "Win32OpenGLWindow.cpp",

View File

@@ -18,13 +18,13 @@
#define B3_DYNLIB_IMPORT GetProcAddress #define B3_DYNLIB_IMPORT GetProcAddress
#else #else
#include <dlfcn.h> #include <dlfcn.h>
typedef void* B3_DYNLIB_HANDLE; typedef void* B3_DYNLIB_HANDLE;
#ifdef __APPLE__ #ifdef B3_USE_DLMOPEN
#define B3_DYNLIB_OPEN(path) dlopen(path, RTLD_NOW | RTLD_GLOBAL)
#else
#define B3_DYNLIB_OPEN(path) dlmopen(LM_ID_NEWLM, path, RTLD_LAZY) #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 #endif
#define B3_DYNLIB_CLOSE dlclose #define B3_DYNLIB_CLOSE dlclose
#define B3_DYNLIB_IMPORT dlsym #define B3_DYNLIB_IMPORT dlsym
@@ -40,16 +40,16 @@ struct b3Plugin
PFN_INIT m_initFunc; PFN_INIT m_initFunc;
PFN_EXIT m_exitFunc; PFN_EXIT m_exitFunc;
PFN_EXECUTE m_executeCommandFunc; PFN_EXECUTE m_executeCommandFunc;
PFN_TICK m_preTickFunc; PFN_TICK m_preTickFunc;
PFN_TICK m_postTickFunc; PFN_TICK m_postTickFunc;
PFN_TICK m_processNotificationsFunc; PFN_TICK m_processNotificationsFunc;
PFN_TICK m_processClientCommandsFunc; PFN_TICK m_processClientCommandsFunc;
PFN_GET_RENDER_INTERFACE m_getRendererFunc; PFN_GET_RENDER_INTERFACE m_getRendererFunc;
void* m_userPointer; void* m_userPointer;
b3Plugin() b3Plugin()
:m_pluginHandle(0), :m_pluginHandle(0),
m_ownsPluginHandle(false), m_ownsPluginHandle(false),
@@ -332,7 +332,7 @@ void b3PluginManager::tickPlugins(double timeStep, b3PluginManagerTickMode tickM
{ {
continue; continue;
} }
PFN_TICK tick = 0; PFN_TICK tick = 0;
switch (tickMode) switch (tickMode)
{ {
@@ -355,7 +355,7 @@ void b3PluginManager::tickPlugins(double timeStep, b3PluginManagerTickMode tickM
{ {
} }
} }
if (tick) if (tick)
{ {
b3PluginContext context = { 0 }; b3PluginContext context = { 0 };
@@ -437,7 +437,7 @@ int b3PluginManager::registerStaticLinkedPlugin(const char* pluginPath, PFN_INIT
{ {
b3Plugin orgPlugin; b3Plugin orgPlugin;
int pluginUniqueId = m_data->m_plugins.allocHandle(); int pluginUniqueId = m_data->m_plugins.allocHandle();
b3PluginHandle* pluginHandle = m_data->m_plugins.getHandle(pluginUniqueId); b3PluginHandle* pluginHandle = m_data->m_plugins.getHandle(pluginUniqueId);
pluginHandle->m_pluginHandle = 0; pluginHandle->m_pluginHandle = 0;
@@ -453,7 +453,7 @@ int b3PluginManager::registerStaticLinkedPlugin(const char* pluginPath, PFN_INIT
pluginHandle->m_pluginHandle = 0; pluginHandle->m_pluginHandle = 0;
pluginHandle->m_pluginPath = pluginPath; pluginHandle->m_pluginPath = pluginPath;
pluginHandle->m_userPointer = 0; pluginHandle->m_userPointer = 0;
if (pluginHandle->m_processNotificationsFunc) if (pluginHandle->m_processNotificationsFunc)
{ {

View File

@@ -1,4 +1,12 @@
#ifdef EGL_ADD_PYTHON_INIT
#if defined(__APPLE__) && (!defined(B3_NO_PYTHON_FRAMEWORK))
#include <Python/Python.h>
#else
#include <Python.h>
#endif
#endif //EGL_ADD_PYTHON_INIT
//eglRenderer plugin //eglRenderer plugin
//see Bullet/examples/pybullet/examples/eglRendererTest.py //see Bullet/examples/pybullet/examples/eglRendererTest.py
@@ -52,3 +60,15 @@ B3_SHARED_API struct UrdfRenderingInterface* getRenderInterface_eglRendererPlugi
return &obj->m_renderer; 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

View File

@@ -795,7 +795,7 @@ void EGLRendererVisualShapeConverter::convertVisualShapes(
// register mesh to m_instancingRenderer too. // 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); 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); 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(); m_data->m_instancingRenderer->writeTransforms();

View File

@@ -6,7 +6,7 @@ project ("pybullet_eglRendererPlugin")
initEGL() initEGL()
includedirs {".","../../../../src", "../../../../examples", includedirs {".","../../../../src", "../../../../examples",
"../../../ThirdPartyLibs", "../../examples/ThirdPartyLibs/glad"} "../../../ThirdPartyLibs", "../../../ThirdPartyLibs/glad"}
defines {"PHYSICS_IN_PROCESS_EXAMPLE_BROWSER", "STB_AGAIN"} defines {"PHYSICS_IN_PROCESS_EXAMPLE_BROWSER", "STB_AGAIN"}
hasCL = findOpenCL("clew") hasCL = findOpenCL("clew")
@@ -25,7 +25,8 @@ project ("pybullet_eglRendererPlugin")
end end
if os.is("Linux") then if os.is("Linux") then
files {"../../../ThirdPartyLibs/glad/glx.c",} files {"../../../OpenGLWindow/EGLOpenGLWindow.cpp"}
end end
files { files {

View File

@@ -98,7 +98,8 @@ myfiles =
"../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp", "../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp",
"../ThirdPartyLibs/tinyxml2/tinyxml2.cpp", "../ThirdPartyLibs/tinyxml2/tinyxml2.cpp",
"../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp", "../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
"../ThirdPartyLibs/stb_image/stb_image.cpp", "../ThirdPartyLibs/stb_image/stb_image.cpp",
"../ThirdPartyLibs/stb_image/stb_image_write.cpp",
} }

View File

@@ -0,0 +1,2 @@
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"

View File

@@ -73,6 +73,7 @@ SET(pybullet_SRCS
../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp ../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp
../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h ../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h
../../examples/ThirdPartyLibs/stb_image/stb_image.cpp ../../examples/ThirdPartyLibs/stb_image/stb_image.cpp
../../examples/ThirdPartyLibs/stb_image/stb_image_write.cpp
../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp ../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp
../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp ../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp
../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp ../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp

View File

@@ -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)

View File

@@ -9,7 +9,7 @@ import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import pybullet import pybullet
import time import time
import pkgutil
plt.ion() plt.ion()
@@ -20,7 +20,9 @@ ax = plt.gca()
pybullet.connect(pybullet.DIRECT) 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("plane.urdf",[0,0,-1])
pybullet.loadURDF("r2d2.urdf") pybullet.loadURDF("r2d2.urdf")

View File

@@ -153,6 +153,7 @@ if not _OPTIONS["no-enet"] then
"../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp", "../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp",
"../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h", "../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h",
"../../examples/ThirdPartyLibs/stb_image/stb_image.cpp", "../../examples/ThirdPartyLibs/stb_image/stb_image.cpp",
"../../examples/ThirdPartyLibs/stb_image/stb_image_write.cpp",
"../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp", "../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp",
"../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp", "../../examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp",
"../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp", "../../examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp",

133
setup.py
View File

@@ -1,14 +1,33 @@
from setuptools import find_packages from setuptools import find_packages
from sys import platform as _platform from sys import platform as _platform
import sys import sys
import glob from glob import glob
from distutils.core import setup from distutils.core import setup
from distutils.extension import Extension from distutils.extension import Extension
from distutils.util import get_platform 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 #see http://stackoverflow.com/a/8719066/295157
import os import os
@@ -23,7 +42,7 @@ CXX_FLAGS += '-DBT_USE_DOUBLE_PRECISION '
CXX_FLAGS += '-DBT_ENABLE_ENET ' CXX_FLAGS += '-DBT_ENABLE_ENET '
CXX_FLAGS += '-DBT_ENABLE_CLSOCKET ' CXX_FLAGS += '-DBT_ENABLE_CLSOCKET '
CXX_FLAGS += '-DB3_DUMP_PYTHON_VERSION ' CXX_FLAGS += '-DB3_DUMP_PYTHON_VERSION '
CXX_FLAGS += '-DSTATIC_EGLRENDERER_PLUGIN ' CXX_FLAGS += '-DEGL_ADD_PYTHON_INIT '
# libraries += [current_python] # libraries += [current_python]
@@ -50,8 +69,6 @@ sources = ["examples/pybullet/pybullet.c"]\
+["examples/TinyRenderer/tgaimage.cpp"]\ +["examples/TinyRenderer/tgaimage.cpp"]\
+["examples/TinyRenderer/our_gl.cpp"]\ +["examples/TinyRenderer/our_gl.cpp"]\
+["examples/TinyRenderer/TinyRenderer.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/pdControlPlugin/pdControlPlugin.cpp"]\
+["examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.cpp"]\ +["examples/SharedMemory/plugins/collisionFilterPlugin/collisionFilterPlugin.cpp"]\
+["examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.cpp"]\ +["examples/SharedMemory/b3RobotSimulatorClientAPI_NoDirect.cpp"]\
@@ -86,6 +103,7 @@ sources = ["examples/pybullet/pybullet.c"]\
+["examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp"]\ +["examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp"]\
+["examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp"]\ +["examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp"]\
+["examples/ThirdPartyLibs/stb_image/stb_image.cpp"]\ +["examples/ThirdPartyLibs/stb_image/stb_image.cpp"]\
+["examples/ThirdPartyLibs/stb_image/stb_image_write.cpp"]\
+["examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp"]\ +["examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp"]\
+["examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp"]\ +["examples/Importers/ImportObjDemo/LoadMeshFromObj.cpp"]\
+["examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp"]\ +["examples/Importers/ImportObjDemo/Wavefront2GLInstanceGraphicsShape.cpp"]\
@@ -388,33 +406,93 @@ sources = ["examples/pybullet/pybullet.c"]\
+["examples/ThirdPartyLibs/Gwen/Platforms/Windows.cpp"]\ +["examples/ThirdPartyLibs/Gwen/Platforms/Windows.cpp"]\
+["examples/ThirdPartyLibs/Gwen/Renderers/OpenGL_DebugFont.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": if _platform == "linux" or _platform == "linux2":
libraries = ['dl','pthread'] libraries += ['dl','pthread']
CXX_FLAGS += '-D_LINUX ' CXX_FLAGS += '-D_LINUX '
CXX_FLAGS += '-DGLEW_STATIC ' CXX_FLAGS += '-DGLEW_STATIC '
CXX_FLAGS += '-DGLEW_INIT_OPENGL11_FUNCTIONS=1 ' CXX_FLAGS += '-DGLEW_INIT_OPENGL11_FUNCTIONS=1 '
CXX_FLAGS += '-DGLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1 ' CXX_FLAGS += '-DGLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1 '
CXX_FLAGS += '-DDYNAMIC_LOAD_X11_FUNCTIONS ' CXX_FLAGS += '-DDYNAMIC_LOAD_X11_FUNCTIONS '
CXX_FLAGS += '-DHAS_SOCKLEN_T ' CXX_FLAGS += '-DHAS_SOCKLEN_T '
CXX_FLAGS += '-fno-inline-functions-called-once '
CXX_FLAGS += '-fPIC ' # for plugins
CXX_FLAGS += '-DBT_USE_EGL ' CXX_FLAGS += '-DBT_USE_EGL '
CXX_FLAGS += '-fno-inline-functions-called-once'
sources = sources + ["examples/ThirdPartyLibs/enet/unix.c"]\ sources = sources + ["examples/ThirdPartyLibs/enet/unix.c"]\
+["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\ +["examples/ThirdPartyLibs/glad/gl.c"]
+["examples/ThirdPartyLibs/glad/gl.c"]\
+["examples/ThirdPartyLibs/glad/glx.c"]\
+["examples/ThirdPartyLibs/glad/egl.c"]\
+["examples/OpenGLWindow/EGLOpenGLWindow.cpp"]
include_dirs += ["examples/ThirdPartyLibs/optionalX11"] 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": elif _platform == "win32":
print("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 += '-DWIN32 '
CXX_FLAGS += '-DGLEW_STATIC ' CXX_FLAGS += '-DGLEW_STATIC '
sources = sources + ["examples/ThirdPartyLibs/enet/win32.c"]\ sources = sources + ["examples/ThirdPartyLibs/enet/win32.c"]\
+["examples/OpenGLWindow/Win32Window.cpp"]\ +["examples/OpenGLWindow/Win32Window.cpp"]\
+["examples/OpenGLWindow/Win32OpenGLWindow.cpp"]\ +["examples/OpenGLWindow/Win32OpenGLWindow.cpp"]\
+["examples/ThirdPartyLibs/glad/gl.c"] +["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": elif _platform == "darwin":
print("darwin!") print("darwin!")
os.environ['LDFLAGS'] = '-framework Cocoa -framework OpenGL' os.environ['LDFLAGS'] = '-framework Cocoa -framework OpenGL'
@@ -426,9 +504,12 @@ elif _platform == "darwin":
+["examples/OpenGLWindow/MacOpenGLWindow.cpp"]\ +["examples/OpenGLWindow/MacOpenGLWindow.cpp"]\
+["examples/ThirdPartyLibs/glad/gl.c"]\ +["examples/ThirdPartyLibs/glad/gl.c"]\
+["examples/OpenGLWindow/MacOpenGLWindowObjC.m"] +["examples/OpenGLWindow/MacOpenGLWindowObjC.m"]
egl_renderer_sources = egl_renderer_sources\
+["examples/OpenGLWindow/MacOpenGLWindow.cpp"]\
+["examples/OpenGLWindow/MacOpenGLWindowObjC.m"]
else: else:
print("bsd!") print("bsd!")
libraries = ['GL','GLEW','pthread'] libraries += ['GL','GLEW','pthread']
os.environ['LDFLAGS'] = '-L/usr/X11R6/lib' os.environ['LDFLAGS'] = '-L/usr/X11R6/lib'
CXX_FLAGS += '-D_BSD ' CXX_FLAGS += '-D_BSD '
CXX_FLAGS += '-I/usr/X11R6/include ' CXX_FLAGS += '-I/usr/X11R6/include '
@@ -437,7 +518,13 @@ else:
sources = ["examples/ThirdPartyLibs/enet/unix.c"]\ sources = ["examples/ThirdPartyLibs/enet/unix.c"]\
+["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\ +["examples/OpenGLWindow/X11OpenGLWindow.cpp"]\
+["examples/ThirdPartyLibs/glad/gl.c"]\ +["examples/ThirdPartyLibs/glad/gl.c"]\
+["examples/ThirdPartyLibs/glad/glx.c"]\
+ sources + 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__)) setup_py_dir = os.path.dirname(os.path.realpath(__file__))
@@ -459,6 +546,16 @@ print("packages")
print(find_packages('examples/pybullet/gym')) print(find_packages('examples/pybullet/gym'))
print("-----") 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( setup(
name = 'pybullet', name = 'pybullet',
version='2.1.4', version='2.1.4',
@@ -469,8 +566,8 @@ setup(
author_email='erwincoumans@google.com', author_email='erwincoumans@google.com',
license='zlib', license='zlib',
platforms='any', platforms='any',
keywords=['game development', 'virtual reality', 'physics simulation', 'robotics', 'collision detection', 'opengl'], keywords=['game development', 'virtual reality', 'physics simulation', 'robotics', 'reinforcement learning', 'collision detection', 'opengl'],
ext_modules = [Extension("pybullet", ext_modules = [eglRender, Extension("pybullet",
sources = sources, sources = sources,
libraries = libraries, libraries = libraries,
extra_compile_args=CXX_FLAGS.split(), extra_compile_args=CXX_FLAGS.split(),

View File

@@ -356,7 +356,7 @@ int main()
#ifndef _WIN32 #ifndef _WIN32
//we need glewExperimental on Linux //we need glewExperimental on Linux
#endif // _WIN32 #endif // _WIN32
gladLoadGLInternalLoader(); gladLoaderLoadGL();
#endif #endif
#endif //B3_USE_GLFW #endif //B3_USE_GLFW
//we ned to call glGetError twice, because of some Ubuntu/Intel/OpenGL issue //we ned to call glGetError twice, because of some Ubuntu/Intel/OpenGL issue

View File

@@ -41,6 +41,7 @@
"../../examples/OpenGLWindow/opengl_fontstashcallbacks.h", "../../examples/OpenGLWindow/opengl_fontstashcallbacks.h",
"../../examples/Utils/b3Clock.cpp", "../../examples/Utils/b3Clock.cpp",
"../../examples/Utils/b3Clock.h", "../../examples/Utils/b3Clock.h",
"../../examples/ThirdPartyLibs/stb_image/stb_image_write.cpp",
"**.cpp", "**.cpp",
"**.h", "**.h",
} }