Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions Docs/EngineArchitecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Storming Engine: C++ Core Architecture

This document provides a technical overview of the C++ Core of the Storming Engine. The engine is designed as a high-performance, decoupled renderer that communicates with the Java Editor via a strict JSON-based IPC (Inter-Process Communication) protocol.

## Dual-Engine Architecture

The engine supports two distinct operational modes, allowing for a Godot-style workflow where the Editor workspace and the Game runtime remain separate.

### 1. Editor Mode (`--editor`)
Used for the background workspace view.
* **Visual Overlays**: Renders an infinite grid and coordinate origin cross (Red X, Green Y).
* **Selection Highlighting**: Draws a yellow bounding box around the currently selected entity.
* **Stateful Tracking**: The engine maintains an internal `m_SelectedEntityID` to facilitate relative transformations.

### 2. Runtime Mode (Default)
Used for the Simulation Window.
* **Clean View**: No grid or editor-specific overlays.
* **Performance Focused**: Optimized for running game logic and scripts without editor overhead.

## Core Systems

### Application Lifecycle (`Application.cpp`)
The `Application` class manages the main engine loop, windowing (via SDL3), and the IPC bridge.

* **Initialization**: Sets up the OpenGL 4.5 Core context and configures the `Renderer2D`. If launched with `--shm`, it initializes a `FrameBuffer` linked to Shared Memory.
* **Robust IPC**: Processes commands using a line-buffered non-blocking `STDIN` reader. This ensures that high-frequency data (like mouse dragging) is processed reliably without dropping packets.
* **The Run Loop**:
1. **Poll Events**: Handles SDL window events.
2. **Process Commands**: Parses and executes incoming JSON commands immediately.
3. **Render Frame**: Clears the buffer and calls `Scene::OnUpdate`.
4. **Editor Overlays**: If in Editor Mode, renders the grid, origin, and selection box.
5. **Sync/Swap**: In Editor Mode, `glFinish()` is called to ensure memory consistency before Java reads the pixel buffer.
6. **Telemetry**: Performance stats (FPS, Draw Calls, Quads) are broadcast to `STDOUT` every 500ms.

### Entity Component System (ECS)
The engine uses **EnTT**, a fast, cache-friendly ECS library.

* **`Scene`**: The container for all game objects. It owns the `entt::registry`.
* **`OnUpdate(float ts)`**: Iterates through entities with a `SpriteRendererComponent` and submits them to the `Renderer2D`.
* **`PickEntity(float x, float y)`**: Performs AABB (Axis-Aligned Bounding Box) physics checks to find and select entities under the mouse cursor.
* **`Serialize()`**: Converts the entire registry into a formatted JSON string for saving.
* **`Components`**: Pure data structures.
* **`TagComponent`**: The entity's name (visible in Hierarchy).
* **`TransformComponent`**: Position (Translation), Rotation (Euler Z for 2D), and Scale.
* **`SpriteRendererComponent`**: Color (RGBA) and Texture reference.

### Rendering Pipeline (`Renderer2D.cpp`)
A high-performance batch-oriented 2D renderer.

* **Batching**: Quads and Lines are accumulated in CPU-side buffers and uploaded to the GPU in bulk.
* **Lines**: Supports a secondary batching path for debug lines, grids, and selection boxes.
* **Textures**: Supports up to 16 texture slots per draw call using a dynamic array sampler `u_Textures[16]`.

## Inter-Process Communication (IPC)

### Commands (Java -> C++)
Sent to the Engine's `STDIN` as single-line JSON.

| Action | Payload | Description |
| :--- | :--- | :--- |
| **`load_scene`** | `{"path": "..."}` | Clears the current scene and loads entities from a file. |
| **`select_entity`** | `{"id": 123}` | Selects an entity and requests its full details. |
| **`translate_selected`** | `{"dx": val, "dy": val}`| Moves the selected entity by a delta world amount. |
| **`rotate_selected`** | `{"da": val}` | Rotates the selected entity by a delta angle (radians). |
| **`scale_selected`** | `{"ds": val}` | Uniformly scales the selected entity by a delta amount. |
| **`update_component`** | `{"id": 1, ...}` | Directly updates a specific component field (e.g., Color). |
| **`create_entity`** | `{"name": "...", "sprite": bool}` | Spawns a new entity in the active registry. |
| **`delete_entity`** | `{"id": 123}` | Destroys the specified entity. |
| **`request_save`** | `{}` | Requests a full JSON dump of the scene state. |
| **`request_picking`** | `{"x": val, "y": val}` | Performs a hit test at normalized coordinates. |

### Telemetry (C++ -> Java)
Broadcast to `STDOUT` with the `[TELEMETRY]` prefix.

| Type | Payload | Description |
| :--- | :--- | :--- |
| **`scene_tree`** | `{"entities": [...]}` | The full hierarchy list. Sent on any scene change. |
| **`entity_details`** | `{"components": {...}}` | Full component state for the Inspector panel. |
| **`telemetry`** | `{"fps": 60, ...}` | Real-time performance and renderer stats. |
| **`scene_data_dump`** | `{"data": "..."}` | The raw JSON string of the scene, ready for disk writing. |

## Build System

* **CMake**: Manages the C++ build process.
* **Key Dependencies**: `SDL3`, `GLAD`, `EnTT`, `GLM`, `nlohmann/json`.
28 changes: 22 additions & 6 deletions Docs/JavaArchitecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@ This document provides an overview of the Java-based Editor for the Storming Eng
## Core Application Lifecycle

* **`EditorApp`**: The entry point for the Java application. It manages global themes (using FlatLaf), configures UI refinements, and handles the initial startup sequence (Splash Screen -> Project Selector -> Main Window).
* **`EngineLauncher`**: Responsible for the lifecycle of the C++ Storming Engine process. It handles launching with shared memory arguments, capturing engine logs, and graceful termination. Supports multiple log listeners for real-time broadcasting.
* **`EngineLauncher`**: Responsible for the lifecycle of the C++ Storming Engine process. It handles launching with shared memory arguments, capturing engine logs, and graceful termination. Supports multiple log and telemetry listeners for real-time data broadcasting.
* **`ProjectManager`**: Manages project history and discovery. It maintains a persistent "recent projects" list and automatically scans default directories (like `~/StormingProjects`) to find Storming projects created by the user.

## Window Management

* **`MainWindow`**: The central orchestrator of the editor's layout. It manages complex nested split panes, JetBrains-style sidebars, and the main workspace tabs.
* **`ProjectSelectorWindow`**: The initial launcher for the engine. Features a modern, animated interface for project management.
* **`MainWindow`**: The central orchestrator of the editor's layout. It manages complex nested split panes, JetBrains-style sidebars, and the main workspace tabs. It handles project and scene loading from disk.
* **`ProjectSelectorWindow`**: The initial launcher for the engine. Features a modern, animated interface for project management, including "New Project" and "Open Project" actions. It displays a list of recent and discovered projects.
* **`NewProjectDialog`**: A comprehensive modal dialog for creating new Storming projects. It handles:
* Template selection (Empty 2D, 2D Demo).
* Directory scaffolding (`assets/`, `scenes/`).
* Initial `.storm` and `main.storm_scene` file generation.
* Real-time path validation and preview.
* **`SimulationWindow`**: A dedicated debugging window for running engine simulations. Includes:
* Godot-inspired UI with integrated header and footer.
* Pulsating "LIVE" indicator.
* Collapsible **Mini-Console** linked to the engine output.
* **Performance Monitor** with real-time graphs (FPS, CPU, GPU, Memory) and hardware detection.
* **Performance Monitor** with real-time area-graphs (FPS, CPU, GPU, Memory) and hardware detection.
* Utility controls for **Always-on-Top**, **Screenshots**, and **Resolution Scaling**.
* **`SettingsWindow`**: A centralized configuration dialog with a searchable sidebar. Supports dynamic theme switching and categorized panels for Engine and Editor preferences.
* **`SplashWindow`**: A simple, stylized startup window displayed during initialization.
Expand All @@ -36,14 +42,24 @@ This document provides an overview of the Java-based Editor for the Storming Eng
| **`TerminalPanel`** | A multi-tabbed terminal emulator using JediTerm and Pty4j. | **Implemented** |
| **`SceneViewPanel`** | A real-time engine viewport utilizing JNA for shared memory image streaming. | **Implemented** |
| **`ConsolePanel`** | A stylized logging interface with level-based filtering and search. | **Implemented** |
| **`HierarchyPanel`** | Scene tree navigation and object management. Populates from `.storm_scene` files on disk and syncs live with the C++ engine during simulation. | **Implemented** |
| **`InspectorPanel`** | Property editor for scene objects. | **WIP (Placeholder)** |
| **`HierarchyPanel`** | Scene tree navigation and object management. | **WIP (Placeholder)** |
| **`GitPanel`** | Integrated version control interface. | **WIP (Placeholder)** |
| **`PRPanel`** | Pull Request management and detail tracking. | **WIP (Placeholder)** |
| **`AnalyzerPanel`** | Script and asset health analyzer. | **WIP (Placeholder)** |

## Project Management & `.storm` Format

The engine uses a JSON-based project descriptor with the `.storm` extension.
When creating a new project via the `NewProjectDialog`, the following structure is generated:
* `ProjectName/`
* `ProjectName.storm` (Project settings and main scene entry point)
* `assets/` (Directory for textures, scripts, and other resources)
* `scenes/`
* `main.storm_scene` (Initial scene data containing default entities like "Main Camera")

## Development Note (WIP Features)

As outlined in the [Roadmap](Roadmap.md), several high-level editor systems (Git, PR, Hierarchy, Inspector, and Analyzer) are currently in an early **Work-in-Progress (WIP)** state. These components serve as visual placeholders and utilize mock data to illustrate the final intended user experience. They will be incrementally integrated with the C++ engine and external providers in upcoming development phases.
As outlined in the [Roadmap](Roadmap.md), several high-level editor systems (Git, PR, Inspector, and Analyzer) are currently in an early **Work-in-Progress (WIP)** state. These components serve as visual placeholders and utilize mock data to illustrate the final intended user experience. They will be incrementally integrated with the C++ engine and external providers in upcoming development phases.

Telemetry data shown in the **Simulation Window** (FPS, CPU Load, etc.) is currently simulated or best-effort based on the JVM environment and will be fully linked to the engine's telemetry bridge in the future.
43 changes: 21 additions & 22 deletions Docs/Roadmap.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
# Storming Engine: 2026 Revival Roadmap

## Pre-Phase: Engine Startup (v2026.0.0)
* **[Done]** **Shared Memory (SHM) Pipeline:** Establish a high-speed pixel transfer between C++ Engine and Java Editor.
* **[Semi-Done]** **Embedded Mode:** Engine can run hidden (`--shm`) while streaming its output to the Editor's viewport.
* **[Next]** **JSON Command Protocol:** Use stdin/stdout for basic Editor -> Engine commands (e.g., Change Clear Color).
* **[Next]** **HAL Abstraction:** Move raw OpenGL code from `Application` into a dedicated `OpenGLRendererAPI` class.
* **[Next]** **Telemetry Bridge:** Engine reports FPS and Draw Call statistics back to the Editor's Console.

* **[REQUIRED]** **Auto Engine Compile:** Automatically make Storming Initalitize the Engine.
* **[Done]** **Shared Memory (SHM) Pipeline:** High-speed pixel transfer proven and stable.
* **[Done]** **Embedded Mode:** Engine runs headless and streams to Editor viewport.
* **[Done]** **C++ Engine Rewrite:** C++20, SDL3, and Data-Oriented foundation.
* **[Done]** **JSON Command Protocol:** Stdin/stdout bridge for Editor -> Engine commands.
* **[Done]** **Telemetry Bridge:** Real-time reporting of FPS, DC, and Quads.
* **[Done]** **Auto Engine Compile:** Editor automatically manages C++ builds.

## Phase 1: The Core Foundation (v2026.0.1)
* **[Redesigning]** Improved UI
* **[Semi-Done]** New high-performance directory structure for C++ Engine.
* **[Semi-Done]** Modern "IntelliJ-style" Java Editor with Dark Theme (FlatLaf).
* **[Semi-Done]** Hardware Abstraction Layer (HAL) for multi-backend rendering (OpenGL/Vulkan).
* **[Semi-Done]** Basic Engine Launcher "Play" bridge from Editor to Engine.
* **[Next]** **The `.storm` Project Format:** A JSON-based file system to track assets and scenes.
* **[Done]** Modern "IntelliJ-style" Java Editor.
* **[Done]** HAL/RHI abstraction for OpenGL 4.5.
* **[Done]** High-performance directory structure.
* **[Done]** **Rendering Compatibility:** Resolved invisible assets and WM maximization issues.
* **[In Progress]** **The `.storm` Project Format:** Implemented basic project creation and structure.

## Phase 2: The 2D World (v2026.0.2)
* **Entity Component System (ECS):** A clean C++ implementation to manage "Entities" (players, enemies, objects).
* **Renderer2D (OpenGL Backend):** Efficiently draw thousands of sprites using batching.
* **The Scene Tree:** Implement the "Hierarchy" in both the Engine (for logic) and the Editor (for editing).
* **Inspector Binding:** Ability to click an object in the Scene and change its position/color in the Editor's Inspector.
* **[Done]** **ECS Integration:** Deep integration of EnTT.
* **[Done]** **Texture & Sprite Support:** PNG/JPG loading and rendering.
* **[Done]** **The Scene Tree:** Syncing entity hierarchy between C++ and Java.
* **[Next]** **Inspector Binding:** Real-time property editing via the Editor's UI.
* **[Next]** **Renderer2D Batching:** Optimizing for 32+ texture slots.

## Phase 3: The Scripting Layer (v2026.0.3)
* **LUA/C# Integration:** Bringing back scripting. We'll decide between a lightweight LUA integration or a full C# (Mono/DotNet) runtime for game logic.
* **Hot Reload:** Change a script and see the results in the engine immediately without restarting.
* **LUA/C# Integration:** Flexible gameplay logic layer.
* **Hot Reload:** Instant logic updates.

## Phase 4: Advanced Graphics & 3D (v2026.0.4)
* **Vulkan Renderer implementation:** Complete the high-performance HAL backend.
* **3D Foundation:** Basic 3D math, Model loading (.obj/.fbx), and a simple PBR (Physically Based Rendering) shader.
* **Plugin API:** Allow users to write their own Editor tools in Java.
* **Vulkan Backend:** Full implementation of the Vulkan RHI for peak performance.
* **3D Foundation:** Basic 3D math, PBR shading, and model loading.
* **Plugin API:** Java-based API for expanding Editor functionality.
25 changes: 23 additions & 2 deletions Engine/2D/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ FetchContent_Declare(
entt
GIT_REPOSITORY https://github.com/skypjack/entt.git
GIT_TAG v3.13.0
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(entt)

Expand All @@ -27,19 +28,37 @@ FetchContent_Declare(
glad
GIT_REPOSITORY https://github.com/Dav1dde/glad.git
GIT_TAG v0.1.36
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(glad)
# Custom glad generation for OpenGL 4.5
# We don't need add_library here anymore if it exists

# 4. GLM (Math)
FetchContent_Declare(
glm
GIT_REPOSITORY https://github.com/g-truc/glm.git
GIT_TAG 0.9.9.8
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(glm)

# 5. nlohmann_json (Command Protocol)
FetchContent_Declare(
json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(json)

# 6. stb (Image Loading)
FetchContent_Declare(
stb
GIT_REPOSITORY https://github.com/nothings/stb.git
GIT_TAG master
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(stb)

# --- Sources ---
file(GLOB_RECURSE SOURCES
"src/*.cpp"
Expand All @@ -54,6 +73,7 @@ add_executable(StormingEngine ${SOURCES})
target_include_directories(StormingEngine PRIVATE
include
src
${stb_SOURCE_DIR}
)

# Link libraries
Expand All @@ -62,6 +82,7 @@ target_link_libraries(StormingEngine PRIVATE
EnTT::EnTT
glad
glm::glm
nlohmann_json::nlohmann_json
rt
)

Expand Down
48 changes: 37 additions & 11 deletions Engine/2D/include/Core/Log.hpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,47 @@
//
// Created by Batista on 9/11/2025.
//

#ifndef STORMING_LOG_H
#define STORMING_LOG_H

#pragma once

#include <memory>
#include <string>
#include <iostream>

namespace Storming {

/**
* Internal logging utility for the engine.
* Provides macros for various logging levels that output to STDOUT.
* The Java Editor listens for specific prefixes (e.g., [Error]) to colorize output.
*/
class Log {
public:
enum class Level {
Trace, Info, Warn, Error, Fatal
};

static void Init();
static void Info(const std::string& message);
static void Error(const std::string& message);

/**
* Generic print function used by the logging macros.
* Prepends appropriate prefixes for Editor log level detection.
*/
template<typename... Args>
static void Print(Level level, const std::string& fmt, Args&&... args) {
std::string prefix;
switch (level) {
case Level::Trace: prefix = "[Trace] "; break;
case Level::Info: prefix = "[Engine] "; break;
case Level::Warn: prefix = "[Warning] "; break;
case Level::Error: prefix = "[Error] "; break;
case Level::Fatal: prefix = "[Fatal] "; break;
}
std::cout << prefix << fmt << std::endl;
}
};
}

}

#endif //STORMING_LOG_H
// Core logging macros
#define ST_TRACE(...) ::Storming::Log::Print(::Storming::Log::Level::Trace, __VA_ARGS__)
#define ST_INFO(...) ::Storming::Log::Print(::Storming::Log::Level::Info, __VA_ARGS__)
#define ST_WARN(...) ::Storming::Log::Print(::Storming::Log::Level::Warn, __VA_ARGS__)
#define ST_ERROR(...) ::Storming::Log::Print(::Storming::Log::Level::Error, __VA_ARGS__)
#define ST_FATAL(...) ::Storming::Log::Print(::Storming::Log::Level::Fatal, __VA_ARGS__)
53 changes: 47 additions & 6 deletions Engine/2D/include/ECS/Component.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,49 @@
//
// Created by Batista on 9/11/2025.
//
#pragma once

#ifndef STORMING_COMPONENT_H
#define STORMING_COMPONENT_H
#include <glm/glm.hpp>
#include <string>
#include <memory>
#include "Rendering/Texture.hpp"

#endif //STORMING_COMPONENT_H
namespace Storming {

/**
* Stores the name/identifier of an entity.
* Used for the Hierarchy panel in the Editor.
*/
struct TagComponent {
std::string Tag;

TagComponent() = default;
TagComponent(const TagComponent&) = default;
TagComponent(const std::string& tag) : Tag(tag) {}
};

/**
* Defines the position, orientation, and size of an entity in 3D space.
* While the engine is 2D, a 3D vector is used for Z-layering support.
*/
struct TransformComponent {
glm::vec3 Translation = { 0.0f, 0.0f, 0.0f };
glm::vec3 Rotation = { 0.0f, 0.0f, 0.0f }; // Euler angles
glm::vec3 Scale = { 1.0f, 1.0f, 1.0f };

TransformComponent() = default;
TransformComponent(const TransformComponent&) = default;
TransformComponent(const glm::vec3& translation) : Translation(translation) {}
};

/**
* Allows an entity to be rendered as a textured or colored quad.
* Color acts as a tint if a texture is provided.
*/
struct SpriteRendererComponent {
glm::vec4 Color{ 1.0f, 1.0f, 1.0f, 1.0f };
std::shared_ptr<Texture2D> Texture;

SpriteRendererComponent() = default;
SpriteRendererComponent(const SpriteRendererComponent&) = default;
SpriteRendererComponent(const glm::vec4& color) : Color(color) {}
};

}
Loading
Loading