Overview
The Window class provides the main interface for interacting with the Atlas Engine. It manages window creation, rendering loops, scene management, and input handling.
WindowConfiguration
Structure representing the configuration options for creating a window.
The title of the window displayed in the title bar.
The width of the window in pixels.
The height of the window in pixels.
Internal rendering resolution scale factor. Values below 1.0 render at a lower resolution and upscale to the window, improving performance.
Whether the mouse cursor should be captured and hidden.
posX
int
default:"WINDOW_CENTERED"
The X position of the window. Use WINDOW_CENTERED to center.
posY
int
default:"WINDOW_CENTERED"
The Y position of the window. Use WINDOW_CENTERED to center.
Whether to enable multisampling anti-aliasing.
Whether the window should have decorations (title bar, borders).
Whether the window can be resized by the user.
Whether the window framebuffer should be transparent.
Whether the window should always stay on top of other windows.
The opacity of the window. 1.0 is fully opaque, 0.0 is fully transparent.
The width component of the aspect ratio. Use -1 for no constraint.
The height component of the aspect ratio. Use -1 for no constraint.
Resolution scale used specifically for SSAO passes. Lower values reduce quality but greatly boost performance.
Window Class
Constructor
Window(const WindowConfiguration &config);
Constructs a window with the specified configuration.
config
const WindowConfiguration&
Window configuration settings.
Properties
The title of the window displayed in the title bar.
The width of the window in pixels.
The height of the window in pixels.
The gravity constant applied to physics bodies. Default is 9.81 m/s².
audioEngine
std::shared_ptr<AudioEngine>
The audio engine instance for managing spatial audio. Shared across the window.
Whether the window is using deferred rendering.
Static pointer to the main window instance. Used for global access to the primary window.
Core Methods
run
Starts the main window loop and begins rendering.
close
Closes the window and terminates the application.
setClearColor
void setClearColor(const Color &color);
Sets the background clear color for the window.
The color to use for clearing the screen.
Fullscreen and Window Mode
setFullscreen
void setFullscreen(bool enable);
void setFullscreen(Monitor &monitor);
Sets the window to fullscreen mode.
True to enable fullscreen, false to disable.
The monitor to use for fullscreen.
setWindowed
void setWindowed(const WindowConfiguration &config);
Sets the window to windowed mode with new configuration.
config
const WindowConfiguration&
New window configuration.
enumerateMonitors
static std::vector<Monitor> enumerateMonitors();
Enumerates all available monitors.
Vector of available monitors.
Scene and Camera Management
setCamera
void setCamera(Camera *newCamera);
Sets the camera for the window.
The camera to use for rendering. Must be long-lived.
setScene
void setScene(Scene *scene);
Sets the scene for the window.
getCurrentScene
Scene* getCurrentScene();
Gets the current scene being rendered.
Pointer to the current scene.
getCamera
Gets the current camera.
Pointer to the current camera.
Object Management
addObject
void addObject(Renderable *object);
Adds a renderable object to the window.
The renderable object to add. The object must be long-lived.
The object must be long-lived. This means that declaring it as a class property is a good idea.
removeObject
void removeObject(Renderable *object);
Removes a renderable object from the window.
addPreferencedObject
void addPreferencedObject(Renderable *object);
Adds a renderable object with higher rendering priority.
addPreludeObject
void addPreludeObject(Renderable *object);
Adds a renderable object to be rendered first.
addUIObject
void addUIObject(Renderable *object);
Registers a UI renderable so it is drawn after world geometry.
addLateForwardObject
void addLateForwardObject(Renderable *object);
Adds a renderable to the late forward queue. Late forward renderables are evaluated after the main forward pass.
isKeyPressed
bool isKeyPressed(Key key);
Checks if a key is currently pressed.
True if the key is pressed, false otherwise.
isKeyClicked
bool isKeyClicked(Key key);
Checks if a key was clicked (pressed and released) this frame.
True if the key was clicked, false otherwise.
releaseMouse
Releases mouse capture, allowing the cursor to move freely.
captureMouse
Captures the mouse cursor for camera control.
getCursorPosition
std::tuple<int, int> getCursorPosition();
Gets the current cursor position.
X and Y cursor coordinates.
Timing
getTime
Gets the current time since window creation.
getDeltaTime
float getDeltaTime() const;
Gets the delta time between frames.
getFramesPerSecond
float getFramesPerSecond() const;
Gets the current frames per second.
Rendering Configuration
useDeferredRendering
void useDeferredRendering();
Enables deferred rendering for the window. This allows for more advanced lighting and post-processing effects.
getRenderScale
float getRenderScale() const;
Returns the active internal render scale.
getSSAORenderScale
float getSSAORenderScale() const;
Returns the SSAO-specific render scale.
The SSAO render scale factor.
enableSSR
void enableSSR(bool enabled = true);
Enables or disables screen-space reflections.
isSSREnabled
bool isSSREnabled() const;
Checks if screen-space reflections are enabled.
getSize
Gets the framebuffer size of the window.
The width and height of the framebuffer.
Debug Methods
activateDebug
Activates debug mode for the window.
deactivateDebug
Deactivates debug mode for the window.
setLogOutput
void setLogOutput(bool showLogs, bool showWarnings, bool showErrors);
Configures which log messages are displayed.
Advanced Rendering
getDevice
std::shared_ptr<opal::Device> getDevice() const;
Returns the opal device instance for rendering.
return
std::shared_ptr<opal::Device>
Pointer to the rendering device.
getGBuffer
RenderTarget* getGBuffer() const;
Returns the lazily created deferred geometry buffer.
Pointer to the G-buffer contents.
addRenderTarget
void addRenderTarget(RenderTarget *target);
Adds a render target to the window.
The render target to add.
Monitor Class
Class representing a monitor with video mode querying capabilities.
Properties
The unique identifier for this monitor.
Whether this is the primary monitor.
Methods
queryVideoModes
std::vector<VideoMode> queryVideoModes() const;
Queries all available video modes for this monitor.
Vector of available video modes.
getCurrentVideoMode
VideoMode getCurrentVideoMode() const;
Gets the current video mode of this monitor.
getPhysicalSize
std::tuple<int, int> getPhysicalSize() const;
Gets the physical size of the monitor in millimeters.
Width and height in millimeters.
getPosition
std::tuple<int, int> getPosition() const;
Gets the position of the monitor in the desktop coordinate system.
X and Y position coordinates.
getContentScale
std::tuple<float, float> getContentScale() const;
Gets the content scale factors for this monitor.
Horizontal and vertical scale factors.
getName
std::string getName() const;
Gets the human-readable name of this monitor.
VideoMode Structure
Structure representing a video mode with resolution and refresh rate.
The width of the video mode in pixels.
The height of the video mode in pixels.
Example Usage
// Create a window with specific configuration
WindowConfiguration config;
config.title = "My Game";
config.width = 1280;
config.height = 720;
config.renderScale = 0.75f;
config.multisampling = true;
Window window(config);
// Set up camera and scene
Camera camera;
Scene scene;
window.setCamera(&camera);
window.setScene(&scene);
// Add objects to the scene
CoreObject cube = createBox({1.0, 1.0, 1.0}, Color::red());
window.addObject(&cube);
// Configure rendering
window.useDeferredRendering();
window.setClearColor(Color(0.2f, 0.3f, 0.4f, 1.0f));
// Run the main window loop
window.run();
Monitor Example
// Enumerate all available monitors
std::vector<Monitor> monitors = Window::enumerateMonitors();
for (const auto& monitor : monitors) {
std::cout << "Monitor: " << monitor.getName() << std::endl;
std::cout << "Primary: " << (monitor.primary ? "Yes" : "No") << std::endl;
// Get current video mode
VideoMode current = monitor.getCurrentVideoMode();
std::cout << "Current: " << current.width << "x" << current.height
<< " @ " << current.refreshRate << "Hz" << std::endl;
// Query all available modes
auto modes = monitor.queryVideoModes();
std::cout << "Available modes: " << modes.size() << std::endl;
}
// Set fullscreen on a specific monitor
if (!monitors.empty()) {
window.setFullscreen(monitors[0]);
}