Files
bullet3/examples/SharedMemory/plugins/eglPlugin/eglRendererPlugin.cpp
erwincoumans adb5c049c7 Thanks to @dchichkov for some of the fixes in the eglRendererPlugin!
Rename tinyRenderer -> eglRenderer in the eglRendererPlugin.
Allow to run the eglRendererPlugin to run on Windows (not in EGL mode but Win32OpenGLWindow mode)

Here is a script I tested on Windows:
~~~~~~~~~~~~
mport pybullet as p
import time

p.connect(p.DIRECT)
plugin = p.loadPlugin("e:/develop/bullet3/bin/pybullet_eglRendererPlugin_vs2010_x64_debug.dll","_eglRendererPlugin")
print("plugin=",plugin)
p.setGravity(0,0,-10)
p.loadURDF("plane.urdf",[0,0,-1])
p.loadURDF("r2d2.urdf")
pixelWidth = 320
pixelHeight = 220
while (1):
	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]
	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,projectionMatrix, shadow=1,lightDirection=[1,1,1])#,renderer=pybullet.ER_BULLET_HARDWARE_OPENGL)
	img_arr = p.getCameraImage(pixelWidth, pixelHeight, shadow=1,lightDirection=[1,1,1])#,renderer=pybullet.ER_BULLET_HARDWARE_OPENGL)
	#print("img_arr=",img_arr)
	time.sleep(1)
~~~~~~~~~~~~~
2018-09-09 13:37:49 -07:00

55 lines
1.2 KiB
C++

//eglRenderer plugin
//see Bullet/examples/pybullet/examples/eglRendererTest.py
#include "eglRendererPlugin.h"
#include "eglRendererVisualShapeConverter.h"
#include "../../SharedMemoryPublic.h"
#include "../b3PluginContext.h"
#include <stdio.h>
struct EGLRendererPluginClass
{
EGLRendererVisualShapeConverter m_renderer;
EGLRendererPluginClass()
{
}
virtual ~EGLRendererPluginClass()
{
}
};
B3_SHARED_API int initPlugin_eglRendererPlugin(struct b3PluginContext* context)
{
EGLRendererPluginClass* obj = new EGLRendererPluginClass();
context->m_userPointer = obj;
return SHARED_MEMORY_MAGIC_NUMBER;
}
B3_SHARED_API int executePluginCommand_eglRendererPlugin(struct b3PluginContext* context, const struct b3PluginArguments* arguments)
{
return -1;
}
B3_SHARED_API void exitPlugin_eglRendererPlugin(struct b3PluginContext* context)
{
EGLRendererPluginClass* obj = (EGLRendererPluginClass*) context->m_userPointer;
delete obj;
context->m_userPointer = 0;
}
//all the APIs below are optional
B3_SHARED_API struct UrdfRenderingInterface* getRenderInterface_eglRendererPlugin(struct b3PluginContext* context)
{
EGLRendererPluginClass* obj = (EGLRendererPluginClass*) context->m_userPointer;
return &obj->m_renderer;
}