simvx.graphics.renderer.game_viewport¶
Game Viewport Renderer: offscreen render target for in-editor game preview.
Renders the game scene through the forward renderer into an offscreen RenderTarget, then exposes it as a bindless texture for Draw2D to display in the editor’s viewport panel.
Follows the same pattern as PostProcessPass: render to offscreen target in pre_render, sample the result as a texture in the main pass.
Usage: gvp = GameViewportRenderer(engine) gvp.create(width, height)
# In pre_render (before main render pass):
gvp.begin_pass(cmd)
scene_renderer.render_scene_content(cmd)
gvp.end_pass(cmd)
# In Draw2D (inside main render pass):
Draw2DTexture.draw_texture(gvp.texture_id, (x, y), (w, h))
# Cleanup:
gvp.destroy()
Module Contents¶
Classes¶
Manages an offscreen render target for rendering the game scene. |
Data¶
API¶
- simvx.graphics.renderer.game_viewport.log¶
‘getLogger(…)’
- simvx.graphics.renderer.game_viewport.__all__¶
[‘GameViewportRenderer’]
- class simvx.graphics.renderer.game_viewport.GameViewportRenderer(engine: Any)¶
Manages an offscreen render target for rendering the game scene.
The rendered result is registered as a bindless texture so Draw2D can display it as a textured quad in the editor viewport panel.
Also owns a
Draw2DPasscompiled against the offscreen render pass, allowing game tree 2D overlays (Labels, Panels, customdraw()calls) to be rendered into the same target as the 3D scene.Initialization
- create(width: int, height: int) None¶
Create the offscreen render target and register its texture.
Uses R16G16B16A16_SFLOAT to match the HDR render pass format, ensuring pipeline compatibility with the 3D pipelines (which are compiled against the HDR offscreen render pass).
- resize(width: int, height: int) None¶
Recreate the render target at a new size.
Preserves the bindless texture slot across resizes: the slot id the editor handed out stays stable, only the backing image view changes. Draw2D tickets that captured the old id keep working.
- ensure_gbuffer() None¶
Recreate the target if the engine’s thin-G-buffer activation changed.
SSR/SSGI toggling the G-buffer rebuilds the forward pipelines with a second colour output; a single-attachment offscreen pass would then be render-pass-incompatible with them (a hard crash when SSR is combined with a live RenderView / reflection probe). Called from the manager’s prepare phase (before any offscreen draw is recorded), it rebuilds the target to match, preserving the bindless slot. A no-op when the state already matches, which is the common path (feature off, or already activated at create time).
- begin_pass(cmd: Any) None¶
Begin the offscreen render pass (call before scene rendering).
- end_pass(cmd: Any) None¶
End the offscreen render pass.
- render_draw2d(cmd: Any, ops: list) None¶
Render pre-extracted Draw2D ops into the offscreen target.
Call AFTER end_pass (3D content) to overlay 2D game content. Begins its own render pass with LOAD_OP_LOAD to preserve 3D content.
- property texture_id: int¶
Bindless texture index for Draw2D, or -1 if not created.
- property width: int¶
- property height: int¶
- property ready: bool¶
True when the render target is created and ready for rendering.
- destroy() None¶
Release all GPU resources.