Creating a Window
Windows are the primary interface for interacting with the Atlas Engine. Every application starts by creating a window with specific configuration options.
Basic Window Creation
Window window ({. title = "My Window" ,
. width = 1600 ,
. height = 1200 ,
. renderScale = 5.0 f ,
. mouseCaptured = true ,
. multisampling = false ,
. ssaoScale = 0.4 f });
Render Scale : The renderScale parameter controls internal rendering resolution. Values below 1.0 render at lower resolution and upscale for better performance.
Window Configuration
The WindowConfiguration struct provides extensive customization options:
Configuration Options
Property Type Default Description titlestd::string- Window title displayed in title bar widthint- Window width in pixels heightint- Window height in pixels renderScalefloat0.75fInternal resolution scale factor mouseCapturedbooltrueWhether to capture and hide cursor posXintWINDOW_CENTEREDX position or WINDOW_CENTERED posYintWINDOW_CENTEREDY position or WINDOW_CENTERED multisamplingbooltrueEnable MSAA anti-aliasing decorationsbooltrueShow title bar and borders resizablebooltrueAllow user resizing transparentboolfalseTransparent framebuffer alwaysOnTopboolfalseKeep window above others opacityfloat1.0fWindow opacity (0.0-1.0) ssaoScalefloat0.5fSSAO quality scale
Example: Custom Configuration
WindowConfiguration config;
config . title = "My Game" ;
config . width = 1280 ;
config . height = 720 ;
config . renderScale = 0.8 f ; // 80% internal resolution
config . multisampling = true ;
config . decorations = true ;
config . resizable = true ;
Window window ( config );
Setting Up the Window
After creating a window, you need to configure its scene and camera:
Window window ({. title = "My Window" ,
. width = 1600 ,
. height = 1200 ,
. renderScale = 5.0 f ,
. mouseCaptured = true ,
. multisampling = false ,
. ssaoScale = 0.4 f });
MainScene scene;
window . setScene ( & scene);
window . run ();
Window Loop
The run() method starts the main rendering loop:
// Start the window loop
window . run ();
// This blocks until the window closes
Rendering Configuration
Deferred Rendering
window . usesDeferred = true ;
window . enableSSR ( true );
Clear Color
window . setClearColor ( Color ( 0.1 f , 0.1 f , 0.15 f , 1.0 f ));
Fullscreen & Display Modes
Enumerate Monitors
std ::vector < Monitor > monitors = Window :: enumerateMonitors ();
for ( const auto & monitor : monitors) {
std ::string name = monitor . getName ();
auto [width, height] = monitor . getPosition ();
VideoMode currentMode = monitor . getCurrentVideoMode ();
std ::cout << "Monitor: " << name << " at ("
<< width << ", " << height << ")" << std ::endl;
std ::cout << "Current mode: " << currentMode . width << "x"
<< currentMode . height << "@"
<< currentMode . refreshRate << "Hz" << std ::endl;
}
Enable Fullscreen
// Fullscreen on primary monitor
window . setFullscreen ( true );
// Fullscreen on specific monitor
std ::vector < Monitor > monitors = Window :: enumerateMonitors ();
if ( ! monitors . empty ()) {
window . setFullscreen ( monitors [ 1 ]); // Second monitor
}
// Return to windowed mode
WindowConfiguration windowedConfig;
windowedConfig . width = 1280 ;
windowedConfig . height = 720 ;
window . setWindowed (windowedConfig);
The Window class provides input query methods:
if ( window . isKeyPressed ( Key ::W)) {
// Move forward while key is held
}
if ( window . isKeyClicked ( Key ::Space)) {
// Jump once when space is pressed
}
Mouse Control
// Release mouse cursor
window . releaseMouse ();
// Capture mouse for camera control
window . captureMouse ();
// Get cursor position
auto [x, y] = window . getCursorPosition ();
class MainScene : public Scene {
void update ( Window & window ) override {
camera . update (window);
if ( window . isKeyPressed ( Key ::Escape)) {
window . releaseMouse ();
}
}
void onMouseMove ( Window & window , Movement2d movement ) override {
camera . updateLook (window, movement);
}
};
// Get time since window creation
float time = window . getTime ();
// Get delta time between frames
float dt = window . getDeltaTime ();
// Get frames per second
float fps = window . getFramesPerSecond ();
Render Targets
RenderTarget frameBuffer = RenderTarget (window, RenderTargetType ::Scene);
window . addRenderTarget ( & frameBuffer);
frameBuffer . display (window);
Adding Objects to Window
// Add regular 3D object
window . addObject ( & cube);
// Add with higher rendering priority
window . addPreferencedObject ( & importantObject);
// Add to render first
window . addPreludeObject ( & skybox);
// Add UI element (rendered after world geometry)
window . addUIObject ( & fpsText);
// Add to late forward queue
window . addLateForwardObject ( & particles);
// Remove object
window . removeObject ( & cube);
Physics & Audio
// Set gravity
window . gravity = 9.81 f ; // Default is 9.81 m/s²
// Access physics world
if ( window . physicsWorld ) {
// Physics operations
}
// Access audio engine
if ( window . audioEngine ) {
// Audio operations
}
Debug Mode
// Enable debug rendering
window . activateDebug ();
// Disable debug rendering
window . deactivateDebug ();
Static Access
The main window can be accessed globally:
if ( Window ::mainWindow) {
// Access from anywhere
float fps = Window :: mainWindow -> getFramesPerSecond ();
}
Advanced Configuration
Rendering Backend Access
std ::shared_ptr < opal ::Device > device = window . getDevice ();
Viewport Control
window . viewportX = 0 ;
window . viewportY = 0 ;
window . viewportWidth = 1920 ;
window . viewportHeight = 1080 ;
Pipeline State
window . useDepth = true ;
window . useBlending = true ;
window . writeDepth = true ;
window . cullMode = opal :: CullMode ::Back;
window . depthCompareOp = opal :: CompareOp ::Less;
window . frontFace = opal :: FrontFace ::CounterClockwise;
Example: Complete Window Setup
int main () {
// Create window with configuration
Window window ({.title = "My Game" ,
.width = 1920 ,
.height = 1080 ,
.renderScale = 0.75 f ,
.mouseCaptured = true ,
.multisampling = true ,
.ssaoScale = 0.5 f });
// Configure rendering
window . usesDeferred = true ;
window . enableSSR ( true );
window . setClearColor ( Color ( 0.1 f , 0.1 f , 0.15 f , 1.0 f ));
// Set up scene
MainScene scene;
window . setScene ( & scene);
// Run main loop
window . run ();
return 0 ;
}
Next Steps
Scene Management Learn how to create and manage scenes
Objects & Components Work with game objects and components