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
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Release

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

env:
BUILD_TYPE: Release
Expand All @@ -13,15 +13,15 @@ jobs:
build:
strategy:
matrix:
os: [ macos-14, ubuntu-latest, windows-latest ]
os: [macos-14, ubuntu-latest, windows-latest]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DWARNINGS_AS_ERRORS=FALSE

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Application build output
build/
distribution/
.cache/

# Created by CPack when executing tests.
Testing/
Expand All @@ -14,3 +15,4 @@ profile.json

# User defined CMake preset file.
CMakeUserPresets.json
*.sublime-workspace
22 changes: 8 additions & 14 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"generator": "Ninja",
"binaryDir": "build/release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
"CMAKE_BUILD_TYPE": "Release",
"WARNINGS_AS_ERRORS": "FALSE"
}
},
{
Expand All @@ -41,7 +42,8 @@
"binaryDir": "build/xcode-release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_OSX_ARCHITECTURES": "x86_64;arm64"
"CMAKE_OSX_ARCHITECTURES": "x86_64;arm64",
"WARNINGS_AS_ERRORS": "FALSE"
},
"condition": {
"type": "equals",
Expand All @@ -62,9 +64,7 @@
"displayName": "Build Release",
"configurePreset": "release",
"configuration": "Release",
"targets": [
"App"
]
"targets": ["App"]
},
{
"name": "xcode-debug",
Expand All @@ -82,9 +82,7 @@
"displayName": "Build Release (Xcode)",
"configurePreset": "xcode-release",
"configuration": "Release",
"targets": [
"App"
],
"targets": ["App"],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
Expand All @@ -97,17 +95,13 @@
"name": "release",
"displayName": "Distribute Release",
"configurePreset": "release",
"configurations": [
"Release"
]
"configurations": ["Release"]
},
{
"name": "xcode-release",
"displayName": "Distribute Release (Xcode)",
"configurePreset": "xcode-release",
"configurations": [
"Release"
],
"configurations": ["Release"],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
Expand Down
2 changes: 1 addition & 1 deletion cmake/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

function(set_project_warnings project_name)
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" TRUE)
message(STATUS "Treat compiler warnings as errors")

set(MSVC_WARNINGS
/W4 # Baseline reasonable warnings
Expand Down Expand Up @@ -59,6 +58,7 @@ function(set_project_warnings project_name)
)

if (WARNINGS_AS_ERRORS)
message(STATUS "Treat compiler warnings as errors")
set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror)
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
endif ()
Expand Down
5 changes: 2 additions & 3 deletions docs/Profiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ int Application::run() {

## Show results

The resulting JSON file uses
the [Trace Event Format](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview). Any
The resulting JSON file (`profile.json`) uses the [Trace Event Format](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview). Any
tool that can read this format can visualize the profiler data. For example the web
tool [Perfetto](https://ui.perfetto.dev/) or Chromes built in [chrome://tracing](chrome://tracing). Just drag&drop the
generated profiler JSON file onto the tool to load it.
Expand All @@ -78,6 +77,6 @@ This is roughly how this looks like on Chrome.

![chrome-trace.png](assets/chrome-trace.png)

***
---

Next up: [Logging](Logging.md)
3 changes: 2 additions & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ include(${PROJECT_SOURCE_DIR}/cmake/StaticAnalyzers.cmake)
add_library(${NAME} STATIC
Core/Log.cpp Core/Log.hpp Core/Debug/Instrumentor.hpp
Core/Application.cpp Core/Application.hpp Core/Window.cpp Core/Window.hpp
Core/Resources.hpp Core/DPIHandler.hpp)
Core/Resources.hpp Core/Resources.cpp
Core/DPIHandler.hpp)

# Define set of OS specific files to include
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
Expand Down
9 changes: 7 additions & 2 deletions src/core/Core/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ ExitStatus App::Application::run() {
const float font_size{18.0F * font_scaling_factor};
const std::string font_path{Resources::font_path("Manrope.ttf").generic_string()};

io.Fonts->AddFontFromFileTTF(font_path.c_str(), font_size);
io.FontDefault = io.Fonts->AddFontFromFileTTF(font_path.c_str(), font_size);
if (Resources::exists(font_path)) {
io.Fonts->AddFontFromFileTTF(font_path.c_str(), font_size);
io.FontDefault = io.Fonts->AddFontFromFileTTF(font_path.c_str(), font_size);
} else {
APP_WARN("Could not find font file under: {}", font_path.c_str());
}

DPIHandler::set_global_font_scaling(&io);

// Setup Platform/Renderer backends
Expand Down
18 changes: 18 additions & 0 deletions src/core/Core/Resources.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "Core/Resources.hpp"

#include <sys/stat.h>

#include <filesystem>

#include "Core/Debug/Instrumentor.hpp"

namespace App {

bool Resources::exists(const std::filesystem::path& pathname) {
APP_PROFILE_FUNCTION();

struct stat buffer;
return (stat(pathname.generic_string().c_str(), &buffer) == 0);
}

} // namespace App
1 change: 1 addition & 0 deletions src/core/Core/Resources.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Resources {
public:
[[nodiscard]] static std::filesystem::path resource_path(const std::filesystem::path& file_path);
[[nodiscard]] static std::filesystem::path font_path(const std::string_view& font_file);
[[nodiscard]] static bool exists(const std::filesystem::path& pathname);
};

} // namespace App
4 changes: 1 addition & 3 deletions src/core/Core/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ namespace App {
Window::Window(const Settings& settings) {
APP_PROFILE_FUNCTION();

const auto window_flags{
static_cast<SDL_WindowFlags>(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI)};
const WindowSize size{DPIHandler::get_dpi_aware_window_size(settings)};

m_window = SDL_CreateWindow(settings.title.c_str(),
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
size.width,
size.height,
window_flags);
SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);

Uint32 renderer_flags{SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED};
m_renderer = SDL_CreateRenderer(m_window, -1, renderer_flags);
Expand Down
124 changes: 124 additions & 0 deletions template.sublime-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"folders": [
{
"path": ".",
}
],
"settings": {
"cmake": {
"build_folder": "$folder/build",
"command_line_overrides": {
"CMAKE_POLICY_VERSION_MINIMUM": "3.5",
},
},
"LSP": {
"clangd": {
"initializationOptions": {
"clangd.clang-tidy": true,
},
},
},
},
"build_systems":
[
{
"config": "Debug",
"env":
{
},
"generator": "Unix Makefiles",
"name": "Debug",
"target": "cmake_build",
"variants":
[
{
"build_target": "App",
"name": "App"
},
{
"artifact": "src/app/App.app/Contents/MacOS/App",
"build_target": "App",
"name": "Run: App",
"target": "cmake_run"
},
{
"artifact": "src/app/App.app/Contents/MacOS/App",
"build_target": "App",
"debug": true,
"name": "Run under LLDB: App",
"target": "cmake_run"
},
{
"build_target": "Core",
"name": "Core"
},
{
"build_target": "ResourcesTest",
"name": "ResourcesTest"
},
{
"artifact": "src/core/Tests/ResourcesTest",
"build_target": "ResourcesTest",
"name": "Run: ResourcesTest",
"target": "cmake_run"
},
{
"artifact": "src/core/Tests/ResourcesTest",
"build_target": "ResourcesTest",
"debug": true,
"name": "Run under LLDB: ResourcesTest",
"target": "cmake_run"
},
{
"build_target": "SDL2",
"name": "SDL2"
},
{
"build_target": "SDL2-static",
"name": "SDL2-static"
},
{
"build_target": "SDL2_test",
"name": "SDL2_test"
},
{
"build_target": "Settings",
"name": "Settings"
},
{
"build_target": "TestRunner",
"name": "TestRunner"
},
{
"build_target": "doctest_with_main",
"name": "doctest_with_main"
},
{
"build_target": "fmt",
"name": "fmt"
},
{
"build_target": "imgui",
"name": "imgui"
},
{
"build_target": "sdl_headers_copy",
"name": "sdl_headers_copy"
},
{
"build_target": "spdlog",
"name": "spdlog"
},
{
"build_target": "uninstall",
"name": "uninstall"
},
{
"name": "ctest",
"target": "ctest_run"
}
],
"working_dir": "$folder/build"
}
],
}
10 changes: 5 additions & 5 deletions vendor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ include(FetchContent)
FetchContent_Declare(
doctest
GIT_REPOSITORY "https://github.com/onqtam/doctest.git"
GIT_TAG v2.4.11
GIT_TAG v2.4.12
)

FetchContent_Declare(
fmt
GIT_REPOSITORY "https://github.com/fmtlib/fmt.git"
GIT_TAG 11.0.2
GIT_TAG 11.2.0
)

FetchContent_Declare(
imgui
GIT_REPOSITORY "https://github.com/ocornut/imgui.git"
GIT_TAG 368123ab06b2b573d585e52f84cd782c5c006697 # Branch: docking, date: 07.11.2024, 07:58 GMT+1
GIT_TAG b4311141947de17763d88f680c84c14379538388 # Branch: docking, date: 08.08.2024, 06:37 GMT+3
)

FetchContent_Declare(
SDL2
GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git"
GIT_TAG release-2.30.9
GIT_TAG release-2.32.8
)

FetchContent_Declare(
spdlog
GIT_REPOSITORY "https://github.com/gabime/spdlog.git"
GIT_TAG v1.15.0
GIT_TAG v1.15.3
)

# Settings
Expand Down
Loading