API ReferenceGE Extensionsrender
Offscreen View Demo
A minimal example extension demonstrating how to create and display an offscreen render view in an ImGui window. The camera orbits the origin.
A minimal example extension demonstrating how to create and display an offscreen render view in an ImGui window. The camera orbits the origin.
Public API
| Function | Signature | Description |
|---|---|---|
M.onUpdate | (dtReal, dtSim, dtRaw) | Creates render view (once), updates camera, draws ImGui window |
Internals
- Render view name:
"Demo view 1"- unique identifier for the view - Resolution: 512 × 256 pixels
- Camera: Orbits the origin using
sin(timer)/cos(timer)at height 1.5 - FOV: 75°, near clip 0.1, far clip 2000
- Editor icons: Enabled (
renderEditorIcons = true)
How It Works
- On first
onUpdate, creates a render view viaRenderViewManagerInstance:getOrCreateView - Sets
luaOwned = trueso Lua GC manages the view's lifetime - Configures camera matrix, resolution, viewport, frustum, and named texture target
- Each frame, updates the camera position to orbit the origin
- Uses
debugDrawer:drawTextAdvancedto draw text visible only in that view - Displays the rendered texture in an ImGui window using
imUtils.texObj('#' .. renderViewName)
Usage Examples
-- Load the demo extension
extensions.load('render_viewDemo')
-- The demo ImGui window appears automatically showing the orbiting camera view
-- Unload to stop:
extensions.unload('render_viewDemo')Key Notes
- The
#prefix inimUtils.texObj('#Demo view 1')references a named texture target - The render view persists as long as the extension is loaded
- Camera orbits at radius 1.0 around (0, 0, 1.5)
- Demonstrates
DebugDrawertext scoped to a specific render view (commented out target view code) - Good reference for creating picture-in-picture or security camera effects
See Also
- Render HDR - Post-Effect Pipeline Initialization - Related reference
- Render OpenXR - VR/XR Runtime Management - Related reference
- Render Views - Offscreen Camera Screenshots - Related reference
- Game Engine Overview - Guide