Viewport Panel

The Viewport panel renders your 3D scene in real time using an offscreen OpenGL framebuffer. It provides editor camera controls and play/stop functionality.

Rendering

The viewport uses a ViewportFramebuffer that renders the scene to an offscreen FBO (GL_RGB color + GL_DEPTH24_STENCIL8 depth/stencil), then displays the result as an ImGui image. The framebuffer resizes dynamically when you resize the panel.

HiDPI support: The framebuffer resolution is scaled by the display content scale factor (via glfwGetWindowContentScale), so the scene renders at native resolution on Retina/HiDPI displays.

Initial framebuffer size: 800×600.

Play / Stop Toolbar

A centered toolbar bar sits above the viewport content:

  • Play — Enters play mode: physics, native scripts, and audio activate. The scene is snapshot before play so it can be restored on stop.
  • Stop — Exits play mode: reverts the scene to its pre-play state.

See Scene Management for details on the snapshot/restore cycle.

Editor Camera

The editor uses a free-flying camera (separate from any in-scene Camera component):

ControlAction
Right-click + dragOrbit / look around
W / A / S / DMove forward / left / backward / right (when viewport hovered)
Scroll wheelZoom in / out
FFocus on selected entity (when viewport focused)

Camera defaults:

ParameterValue
Position(0, 2, 5)
FOV45°
Near clip0.1
Far clip1000
Move speed5.0 units/sec
Look sensitivity0.15

The aspect ratio updates automatically to match the viewport panel dimensions.