API Reference Introduction
Welcome to the Olympe Engine API Reference. This section provides detailed documentation of the engine's classes, functions, and data structures.
Full API Documentation
Complete API documentation is generated using Doxygen from source code comments. The generated documentation includes:
- Class hierarchies and inheritance diagrams
- Function signatures and parameter descriptions
- Member variable documentation
- Code examples and usage notes
- Cross-references between related classes
Generating API Docs
To generate the full API documentation:
# Install Doxygen (if not already installed)
# Windows: Download from https://www.doxygen.nl/download.html
# Linux: sudo apt install doxygen
# macOS: brew install doxygen
# Generate documentation
cd /path/to/Olympe-Engine
doxygen Doxyfile
Generated documentation will be available in Docs/html/index.html.
Key Classes and Headers
This section provides an overview of the most important classes and headers you'll encounter when working with Olympe Engine.
Core Engine
GameEngine
File: Source/GameEngine.h
Top-level singleton that orchestrates the entire engine.
GameEngine& engine = GameEngine::GetInstance();
engine.Initialize();
engine.Process(); // Call every frame
Key Members:
InputsManager& inputsmanager: Input system accessVideoGame& videogame: Game state managementDataManager& datamanager: Resource managementstatic float fDt: Delta time between framesSDL_Renderer* renderer: Main rendering context
World
File: Source/World.h
Manages the ECS architecture and game world state.
World& world = World::GetInstance();
EntityID entity = world.CreateEntity();
world.AddComponent<Position_data>(entity, position);
world.GetComponent<Position_data>(entity)->position.x += 10.0f;
Key Methods:
CreateEntity(): Create new entityDestroyEntity(EntityID): Destroy entityAddComponent<T>(EntityID, T): Add component to entityGetComponent<T>(EntityID): Get component from entityHasComponent<T>(EntityID): Check if entity has componentRemoveComponent<T>(EntityID): Remove component from entityLoadLevel(string): Load Tiled levelRegisterSystem<T>(): Register ECS system
ECS Architecture
ECS_Entity
File: Source/ECS_Entity.h
Defines entity identifiers and component signatures.
using EntityID = uint32_t;
using ComponentSignature = std::bitset<MAX_COMPONENTS>;
ECS_Components
File: Source/ECS_Components.h
All component data structures. Key components:
- Identity_data: Name, tag, entity type
- Position_data: 2D/3D position
- Velocity_data: Movement velocity
- BoundingBox_data: Collision bounds
- VisualSprite_data: Sprite rendering
- Controller_data: Player input
- AIBlackboard_data: AI state
- AIBehaviorTree_data: Behavior tree
- CameraTransform_data: Camera state
- CameraFollow_data: Camera following behavior
ECS_Systems
File: Source/ECS_Systems.h
Base class for all systems and system declarations.
class ECS_System {
ComponentSignature requiredSignature;
std::set<EntityID> m_entities;
virtual void Process() {}
virtual void Render() {}
};
Key Systems:
InputSystem: Process player inputAISystem: Process behavior treesPathfindingSystem: Navigation and pathfindingPhysicsSystem: Collision detectionCameraSystem: Camera updatesRenderingSystem: Entity rendering
Input System
InputsManager
File: Source/InputsManager.h
Manages all input devices and player bindings.
InputsManager& input = InputsManager::GetInstance();
input.InitializeInputSystem("Config/olympe-config.json");
int joystickCount = input.GetConnectedJoysticksCount();
Key Methods:
InitializeInputSystem(string): Load input configurationHandleEvent(SDL_Event*): Process SDL eventsGetDeviceManager(): Access device managementGetContextManager(): Access input contexts
InputDevice
File: Source/InputDevice.h
Device management and profile assignment.
InputDeviceManager& deviceMgr = InputDeviceManager::GetInstance();
DeviceID keyboard = deviceMgr.GetKeyboardDevice();
Behavior Trees
BehaviorTree
File: Source/AI/BehaviorTree.h
Behavior tree definitions and evaluation.
Key Structures:
BTNode: Individual tree nodeBTNodeType: Node type enum (Selector, Sequence, Action, Condition)BTStatus: Execution status (Running, Success, Failure)BTConditionType: Built-in conditionsBTActionType: Built-in actions
struct AIBehaviorTree_data {
std::string behaviorTreePath;
BTNode rootNode;
BTStatus currentStatus;
};
Prefab and Blueprint System
PrefabFactory
File: Source/PrefabFactory.cpp, Source/prefabfactory.h
Creates entities from JSON blueprints.
EntityID npc = PrefabFactory::CreateEntityFromBlueprint(
"Blueprints/EntityPrefab/guard.json"
);
PrefabScanner
File: Source/PrefabScanner.h
Scans and registers available blueprints.
PrefabScanner::ScanDirectory("Blueprints/EntityPrefab/");
std::vector<std::string> prefabs = PrefabScanner::GetAvailablePrefabs();
Level Loading
TiledLevelLoader
Files: Source/TiledLevelLoader/*
Loads Tiled TMX map files.
Key Classes:
TiledMap: Parsed map dataTileLayer: Tile layer informationObjectGroup: Entity instancesTileset: Tileset metadata
World::GetInstance().LoadLevel("Levels/forest_level.tmx");
Data Management
DataManager
File: Source/DataManager.h
Resource loading and caching.
DataManager& data = DataManager::GetInstance();
SDL_Texture* texture = data.LoadTexture("Resources/sprite.png");
Rendering
IsometricRenderer
File: Source/Rendering/IsometricRenderer.cpp
Isometric projection rendering.
void RenderEntitiesForCamera(const CameraTransform& cam);
void RenderMultiLayerForCamera(const CameraTransform& cam);
RenderContext
File: Source/RenderContext.h
Rendering state and utilities.
Utilities
Vector
File: Source/vector.h
2D/3D vector math.
struct Vector {
float x, y, z;
Vector operator+(const Vector& other);
float Length() const;
Vector Normalized() const;
};
Sprite
File: Source/Sprite.h
Sprite loading and rendering utilities.
EventQueue
File: Source/system/EventQueue.h
Event system for inter-system communication.
EventQueue::Publish("Input", "ButtonPressed", {{"action", "jump"}, {"playerID", 0}});
EventQueue::Subscribe("Input", [](const Event& e) { /* handle */ });
Component Reference
Common Component Properties
Most components follow similar patterns:
// Position component
struct Position_data {
Vector position;
};
// Velocity component
struct Velocity_data {
Vector velocity;
float maxSpeed;
};
// Sprite component
struct VisualSprite_data {
std::string spritePath;
SDL_Rect srcRect;
Vector hotSpot;
bool isVisible;
};
See ECS Overview for complete component documentation.
System Reference
System Processing Order
Systems are processed in this order each frame:
- InputEventConsumeSystem: Consume input events
- GameEventConsumeSystem: Handle game state events
- AISystem: Update behavior trees
- PathfindingSystem: Process navigation requests
- InputSystem: Process player controller input
- PhysicsSystem: Update physics simulation
- CameraSystem: Update camera transforms
- RenderingSystem: Render all entities
Header Dependency Graph
GameEngine.h
├── World.h
│ ├── ECS_Entity.h
│ ├── ECS_Components.h
│ ├── ECS_Systems.h
│ ├── ECS_Register.h
│ ├── PrefabFactory.h
│ └── TiledLevelLoader (subdirectory)
├── InputsManager.h
│ ├── InputDevice.h
│ ├── InputConfigLoader.h
│ └── system/KeyboardManager.h
├── DataManager.h
└── VideoGame.h
Common Patterns
Creating and Configuring Entities
// Create entity
EntityID entity = World::Get().CreateEntity();
// Add identity
Identity_data identity;
identity.name = "Player";
identity.entityType = EntityType::Player;
World::Get().AddComponent<Identity_data>(entity, identity);
// Add position
Position_data position;
position.position = Vector(100.0f, 200.0f, 0.0f);
World::Get().AddComponent<Position_data>(entity, position);
// Add sprite
VisualSprite_data sprite;
sprite.spritePath = "Resources/player.png";
sprite.srcRect = {0, 0, 32, 32};
sprite.hotSpot = Vector(16.0f, 16.0f);
World::Get().AddComponent<VisualSprite_data>(entity, sprite);
Accessing Components in Systems
class MySystem : public ECS_System {
virtual void Process() override {
for (EntityID entity : m_entities) {
Position_data* pos = World::Get().GetComponent<Position_data>(entity);
Velocity_data* vel = World::Get().GetComponent<Velocity_data>(entity);
if (pos && vel) {
pos->position = pos->position + vel->velocity * GameEngine::fDt;
}
}
}
};
Loading Resources
DataManager& dm = DataManager::Get();
SDL_Texture* texture = dm.LoadTexture("Resources/sprite.png");
// Texture is cached; subsequent calls return cached texture
C++ Standard and Dependencies
- C++ Standard: C++14
- Main Dependencies:
- SDL3 (rendering, input, windowing)
- nlohmann/json (JSON parsing)
- ImGui (editor UI)
- tinyxml2 (Tiled TMX parsing)
Next Steps
- Explore ECS Architecture for in-depth component system details
- Read Engine Modules to understand module organization
- Study Behavior Trees for AI programming
- Check Blueprint System for data-driven entity creation
Contributing API Documentation
When contributing code, please:
- Add Doxygen comments to all public classes and functions
- Use
@brief,@param,@returntags - Include usage examples where helpful
- Document preconditions and postconditions
- Note thread-safety considerations
Example:
/**
* @brief Creates a new entity in the world
* @return EntityID of the newly created entity
*
* Example:
* @code
* EntityID player = World::Get().CreateEntity();
* @endcode
*/
EntityID CreateEntity();
See Code Style Guide for full documentation standards.