MCPcopy Create free account
hub / github.com/google-deepmind/dm_control / make_current

Method make_current

dm_control/_render/base.py:123–150  ·  view source on GitHub ↗

Context manager that makes this Renderer's OpenGL context current. Yields: An object that exposes a `call` method that can be used to call a function on the dedicated rendering thread. Raises: RuntimeError: If this context is already current on another thread.

(self)

Source from the content-addressed store, hash-verified

121
122 @contextlib.contextmanager
123 def make_current(self):
124 """Context manager that makes this Renderer's OpenGL context current.
125
126 Yields:
127 An object that exposes a `call` method that can be used to call a
128 function on the dedicated rendering thread.
129
130 Raises:
131 RuntimeError: If this context is already current on another thread.
132 """
133
134 with self._render_executor.execution_context() as ctx:
135 if _CURRENT_CONTEXT_FOR_THREAD[self._render_executor.thread] != id(self):
136 if _CURRENT_THREAD_FOR_CONTEXT[id(self)]:
137 raise RuntimeError(
138 'Cannot make context {!r} current on thread {!r}: '
139 'this context is already current on another thread {!r}.'
140 .format(self, self._render_executor.thread,
141 _CURRENT_THREAD_FOR_CONTEXT[id(self)]))
142 else:
143 current_context = (
144 _CURRENT_CONTEXT_FOR_THREAD[self._render_executor.thread])
145 if current_context:
146 del _CURRENT_THREAD_FOR_CONTEXT[current_context]
147 _CURRENT_THREAD_FOR_CONTEXT[id(self)] = self._render_executor.thread
148 _CURRENT_CONTEXT_FOR_THREAD[self._render_executor.thread] = id(self)
149 ctx.call(self._platform_make_current)
150 yield ctx
151
152 def to_pixels(self, buffer):
153 """Converts the buffer to pixels."""

Callers 15

initialize_episodeMethod · 0.80
renderMethod · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
shapeMethod · 0.80
positionMethod · 0.80
set_titleMethod · 0.80
set_full_screenMethod · 0.80
updateMethod · 0.80
initialize_episodeMethod · 0.80
__init__Method · 0.80

Calls 2

execution_contextMethod · 0.80
callMethod · 0.45

Tested by 6

test_make_currentMethod · 0.64
test_thread_sharingMethod · 0.64
test_freeMethod · 0.64
test_make_currentMethod · 0.64
test_make_currentMethod · 0.64