This guide will walk you through creating your first Atlas Engine application. You’ll create a window, set up a camera, add 3D objects, and implement basic lighting.
#include "atlas/window.h"#include "atlas/scene.h"#include "atlas/camera.h"#include "atlas/object.h"#include "atlas/light.h"int main() { // Configure the window Window window({ .title = "My First Atlas Game", .width = 1280, .height = 720, .renderScale = 0.75f, .mouseCaptured = true, .multisampling = true }); // Start the main loop window.run(); return 0;}
The .renderScale parameter controls internal rendering resolution. Values below 1.0 improve performance by rendering at a lower resolution and upscaling.
Scenes organize your game objects, lights, and environment. Let’s create a custom scene:
main.cpp
#include "atlas/window.h"#include "atlas/scene.h"#include "atlas/camera.h"#include "atlas/object.h"#include "atlas/light.h"class GameScene : public Scene { Camera camera; CoreObject ground; CoreObject cube; DirectionalLight sun;public: void initialize(Window &window) override { // Set up camera camera = Camera(); camera.setPosition({0.0f, 2.0f, 5.0f}); camera.lookAt({0.0f, 0.0f, 0.0f}); window.setCamera(&camera); // Create ground plane ground = createBox({10.0f, 0.1f, 10.0f}, Color::white()); ground.setPosition({0.0f, -0.1f, 0.0f}); ground.initialize(); window.addObject(&ground); // Create a cube cube = createBox({1.0f, 1.0f, 1.0f}, Color(1.0f, 0.5f, 0.2f)); cube.setPosition({0.0f, 0.5f, 0.0f}); cube.initialize(); window.addObject(&cube); // Add directional light (sun) sun = DirectionalLight(); sun.direction = {-0.3f, -1.0f, -0.5f}; sun.setColor(Color(1.0f, 0.95f, 0.9f)); sun.intensity = 1.5f; this->addDirectionalLight(&sun); // Set ambient lighting this->setAmbientIntensity(0.3f); } void update(Window &window) override { // Update camera with WASD controls camera.update(window); // Rotate the cube cube.rotate({0.0f, window.getDeltaTime() * 45.0f, 0.0f}); } void onMouseMove(Window &window, Movement2d movement) override { // Update camera look direction camera.updateLook(window, movement); }};int main() { Window window({ .title = "My First Atlas Game", .width = 1280, .height = 720, .renderScale = 0.75f, .mouseCaptured = true }); GameScene scene; window.setScene(&scene); window.run(); return 0;}
Objects added to the window (like ground and cube) must remain valid for the entire lifetime of the window. Declare them as class members, not local variables in initialize().
For rendering many copies of the same object efficiently, use instanced rendering:
CoreObject cube = createBox({0.5f, 0.5f, 0.5f}, Color::red());cube.setPosition({0.0f, 0.25f, 0.0f});// Create instancesfor (int i = 0; i < 10; i++) { Instance &instance = cube.createInstance(); instance.move({0.0f, i * 0.6f, 0.0f});}cube.initialize();window.addObject(&cube);
Instanced rendering dramatically improves performance when rendering many identical objects. All instances share the same geometry and material but can have unique transforms.