(self,
               model,
               gl_context,
               font_scale=enums.mjtFontScale.mjFONTSCALE_150)
Initializes this MjrContext instance.

    Args:
      model: An `MjModel` instance.
      gl_context: A `render.ContextBase` instance.
      font_scale: Integer controlling the font size for text. Must be a value
        in `mjbindings.enums.mjtFontScale`.

    Raises:
      ValueError: If `font_scale` is invalid.
Initializes this MjrContext instance.
Initializes this MjrContext instance .
def __init__(self,
               model,
               gl_context,
               font_scale=enums.mjtFontScale.mjFONTSCALE_150):
    """Initializes this MjrContext instance.

    Args:
      model: An `MjModel` instance.
      gl_context: A `render.ContextBase` instance.
      font_scale: Integer controlling the font size for text. Must be a value
        in `mjbindings.enums.mjtFontScale`.

    Raises:
      ValueError: If `font_scale` is invalid.
    """
    if font_scale not in enums.mjtFontScale:
      raise ValueError(_INVALID_FONT_SCALE.format(font_scale))

    ptr = ctypes.pointer(types.MJRCONTEXT())
    mjlib.mjr_defaultContext(ptr)

    with gl_context.make_current() as ctx:
      ctx.call(mjlib.mjr_makeContext, model.ptr, ptr, font_scale)
      ctx.call(mjlib.mjr_setBuffer, enums.mjtFramebuffer.mjFB_OFFSCREEN, ptr)
      gl_context.increment_refcount()

    # Free resources when the ctypes pointer is garbage collected.
    def finalize_mjr_context(ptr):
      if not gl_context.terminated:
        with gl_context.make_current() as ctx:
          ctx.call(mjlib.mjr_freeContext, ptr)
          gl_context.decrement_refcount()

    _create_finalizer(ptr, finalize_mjr_context)

    super().__init__(ptr)
def __init__ ( self , model , gl_context , font_scale = enums . mjtFontScale . mjFONTSCALE_150 ) : if font_scale not in enums . mjtFontScale : raise ValueError ( _INVALID_FONT_SCALE . format ( font_scale ) ) ptr = ctypes . pointer ( types . MJRCONTEXT ( ) ) mjlib . mjr_defaultContext ( ptr ) with gl_context . make_current ( ) as ctx : ctx . call ( mjlib . mjr_makeContext , model . ptr , ptr , font_scale ) ctx . call ( mjlib . mjr_setBuffer , enums . mjtFramebuffer . mjFB_OFFSCREEN , ptr ) gl_context . increment_refcount ( ) # Free resources when the ctypes pointer is garbage collected. def finalize_mjr_context ( ptr ) : if not gl_context . terminated : with gl_context . make_current ( ) as ctx : ctx . call ( mjlib . mjr_freeContext , ptr ) gl_context . decrement_refcount ( ) _create_finalizer ( ptr , finalize_mjr_context ) super ( ) . __init__ ( ptr )