Frontends

The user-facing entry points: a windowed application with GLFW, or a headless frontend for tests and compute-only workloads.

class GlfwFrontend

Public Functions

GlfwFrontend()

User facing class.

class HeadlessFrontend

Public Functions

HeadlessFrontend()

User facing class.

Cameras

The camera uniform buffer has the type CameraUboType, a UniformBufferObject<CameraMVP>.

class InterfaceCamera

Interface for cameras that the engine updates every frame.

KlartraumEngine::setInterfaceCamera() calls initialize() once. Every frame, KlartraumEngine::step() passes the queued input events to onEvent() and then calls update(), which writes the camera matrices into the data of the camera uniform buffer.

Subclassed by klartraum::InterfaceCameraOrbit

class InterfaceCameraOrbit : public klartraum::InterfaceCamera
struct CameraMVP

Contents of the camera uniform buffer (CameraUboType): model, view and projection matrices and the camera position, in std140 layout.

cropProjection() creates an off-center view of a square window in the original projection’s normalized device coordinates. centre gives the window’s center and halfExtent its positive half-size; the resulting projection preserves depth. Use it for a cropped render or a higher-resolution view of part of the scene.

inline glm::mat4 klartraum::cropProjection(const glm::mat4 &proj, glm::vec2 centre, float halfExtent)

A projection that shows only a window of proj’s view, enlarged to the whole view.

The window is the square of half extent halfExtent around centre, both in the NDC of proj; NDC depths stay the same. Rendering with it at a resolution of the window’s size in pixels gives the window’s pixels of the full view; at a higher resolution, a sharper view of the window.

Input events

class Event

Base class of the input events that a frontend queues in KlartraumEngine::getEventQueue().

KlartraumEngine::step() passes them to the InterfaceCamera.

Subclassed by klartraum::EventKey, klartraum::EventMouseButton, klartraum::EventMouseMove, klartraum::EventMouseScroll

class EventMouseMove : public klartraum::Event

The mouse cursor moved: position (x, y) and movement (dx, dy) since the last event, in screen coordinates.

class EventMouseButton : public klartraum::Event

A mouse button was pressed or released.

class EventMouseScroll : public klartraum::Event

The mouse wheel or touchpad scrolled; (x, y) is the offset since the last frame.

class EventKey : public klartraum::Event

A key was pressed or released.