picogl.renderer.initializable ============================= .. py:module:: picogl.renderer.initializable .. autoapi-nested-parse:: One-shot lifecycle helpers for renderer resources. ``Initializable`` — GPU/setup work runs once until the object is discarded (e.g. framebuffer creation, renderer ``_do_initialize``). ``Bindable`` — OpenGL *binding* is sticky within a pass: repeated ``bind()`` is a no-op until ``unbind()``. Use for pass-scoped helpers such as :class:`~picogl.backend.modern.core.pipeline.shader_pipeline.ShaderPipeline` and :class:`~picogl.backend.geometry.legacy_mesh_binding.LegacyClientMeshBinding`. Do **not** mix ``Bindable`` into types that rely on nested context managers or state restore (``ShaderProgram.__enter__``, VAO ``with``, ``GLFramebuffer.bound()``). Those need stack/restore semantics, not a single sticky flag. Also do **not** subclass ``Bindable`` from :class:`~picogl.buffers.base.VertexBase`, :class:`~picogl.gpu.buffers.vertex.legacy.VertexBufferGroup`, VAO/VBO types, or :class:`~picogl.protocols.drawable_buffer.DrawableBuffer` implementations. They use stack-based bind/unbind (every ``with`` calls bind then unbind); sticky ``_bound`` would disagree with actual gl state after nested ``with vbo`` scopes. For pass-scoped VAO binding without ``with`` churn, use a separate wrapper (``StickyVAOBinding``) only if profiling warrants it — not inheritance on ``VertexBase``. Classes ------- .. autoapisummary:: picogl.renderer.initializable.Initializable picogl.renderer.initializable.Bindable Module Contents --------------- .. py:class:: Initializable Enforces one-time initialization with optional lazy semantics. .. py:attribute:: __slots__ :value: ('_initialized',) .. py:attribute:: _initialized :value: False .. py:method:: initialize() -> None .. py:method:: _do_initialize() -> None :abstractmethod: Subclass must implement actual initialization. .. py:method:: ensure_initialized() -> None Call before any operation that requires initialization. .. py:method:: require_initialized() -> None Strict check (no auto-init). .. py:class:: Bindable Enforces one-time binding with optional lazy semantics. Not for VAO/VBO/``VertexBase`` types; see module docstring. .. py:attribute:: __slots__ :value: ('_bound',) .. py:attribute:: _bound :value: False .. py:method:: bind() -> None .. py:method:: _do_binding() -> None :abstractmethod: .. py:method:: ensure_bound() -> None .. py:method:: require_bound() -> None .. py:method:: unbind() -> None .. py:method:: _do_unbinding() -> None :abstractmethod: .. py:method:: __enter__() .. py:method:: __exit__(exc_type, exc_val, exc_tb)