Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
28c63cf
Separate tools folder
damacaa Jul 19, 2026
a39f827
Unified CMakeLists of all projects
damacaa Jul 19, 2026
0af4d27
Added web builds and diagnostics test to validate builds
damacaa Jul 19, 2026
7d80206
Format, format script and format test
damacaa Jul 19, 2026
de30163
Trying pre-commit
damacaa Jul 19, 2026
db90d61
Fix format
damacaa Jul 19, 2026
d22d7a6
Trying to fix builds. Use static SDL3 where possible always.
damacaa Jul 19, 2026
fc47768
Update CMakeLists.txt
damacaa Jul 19, 2026
fcf5353
Compilation error on windows
damacaa Jul 19, 2026
85d4a01
Fixed stupid log stupid macros stupid conditional compilation
damacaa Jul 19, 2026
84475f6
Trying to make this worl
damacaa Jul 19, 2026
9de000e
Update build-web.yml
damacaa Jul 19, 2026
e38ff38
Update build-web.yml
damacaa Jul 19, 2026
5e90ce8
Web build should copy index.html now
damacaa Jul 20, 2026
1d52f26
Update build-web.yml
damacaa Jul 20, 2026
0f685fb
Update build-web.yml
damacaa Jul 20, 2026
cf5c46c
Updated CMake files
damacaa Jul 23, 2026
39bc8a5
Combined build-web.yml into cmake-multi-platform.yml using a matrix …
damacaa Jul 23, 2026
f403a8d
ci: fix emsdk cache error, windows artifact step, and node warnings
damacaa Jul 23, 2026
161acac
fix(web): ensure BUILD_WEB scope sets OUTPUT_NAME index and guarantee…
damacaa Jul 23, 2026
25249dd
fix(web): set target SUFFIX .html to force emcc to generate index.htm…
damacaa Jul 23, 2026
398c3e1
feat(web): add customizable src/index.html templates for all examples…
damacaa Jul 23, 2026
14c8cef
itch.io deploy action with Butler
damacaa Jul 24, 2026
ba85438
Cleaned type warnings
damacaa Jul 24, 2026
ab227b0
Merge branch 'chore/cleanup' of https://github.com/damacaa/weird-engi…
damacaa Jul 24, 2026
5af12bf
Improved sample scenes
damacaa Jul 24, 2026
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
120 changes: 102 additions & 18 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,121 @@ on:

env:
BUILD_TYPE: Release
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: "true"
ACTIONS_RUNNER_FORCE_NODE24: "true"
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-2025, ubuntu-latest]

runs-on: ${{ matrix.os }}
include:
- name: Windows
os: windows-latest
target: windows
- name: Linux
os: ubuntu-latest
target: linux
- name: Web (WASM)
os: ubuntu-22.04
target: web

steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Ensure submodules are up-to-date
run: git submodule update --init --recursive

- name: Check submodulesversions
run: git submodule status

# ------------------------------------------------------------------------
# Linux Dependencies
# ------------------------------------------------------------------------
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt update && sudo apt install -y cmake g++ make xorg-dev libgl1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
if: matrix.target == 'linux'
run: sudo apt update && sudo apt install -y cmake g++ make xorg-dev libgl1-mesa-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev xvfb

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
# ------------------------------------------------------------------------
# Web / Emscripten Dependencies
# ------------------------------------------------------------------------
- name: Setup Emscripten (Web)
if: matrix.target == 'web'
uses: mymindstorm/setup-emsdk@v14
with:
version: latest

# ------------------------------------------------------------------------
# Desktop Builds (Windows & Linux)
# ------------------------------------------------------------------------
- name: Configure CMake (Desktop)
if: matrix.target != 'web'
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DWEIRD_ENGINE_BUILD_EXAMPLES=ON -DWEIRD_TEST_HOOKS=ON

- name: Build
- name: Build (Desktop)
if: matrix.target != 'web'
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest -C ${{env.BUILD_TYPE}}
- name: Test (Linux)
if: matrix.target == 'linux'
working-directory: ${{github.workspace}}/build/examples/sample-scenes
env:
WEIRD_AUTO_QUIT_SECONDS: 3
WEIRD_SCREENSHOT_FRAME: 10
run: xvfb-run -a ./WeirdSamples

- name: Upload Test Artifacts (Linux)
if: matrix.target == 'linux' && always()
uses: actions/upload-artifact@v4
with:
name: test-artifacts-${{ matrix.target }}
path: |
${{github.workspace}}/build/examples/sample-scenes/log.txt
${{github.workspace}}/build/examples/sample-scenes/screenshot_*.bmp
${{github.workspace}}/build/examples/sample-scenes/Release/log.txt
${{github.workspace}}/build/examples/sample-scenes/Release/screenshot_*.bmp

# ------------------------------------------------------------------------
# Web Build (Emscripten / WASM)
# ------------------------------------------------------------------------
- name: Build WeirdSamples for Web
if: matrix.target == 'web'
run: |
mkdir build && cd build
emcmake cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DWEIRD_ENGINE_BUILD_EXAMPLES=ON \
-DBUILD_WEB=ON \
-DCMAKE_C_FLAGS="-pthread" \
-DCMAKE_CXX_FLAGS="-pthread" \
-DCMAKE_EXECUTABLE_SUFFIX=".html" \
-DCMAKE_EXE_LINKER_FLAGS="-pthread -sPTHREAD_POOL_SIZE=4 -sINITIAL_MEMORY=33554432 -sMAX_WEBGL_VERSION=2 -sMIN_WEBGL_VERSION=2 --preload-file ${{github.workspace}}/examples/sample-scenes/assets@/assets --preload-file ${{github.workspace}}/src/weird-renderer/fonts@/fonts --preload-file ${{github.workspace}}/src/weird-renderer/shaders@/shaders"
emmake make WeirdSamples

- name: Prepare Web Artifact
if: matrix.target == 'web'
run: |
mkdir -p game_export
# Copy generated outputs (index.* or WeirdSamples.*)
cp build/examples/sample-scenes/index.* game_export/ 2>/dev/null || true
cp build/examples/sample-scenes/WeirdSamples.* game_export/ 2>/dev/null || true

# Guarantee index.html exists in game_export/
if [ ! -f game_export/index.html ]; then
if [ -f game_export/WeirdSamples.html ]; then
cp game_export/WeirdSamples.html game_export/index.html
elif [ -f game_export/index.js ]; then
echo '<!DOCTYPE html><html><head><meta charset="utf-8"><title>WeirdEngine Web</title><style>html,body{margin:0;padding:0;width:100%;height:100%;background:#000;overflow:hidden;display:flex;justify-content:center;align-items:center;}canvas{width:100%;height:100%;outline:none;border:0;}</style></head><body><canvas id="canvas" oncontextmenu="event.preventDefault()"></canvas><script>var Module={canvas:document.getElementById("canvas")};</script><script src="index.js"></script></body></html>' > game_export/index.html
fi
fi

cp -r build/examples/sample-scenes/assets game_export/ 2>/dev/null || true
cp -r build/examples/sample-scenes/fonts game_export/ 2>/dev/null || true
cp -r build/examples/sample-scenes/shaders game_export/ 2>/dev/null || true

- name: Upload Web Artifact
if: matrix.target == 'web'
uses: actions/upload-artifact@v4
with:
name: weird-engine-web-sample
path: game_export/
74 changes: 74 additions & 0 deletions .github/workflows/deploy-itch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Deploy to itch.io

on:
# Run manually from the Actions tab
workflow_dispatch:
# Optionally also run when you push a version tag (e.g. v1.0)
# push:
# tags:
# - 'v*'

env:
BUILD_TYPE: Release

jobs:
build-and-deploy:
name: Build Web & Push to itch.io
runs-on: ubuntu-22.04

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

# ------------------------------------------------------------------------
# Build the Web (Emscripten / WASM) version
# ------------------------------------------------------------------------
- name: Setup Emscripten
uses: mymindstorm/setup-emsdk@v14
with:
version: latest

- name: Build WeirdSamples for Web
run: |
mkdir build && cd build
emcmake cmake .. \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DWEIRD_ENGINE_BUILD_EXAMPLES=ON \
-DBUILD_WEB=ON \
-DCMAKE_C_FLAGS="-pthread" \
-DCMAKE_CXX_FLAGS="-pthread" \
-DCMAKE_EXECUTABLE_SUFFIX=".html" \
-DCMAKE_EXE_LINKER_FLAGS="-pthread -sPTHREAD_POOL_SIZE=4 -sINITIAL_MEMORY=33554432 -sMAX_WEBGL_VERSION=2 -sMIN_WEBGL_VERSION=2 --preload-file ${{github.workspace}}/examples/sample-scenes/assets@/assets --preload-file ${{github.workspace}}/src/weird-renderer/fonts@/fonts --preload-file ${{github.workspace}}/src/weird-renderer/shaders@/shaders"
emmake make WeirdSamples

- name: Prepare Web Artifact
run: |
mkdir -p game_export
cp build/examples/sample-scenes/index.* game_export/ 2>/dev/null || true
cp build/examples/sample-scenes/WeirdSamples.* game_export/ 2>/dev/null || true

if [ ! -f game_export/index.html ]; then
if [ -f game_export/WeirdSamples.html ]; then
cp game_export/WeirdSamples.html game_export/index.html
elif [ -f game_export/index.js ]; then
echo '<!DOCTYPE html><html><head><meta charset="utf-8"><title>WeirdEngine Web</title><style>html,body{margin:0;padding:0;width:100%;height:100%;background:#000;overflow:hidden;display:flex;justify-content:center;align-items:center;}canvas{width:100%;height:100%;outline:none;border:0;}</style></head><body><canvas id="canvas" oncontextmenu="event.preventDefault()"></canvas><script>var Module={canvas:document.getElementById("canvas")};</script><script src="index.js"></script></body></html>' > game_export/index.html
fi
fi

cp -r build/examples/sample-scenes/assets game_export/ 2>/dev/null || true
cp -r build/examples/sample-scenes/fonts game_export/ 2>/dev/null || true
cp -r build/examples/sample-scenes/shaders game_export/ 2>/dev/null || true

# ------------------------------------------------------------------------
# Publish to itch.io via Butler
# ------------------------------------------------------------------------
- name: Setup Butler
uses: remarkablegames/setup-butler@v2

- name: Push to itch.io
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
run: butler push ./game_export/ damaca/weird-engine:html
22 changes: 22 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Clang Format Check

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
format-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Run pre-commit
uses: pre-commit/action@v3.0.1
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.8 # Force this exact version for everyone
hooks:
- id: clang-format
# Removed types_or to ensure it catches custom shader extensions (.frag, .vert)
files: \.(h|cpp|glsl|frag|vert)$
exclude: ^(third-party|build|build-muos|dist-muos|\.git)/
53 changes: 36 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10)

project(WeirdEngine)

execute_process(COMMAND git submodule update --init --recursive)
execute_process(COMMAND git submodule update --init --recursive WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -60,6 +60,10 @@ target_include_directories(imgui
${IMGUI_DIR}/backends
${CMAKE_CURRENT_SOURCE_DIR}/third-party/SDL/include
)
target_link_libraries(imgui PRIVATE glad)
if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN)
target_link_libraries(imgui PRIVATE GLESv2 EGL dl)
endif()
endif()

target_include_directories(${PROJECT_NAME}
Expand All @@ -78,37 +82,41 @@ target_include_directories(glad

# SDL3 setup
# FORCE SDL3 to build as a STATIC library.
# This prevents the creation of libSDL3.so and embeds the code
# directly into your engine/game.
set(SDL_SHARED ON CACHE BOOL "Build SDL shared library" FORCE)
set(SDL_STATIC OFF CACHE BOOL "Build SDL static library" FORCE)
set(SDL_DEPS_SHARED ON CACHE BOOL "Load dependencies dynamically" FORCE)
set(SDL_KMSDRM_SHARED ON CACHE BOOL "Dynamically load KMS DRM support" FORCE)
set(SDL_SHARED OFF CACHE BOOL "Build SDL shared library" FORCE)
set(SDL_STATIC ON CACHE BOOL "Build SDL static library" FORCE)

if(EMSCRIPTEN)
set(SDL_DEPS_SHARED OFF CACHE BOOL "Load dependencies dynamically" FORCE)
set(SDL_KMSDRM_SHARED OFF CACHE BOOL "Dynamically load KMS DRM support" FORCE)
else()
set(SDL_DEPS_SHARED ON CACHE BOOL "Load dependencies dynamically" FORCE)
set(SDL_KMSDRM_SHARED ON CACHE BOOL "Dynamically load KMS DRM support" FORCE)
endif()
# Add dependencies
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/third-party/SDL)

# Force SDL3 to dynamically load KMSDRM libraries via dlopen instead of hard-linking.
# This is necessary because cmake_dependent_option overrides our FORCE cache entries.
if(TARGET SDL3-shared)
target_compile_definitions(SDL3-shared PRIVATE
if(TARGET SDL3-static AND CMAKE_SYSTEM_NAME MATCHES "Linux")
target_compile_definitions(SDL3-static PRIVATE
"SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC=\"libdrm.so.2\""
"SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM=\"libgbm.so.1\""
)
# Keep the include directories for compilation but remove link dependencies
target_include_directories(SDL3-shared PRIVATE
target_include_directories(SDL3-static PRIVATE
/usr/include/libdrm
/usr/include
)
# Remove the hard link dependencies that SDL added
get_target_property(_libs SDL3-shared LINK_LIBRARIES)
get_target_property(_libs SDL3-static LINK_LIBRARIES)
if(_libs)
list(FILTER _libs EXCLUDE REGEX "PC_LIBDRM|PC_GBM")
set_target_properties(SDL3-shared PROPERTIES LINK_LIBRARIES "${_libs}")
set_target_properties(SDL3-static PROPERTIES LINK_LIBRARIES "${_libs}")
endif()
get_target_property(_iface_libs SDL3-shared INTERFACE_LINK_LIBRARIES)
get_target_property(_iface_libs SDL3-static INTERFACE_LINK_LIBRARIES)
if(_iface_libs)
list(FILTER _iface_libs EXCLUDE REGEX "PC_LIBDRM|PC_GBM")
set_target_properties(SDL3-shared PROPERTIES INTERFACE_LINK_LIBRARIES "${_iface_libs}")
set_target_properties(SDL3-static PROPERTIES INTERFACE_LINK_LIBRARIES "${_iface_libs}")
endif()
endif()
# add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/third-party/SDL_image)
Expand Down Expand Up @@ -144,11 +152,12 @@ target_include_directories(glad
PUBLIC
SDL3::SDL3
PRIVATE
GLESv2
EGL
dl
glad
)
if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN)
target_link_libraries(${PROJECT_NAME} PRIVATE GLESv2 EGL dl)
endif()

if(NOT WEIRD_DISABLE_IMGUI)
target_link_libraries(${PROJECT_NAME} PUBLIC imgui)
else()
Expand All @@ -161,6 +170,10 @@ endif()


# Shaders
if(EMSCRIPTEN)
set(WEIRD_ENGINE_USE_RUNTIME_ASSETS ON CACHE BOOL "Load shaders/assets from runtime folder instead of source tree" FORCE)
endif()

option(WEIRD_ENGINE_USE_RUNTIME_ASSETS
"Load shaders/assets from runtime folder instead of source tree"
OFF
Expand Down Expand Up @@ -210,3 +223,9 @@ if(WEIRD_ENGINE_BUILD_EXAMPLES)
add_subdirectory(examples/opengl-experiments)
add_subdirectory(examples/sample-scenes)
endif()

# Tools
option(WEIRD_ENGINE_BUILD_TOOLS "Build tool projects" OFF)
if(WEIRD_ENGINE_BUILD_TOOLS)
add_subdirectory(tools)
endif()
Loading
Loading