in mujoco_py/mjrendercontext.pyx [0:0]
def render(self, width, height, camera_id=None, segmentation=False):
cdef mjrRect rect
rect.left = 0
rect.bottom = 0
rect.width = width
rect.height = height
if self.sim.render_callback is not None:
self.sim.render_callback(self.sim, self)
# Sometimes buffers are too small.
if width > self._con.offWidth or height > self._con.offHeight:
new_width = max(width, self._model_ptr.vis.global_.offwidth)
new_height = max(height, self._model_ptr.vis.global_.offheight)
self.update_offscreen_size(new_width, new_height)
if camera_id is not None:
if camera_id == -1:
self.cam.type = const.CAMERA_FREE
else:
self.cam.type = const.CAMERA_FIXED
self.cam.fixedcamid = camera_id
# This doesn't really do anything else rather than checking for the size of buffer
# need to investigate further whi is that a no-op
# self.opengl_context.set_buffer_size(width, height)
mjv_updateScene(self._model_ptr, self._data_ptr, &self._vopt,
&self._pert, &self._cam, mjCAT_ALL, &self._scn)
if segmentation:
self._scn.flags[const.RND_SEGMENT] = 1
self._scn.flags[const.RND_IDCOLOR] = 1
for marker_params in self._markers:
self._add_marker_to_scene(marker_params)
mjr_render(rect, &self._scn, &self._con)
for gridpos, (text1, text2) in self._overlay.items():
mjr_overlay(const.FONTSCALE_150, gridpos, rect, text1.encode(), text2.encode(), &self._con)
if segmentation:
self._scn.flags[const.RND_SEGMENT] = 0
self._scn.flags[const.RND_IDCOLOR] = 0