Thanks to visit codestin.com
Credit goes to github.com

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
53 changes: 49 additions & 4 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ This document explains the current state and what would be needed for a full bui

### What Still Needs Work

1. **C++ Template Compatibility** - The memory management templates use old MSVC syntax that doesn't compile on modern GCC
2. **Graphics Implementation** - DirectX 8 or modern OpenGL/Vulkan rendering
3. **Complete Audio Implementation** - OpenAL, FMOD, or similar
1. **C++ Template Compatibility** - The memory management templates use old MSVC syntax that doesn't compile on modern GCC (being addressed in separate PR)
2. **Graphics Implementation** - Backend architecture documented and integrated into CMake, stub implementations exist for DirectX/OpenGL, Vulkan implementation exists but needs integration
3. **Complete Audio Implementation** - Backend architecture documented and integrated into CMake, stub implementations exist for SDL2/OpenAL/FMOD
4. **Asset Pipeline** - Convert console assets to PC formats

## Build Infrastructure Added
Expand All @@ -47,6 +47,33 @@ A `CMakeLists.txt` has been created that:
- Collects source files automatically from Win32/Wn32 directories
- Sets up include directories
- Provides debug/release build configurations
- **NEW**: Supports multiple graphics backends (Vulkan, DirectX, OpenGL)
- **NEW**: Supports multiple audio backends (SDL2, OpenAL, FMOD)

#### Backend Architecture

The build system now supports configurable graphics and audio backends:

**Graphics Backend Options:**
```bash
cmake -DUSE_VULKAN_RENDERER=ON .. # Vulkan (recommended, cross-platform)
cmake -DUSE_DIRECTX_RENDERER=ON .. # DirectX (Windows only)
cmake -DUSE_OPENGL_RENDERER=ON .. # OpenGL (cross-platform)
```

**Audio Backend Options:**
```bash
cmake -DAUDIO_BACKEND=SDL2 .. # SDL2_mixer (recommended, simple API)
cmake -DAUDIO_BACKEND=OpenAL .. # OpenAL (3D positional audio)
cmake -DAUDIO_BACKEND=FMOD .. # FMOD (professional, requires license)
```

**Combined Example:**
```bash
cmake -DUSE_VULKAN_RENDERER=ON -DAUDIO_BACKEND=SDL2 ..
```

See `docs/BACKEND_ARCHITECTURE.md` for detailed backend documentation.

### 2. Case-Sensitivity Fixes

Expand Down Expand Up @@ -174,13 +201,31 @@ This would require:

### Step 1: Configure

**Basic configuration (no backends):**
```bash
cd /path/to/thug
mkdir build && cd build
cmake ..
```

This will succeed - CMake can configure the build.
**With graphics backend:**
```bash
cmake -DUSE_VULKAN_RENDERER=ON ..
# or
cmake -DUSE_OPENGL_RENDERER=ON ..
```

**With audio backend:**
```bash
cmake -DAUDIO_BACKEND=SDL2 ..
```

**With both:**
```bash
cmake -DUSE_VULKAN_RENDERER=ON -DAUDIO_BACKEND=SDL2 ..
```

This will succeed - CMake can configure the build and will display a summary showing selected backends.

### Step 2: Build

Expand Down
181 changes: 169 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 99)

# Renderer options
option(USE_VULKAN_RENDERER "Use Vulkan renderer backend (experimental)" OFF)
# ============================================================================
# Backend Architecture Configuration
# ============================================================================

# Graphics Backend Options
option(USE_VULKAN_RENDERER "Use Vulkan renderer backend (recommended)" OFF)
option(USE_DIRECTX_RENDERER "Use DirectX renderer backend (Windows only)" OFF)
option(USE_OPENGL_RENDERER "Use OpenGL renderer backend" OFF)

# Audio Backend Selection
set(AUDIO_BACKEND "None" CACHE STRING "Audio backend to use (SDL2/OpenAL/FMOD/None)")
set_property(CACHE AUDIO_BACKEND PROPERTY STRINGS SDL2 OpenAL FMOD None)

# Compiler options
if(MSVC)
Expand Down Expand Up @@ -49,21 +59,117 @@ include_directories(
${CMAKE_SOURCE_DIR}/Code
)

# ============================================================================
# Graphics Backend Configuration
# ============================================================================

# Validate graphics backend selection
set(GRAPHICS_BACKEND_COUNT 0)
if(USE_VULKAN_RENDERER)
math(EXPR GRAPHICS_BACKEND_COUNT "${GRAPHICS_BACKEND_COUNT} + 1")
endif()
if(USE_DIRECTX_RENDERER)
math(EXPR GRAPHICS_BACKEND_COUNT "${GRAPHICS_BACKEND_COUNT} + 1")
endif()
if(USE_OPENGL_RENDERER)
math(EXPR GRAPHICS_BACKEND_COUNT "${GRAPHICS_BACKEND_COUNT} + 1")
endif()

# Ensure only one graphics backend is selected
if(GRAPHICS_BACKEND_COUNT GREATER 1)
message(FATAL_ERROR "Multiple graphics backends selected. Please select only one of: USE_VULKAN_RENDERER, USE_DIRECTX_RENDERER, USE_OPENGL_RENDERER")
endif()

# Platform-specific backend validation
if(USE_DIRECTX_RENDERER AND NOT WIN32)
message(FATAL_ERROR "DirectX renderer is only supported on Windows")
endif()

# Vulkan renderer configuration
if(USE_VULKAN_RENDERER)
message(STATUS "Vulkan renderer enabled (experimental)")
message(STATUS "Graphics Backend: Vulkan (recommended)")
add_definitions(-DUSE_VULKAN_RENDERER)

# Try to find Vulkan SDK (optional, for future full implementation)
find_package(Vulkan QUIET)
if(Vulkan_FOUND)
message(STATUS "Vulkan SDK found: ${Vulkan_LIBRARY}")
message(STATUS " Vulkan SDK found: ${Vulkan_LIBRARY}")
include_directories(${Vulkan_INCLUDE_DIRS})
else()
message(STATUS "Vulkan SDK not found (optional for current implementation)")
message(STATUS " Vulkan SDK not found (optional for current implementation)")
endif()
endif()

# DirectX renderer configuration
if(USE_DIRECTX_RENDERER)
message(STATUS "Graphics Backend: DirectX (Windows only)")
add_definitions(-DUSE_DIRECTX_RENDERER)
message(STATUS " DirectX implementation is a stub - requires DirectX SDK integration")
endif()

# OpenGL renderer configuration
if(USE_OPENGL_RENDERER)
message(STATUS "Graphics Backend: OpenGL (cross-platform)")
add_definitions(-DUSE_OPENGL_RENDERER)

# Try to find OpenGL
find_package(OpenGL QUIET)
if(OPENGL_FOUND)
message(STATUS " OpenGL found: ${OPENGL_LIBRARIES}")
include_directories(${OPENGL_INCLUDE_DIR})
else()
message(STATUS " OpenGL not found (optional for current implementation)")
endif()
endif()

# Default message if no graphics backend is selected
if(GRAPHICS_BACKEND_COUNT EQUAL 0)
message(STATUS "Graphics Backend: None selected (using platform default)")
message(STATUS " Available options:")
message(STATUS " -DUSE_VULKAN_RENDERER=ON (recommended, cross-platform)")
if(WIN32)
message(STATUS " -DUSE_DIRECTX_RENDERER=ON (Windows only)")
endif()
message(STATUS " -DUSE_OPENGL_RENDERER=ON (cross-platform)")
Comment on lines +129 to +133
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The graphics backend options display logic is duplicated. Consider extracting this into a function or variable to improve maintainability and ensure consistency across the codebase.

Copilot uses AI. Check for mistakes.
endif()

# ============================================================================
# Audio Backend Configuration
# ============================================================================

# Validate and configure audio backend
if(NOT AUDIO_BACKEND STREQUAL "None")
message(STATUS "Audio Backend: ${AUDIO_BACKEND}")

if(AUDIO_BACKEND STREQUAL "SDL2")
add_definitions(-DUSE_SDL2_AUDIO)
message(STATUS " SDL2_mixer implementation is a stub - requires SDL2_mixer integration")
message(STATUS " Install: sudo apt install libsdl2-mixer-dev (Linux)")
message(STATUS " brew install sdl2_mixer (macOS)")

elseif(AUDIO_BACKEND STREQUAL "OpenAL")
add_definitions(-DUSE_OPENAL_AUDIO)
message(STATUS " OpenAL implementation is a stub - requires OpenAL integration")
message(STATUS " Install: sudo apt install libopenal-dev (Linux)")
message(STATUS " brew install openal-soft (macOS)")

elseif(AUDIO_BACKEND STREQUAL "FMOD")
add_definitions(-DUSE_FMOD_AUDIO)
message(STATUS " FMOD implementation is a stub - requires FMOD SDK")
message(STATUS " Download: https://www.fmod.com/download")
message(STATUS " Note: FMOD requires a commercial license for released games")

else()
message(FATAL_ERROR "Invalid AUDIO_BACKEND: ${AUDIO_BACKEND}. Valid options: SDL2, OpenAL, FMOD, None")
endif()
else()
message(STATUS "Audio Backend: None selected (using platform default stubs)")
message(STATUS " Available options:")
message(STATUS " -DAUDIO_BACKEND=SDL2 (recommended, simple API, free)")
message(STATUS " -DAUDIO_BACKEND=OpenAL (3D positional audio, free)")
message(STATUS " -DAUDIO_BACKEND=FMOD (professional features, requires license)")
Comment on lines +167 to +170
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The audio backend options display logic is also duplicated with the validation section above. Consider consolidating these option displays to reduce code duplication.

Copilot uses AI. Check for mistakes.
endif()

# Add subsystem directories (modular CMake structure)
# Each subsystem has its own CMakeLists.txt
add_subdirectory(Code/Core)
Expand Down Expand Up @@ -104,17 +210,68 @@ elseif(APPLE)
target_link_libraries(thug pthread dl m)
endif()

# Link Vulkan if available and enabled
# Link graphics backend libraries
if(USE_VULKAN_RENDERER AND Vulkan_FOUND)
target_link_libraries(thug ${Vulkan_LIBRARIES})
message(STATUS "Vulkan library linked: ${Vulkan_LIBRARIES}")
message(STATUS "Linking Vulkan library: ${Vulkan_LIBRARIES}")
endif()

if(USE_OPENGL_RENDERER AND OPENGL_FOUND)
target_link_libraries(thug ${OPENGL_LIBRARIES})
message(STATUS "Linking OpenGL library: ${OPENGL_LIBRARIES}")
endif()

if(USE_DIRECTX_RENDERER)
if(WIN32)
# DirectX libraries (will be linked when implementation is complete)
# target_link_libraries(thug d3d9 d3dx9)
message(STATUS "DirectX linking will be enabled when implementation is complete")
endif()
endif()

# Link audio backend libraries (when implementations are complete)
if(AUDIO_BACKEND STREQUAL "SDL2")
# find_package(SDL2 REQUIRED)
# find_package(SDL2_mixer REQUIRED)
# target_link_libraries(thug SDL2::SDL2 SDL2::SDL2_mixer)
message(STATUS "SDL2_mixer linking will be enabled when implementation is complete")
elseif(AUDIO_BACKEND STREQUAL "OpenAL")
# find_package(OpenAL REQUIRED)
# target_link_libraries(thug ${OPENAL_LIBRARY})
message(STATUS "OpenAL linking will be enabled when implementation is complete")
elseif(AUDIO_BACKEND STREQUAL "FMOD")
# Manual FMOD linking will be required
message(STATUS "FMOD linking will be enabled when implementation is complete")
endif()

# Installation
install(TARGETS thug DESTINATION bin)

# Print build information
message(STATUS "Building THUG for ${PLATFORM_NAME}")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "C++ Compiler: ${CMAKE_CXX_COMPILER}")
message(STATUS "C Compiler: ${CMAKE_C_COMPILER}")
# ============================================================================
# Build Summary
# ============================================================================
message(STATUS "")
message(STATUS "=================================================================")
message(STATUS "THUG Build Configuration Summary")
message(STATUS "=================================================================")
message(STATUS "Platform: ${PLATFORM_NAME}")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "C++ Compiler: ${CMAKE_CXX_COMPILER}")
message(STATUS "C Compiler: ${CMAKE_C_COMPILER}")
message(STATUS "")
if(USE_VULKAN_RENDERER)
message(STATUS "Graphics: Vulkan (recommended)")
elseif(USE_DIRECTX_RENDERER)
message(STATUS "Graphics: DirectX (Windows)")
elseif(USE_OPENGL_RENDERER)
message(STATUS "Graphics: OpenGL (cross-platform)")
else()
message(STATUS "Graphics: Platform default (no backend selected)")
endif()
if(NOT AUDIO_BACKEND STREQUAL "None")
message(STATUS "Audio: ${AUDIO_BACKEND}")
else()
message(STATUS "Audio: Platform default (no backend selected)")
endif()
message(STATUS "=================================================================")
message(STATUS "")
12 changes: 12 additions & 0 deletions Code/Gel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ if(WIN32)
target_compile_definitions(thug_gel PRIVATE __PLAT_WN32__)
endif()

# Audio backend configuration
if(AUDIO_BACKEND STREQUAL "SDL2")
target_compile_definitions(thug_gel PRIVATE USE_SDL2_AUDIO)
message(STATUS " Gel: SDL2_mixer audio backend enabled")
elseif(AUDIO_BACKEND STREQUAL "OpenAL")
target_compile_definitions(thug_gel PRIVATE USE_OPENAL_AUDIO)
message(STATUS " Gel: OpenAL audio backend enabled")
elseif(AUDIO_BACKEND STREQUAL "FMOD")
target_compile_definitions(thug_gel PRIVATE USE_FMOD_AUDIO)
message(STATUS " Gel: FMOD audio backend enabled")
endif()

# Debug configurations
if(CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(thug_gel PRIVATE
Expand Down
16 changes: 15 additions & 1 deletion Code/Gfx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,26 @@ if(WIN32)
target_compile_definitions(thug_gfx PRIVATE __PLAT_WN32__)
endif()

# Vulkan renderer support
# Graphics backend configuration
if(USE_VULKAN_RENDERER)
target_compile_definitions(thug_gfx PRIVATE USE_VULKAN_RENDERER)
if(Vulkan_FOUND)
target_include_directories(thug_gfx PRIVATE ${Vulkan_INCLUDE_DIRS})
endif()
message(STATUS " Gfx: Vulkan renderer enabled")
endif()

if(USE_DIRECTX_RENDERER)
target_compile_definitions(thug_gfx PRIVATE USE_DIRECTX_RENDERER)
message(STATUS " Gfx: DirectX renderer enabled")
endif()

if(USE_OPENGL_RENDERER)
target_compile_definitions(thug_gfx PRIVATE USE_OPENGL_RENDERER)
if(OPENGL_FOUND)
target_include_directories(thug_gfx PRIVATE ${OPENGL_INCLUDE_DIR})
endif()
message(STATUS " Gfx: OpenGL renderer enabled")
endif()

# Debug configurations
Expand Down
Loading