in mujoco_py/mjbatchrenderer.pyx [0:0]
def __init__(self, width, height, batch_size=1, device_id=0,
depth=False, use_cuda=False):
"""
Args:
- width (int): Image width.
- height (int): Image height.
- batch_size (int): Size of batch to render into. Memory is
allocated once upon initialization of object.
- device_id (int): Device to use for storing the batch.
- depth (bool): if True, render depth in addition to RGB.
- use_cuda (bool): if True, use OpenGL-CUDA interop to map
the PBO onto a CUDA buffer.
"""
# Early initialization to prevent failure in __del__
self._use_cuda = False
self.pbo_depth, self.pbo_depth = 0, 0
if not usingEGL():
raise MjBatchRendererNotSupported(
"MjBatchRenderer currently only supported with EGL-backed"
"rendering context.")
# Make sure OpenGL Context is available before creating PBOs
initOpenGL(device_id)
makeOpenGLContextCurrent(device_id)
self.pbo_rgb = createPBO(width, height, batch_size, 0)
self.pbo_depth = createPBO(width, height, batch_size, 1) if depth else 0
self._depth = depth
self._device_id = device_id
self._width = width
self._height = height
self._batch_size = batch_size
self._current_batch_offset = 0
self._use_cuda = use_cuda
self._cuda_buffers_are_mapped = False
self._cuda_rgb_ptr, self._cuda_depth_ptr = None, None
if use_cuda:
self._init_cuda()