Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

Add CMake build system with Linux support and Pong test game#1

Open
killerdevildog wants to merge 2 commits intoStarEngine:developfrom
killerdevildog:feature/cmake-build-system
Open

Add CMake build system with Linux support and Pong test game#1
killerdevildog wants to merge 2 commits intoStarEngine:developfrom
killerdevildog:feature/cmake-build-system

Conversation

@killerdevildog
Copy link

Summary

This PR adds a CMake build system for StarEngine that successfully builds the engine as a static library (libstarengine.a) on Linux. It also includes a fully playable Pong test game that links against the engine, proving the build system works end-to-end.

What was done

CMake Build System

  • Added root CMakeLists.txt and src/CMakeLists.txt defining the starengine static library target
  • All ~95 source files organized into logical groups (Core, Actions, AI, Components, Graphics, UI, Helpers, Input, Objects, Physics, Scenes, Sound, ThirdParty)
  • Platform-conditional compilation for Windows-only files (Console.cpp, Window.cpp) and Android-only files (Resource.cpp, HelpersAndroid.cpp)
  • System dependencies resolved via CMake/pkg-config: SDL2, SDL2_mixer, GLEW, OpenGL, Freetype, libpng
  • Bundled GLM (header-only) and PugiXML included directly

Linux Portability Fixes

The original codebase targeted Windows (MSVC) and Android (NDK) only. The following changes were needed to compile on Linux/GCC:

  • Path separators: Fixed Windows-style backslash \ in #include directives to forward slashes across all source files
  • Case-sensitive filenames: Fixed mismatches (SpriteSheet.hSpritesheet.h, FilePath.hFilepath.h, etc.)
  • Platform guards: The codebase used #ifdef DESKTOP ... #else (assume Android) throughout. Changed to #elif defined(ANDROID) to avoid compiling Android code on Linux
  • WGL-specific code: Moved Windows OpenGL extension code (wglext.h, PFNWGLSWAPINTERVALEXTPROC) from #ifdef DESKTOP to #ifdef _WIN32
  • Missing types: Added typedef uint8_t byte and tfopen() wrapper for Linux
  • MSVC extensions: Replaced unordered_multimap::lower_bound/upper_bound (MSVC-only) with standard equal_range on non-Windows
  • Logger: Added Linux implementation using std::cerr output
  • GL includes: Fixed include paths for Linux (<GL/glew.h>, <GL/gl.h>)

Test Game: Star Pong

A complete Pong game in test/pong/ that links against libstarengine and uses engine subsystems (Logger, TimeManager):

  • Main menu with 1P vs AI and 2P local multiplayer
  • AI difficulty selection (Easy / Medium / Hard / Impossible)
  • AI with ball trajectory prediction, configurable reaction time and aiming error
  • Visual polish: serve countdown, ball trail, paddle glow, screen shake
  • Pause and game-over screens
  • Custom bitmap font renderer for all UI text

How to build

# Install dependencies (Ubuntu/Debian)
sudo apt install libsdl2-dev libsdl2-mixer-dev libglew-dev libfreetype-dev libpng-dev

# Configure and build
cmake -S . -B build -DSTARENGINE_BUILD_EXAMPLES=ON
cmake --build build -j$(nproc)

# Run the test game
./build/bin/pong

What is NOT in this PR

  • Windows build: The existing MSVC/Visual Studio project files are untouched. CMake support for Windows (FindPackage paths, MSVC flags) can be added in a follow-up PR.
  • Android build: The NDK/Gradle build integration is not included and would be a separate effort.
  • Linux input handling: The InputManager has no SDL-based keyboard/gamepad input for Linux yet — the Pong game handles input directly via SDL. Wiring SDL events into InputManager for Linux would be a future PR.

These platform integrations are straightforward to add incrementally now that the CMake foundation is in place.

- Add root CMakeLists.txt and src/CMakeLists.txt for building starengine static library
- Fix Windows-style backslash path separators in #include directives
- Fix case-sensitive filename mismatches (SpriteSheet->Spritesheet, FilePath->Filepath)
- Add Linux platform support: byte typedef, tfopen(), Logger stderr output
- Guard WGL-specific code with _WIN32 instead of DESKTOP
- Fix #ifdef DESKTOP/#else pattern to use #elif defined(ANDROID) throughout
- Fix Dictionary.inl lower_bound/upper_bound for non-MSVC compilers (use equal_range)
- Guard Windows-only InputManager methods (keyboard, gamepad) with _WIN32
- Add build/ and lib/ to .gitignore
- System dependencies: SDL2, SDL2_mixer, GLEW, OpenGL, Freetype, libpng
- Add test/pong/ with a fully playable Pong game linked against starengine
- Main menu with 1P vs AI and 2P local multiplayer modes
- AI difficulty selection: Easy, Medium, Hard, Impossible
- AI uses ball trajectory prediction with configurable reaction time and error
- Serve countdown, ball trail, paddle glow, screen shake effects
- Pause screen and game-over screen with rematch option
- Bitmap font rendering for all UI text (A-Z, 0-9, symbols)
- Fix GraphicsManager.h GL include guards for Linux (DESKTOP else branch)
- Enable STARENGINE_BUILD_EXAMPLES by default in root CMakeLists.txt
- Add StarLog.txt to .gitignore
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant