aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clangd49
-rw-r--r--premake5.lua49
-rw-r--r--src/core/application.cpp2
-rw-r--r--src/core/camera.cpp5
-rw-r--r--src/core/camera.h1
-rw-r--r--src/core/log.h10
-rw-r--r--src/core/window.cpp6
-rw-r--r--src/platform/opengl/shader.cpp2
-rw-r--r--src/platform/opengl/texture.cpp2
-rw-r--r--src/ui/ui_layer.cpp2
10 files changed, 101 insertions, 27 deletions
diff --git a/.clangd b/.clangd
new file mode 100644
index 0000000..583eae4
--- /dev/null
+++ b/.clangd
@@ -0,0 +1,49 @@
+# clangd config for Donut (the `Donut` app project — src/**). mirrors the build
+# flags in premake5.lua so clangd resolves headers and macros with no
+# compile_commands.json.
+#
+# NOTE: the include paths are absolute for THIS checkout. clangd's no-database
+# fallback runs from each file's own directory, so relative includes don't
+# resolve — hence absolute. If you move the repo, re-point them (or generate a
+# compile_commands.json, e.g. `bear -- make config=debug`, which supersedes this).
+CompileFlags:
+ Add:
+ - -std=c++20
+ # our code (mirror premake5.lua includedirs)
+ - -I/Users/hachem/Dev/Donut/src
+ # vendored deps as system headers (-isystem), mirroring externalincludedirs:
+ # keeps their warnings out of our -Wall/-Wextra/-pedantic.
+ - -isystem/Users/hachem/Dev/Donut/ext/glm
+ - -isystem/Users/hachem/Dev/Donut/ext/glfw/include
+ - -isystem/Users/hachem/Dev/Donut/ext/glad/include
+ - -isystem/Users/hachem/Dev/Donut/ext/imgui
+ - -isystem/Users/hachem/Dev/Donut/ext/imgui/backends
+ - -isystem/Users/hachem/Dev/Donut/ext/ImGuizmo
+ - -isystem/Users/hachem/Dev/Donut/ext/toml11/include
+ - -isystem/Users/hachem/Dev/Donut/ext/json/single_include
+ - -isystem/Users/hachem/Dev/Donut/ext/stb
+ - -isystem/opt/homebrew/include # Vulkan / MoltenVK headers (Homebrew, macOS)
+ # defines (mirror premake5.lua; Debug is the dev default)
+ - -DGLFW_INCLUDE_NONE
+ - -DDONUT_MACOS
+ - -DDONUT_DEBUG
+ - -D_CRT_SECURE_NO_WARNINGS
+ # same strict warnings as the build. -Werror is intentionally left out so the
+ # editor shows these as warnings, not errors — the build is what enforces them.
+ - -Wall
+ - -Wextra
+ - -pedantic
+
+Diagnostics:
+ # this project pulls headers in transitively; clangd's include heuristics are
+ # noisy here and often wrong, so hush them.
+ UnusedIncludes: None
+ MissingIncludes: None
+
+---
+# Vulkan create-info structs zero-init pNext via aggregate init, so
+# -Wmissing-field-initializers is just noise there (matches the build override).
+If:
+ PathMatch: .*/platform/vulkan/.*
+CompileFlags:
+ Add: [-Wno-missing-field-initializers]
diff --git a/premake5.lua b/premake5.lua
index 2d2b0c6..22e1a1d 100644
--- a/premake5.lua
+++ b/premake5.lua
@@ -243,7 +243,18 @@ project "ImGui"
"ext/imgui/imgui_draw.cpp",
"ext/imgui/imgui_tables.cpp",
"ext/imgui/imgui_widgets.cpp",
- "ext/imgui/imgui_demo.cpp"
+ "ext/imgui/imgui_demo.cpp",
+
+ -- the platform/renderer backends live here, not in the app, so they aren't
+ -- held to the app's -Wall -Wextra -Werror -pedantic.
+ "ext/imgui/backends/imgui_impl_glfw.cpp",
+ "ext/imgui/backends/imgui_impl_opengl3.cpp"
+ }
+
+ includedirs
+ {
+ "%{IncludeDir.imgui}",
+ "%{IncludeDir.glfw}"
}
filter "system:windows"
@@ -255,6 +266,10 @@ project "ImGui"
systemversion "latest"
cppdialect "C++17"
+ filter "system:macosx"
+ files { "ext/imgui/backends/imgui_impl_vulkan.cpp" } -- Vulkan via MoltenVK, macOS only
+ externalincludedirs { "/opt/homebrew/include" }
+
filter "configurations:Debug"
runtime "Debug"
symbols "on"
@@ -335,9 +350,6 @@ project "Donut"
"src/**.h",
"src/**.cpp",
- "ext/imgui/backends/imgui_impl_glfw.cpp",
- "ext/imgui/backends/imgui_impl_opengl3.cpp",
-
"assets/fonts/inter/static/Inter_18pt-Regular.ttf",
"assets/fonts/inter/static/Inter_18pt-Bold.ttf",
"assets/fonts/inter/static/Inter_18pt-Light.ttf"
@@ -345,8 +357,13 @@ project "Donut"
includedirs
{
- "src",
+ "src"
+ }
+ -- vendored deps are external: -isystem so their warnings don't trip our
+ -- -Werror, and we aren't on the hook for making glm/imgui/toml11 -pedantic.
+ externalincludedirs
+ {
"%{IncludeDir.glm}",
"%{IncludeDir.glfw}",
"%{IncludeDir.glad}",
@@ -357,6 +374,18 @@ project "Donut"
"%{IncludeDir.nlohmann}",
"%{IncludeDir.stb}",
}
+ externalwarnings "Off"
+
+ -- our own code is held to strict warnings (clang/gcc only; MSVC uses /W).
+ filter { "system:macosx or system:linux" }
+ buildoptions { "-Wall", "-Wextra", "-Werror", "-pedantic" }
+ filter {}
+
+ -- Vulkan create-info structs use aggregate init (VkFoo{ TYPE }); pNext etc.
+ -- are zero-initialised, so -Wmissing-field-initializers is just noise there.
+ filter { "system:macosx or system:linux", "files:src/platform/vulkan/**" }
+ buildoptions { "-Wno-missing-field-initializers" }
+ filter {}
links
{
@@ -375,12 +404,10 @@ project "Donut"
}
filter "system:macosx"
- -- Objective-C++ (Metal) sources + the ImGui Vulkan backend compile only
- -- on macOS (Vulkan headers come from Homebrew there).
+ -- Objective-C++ (Metal) sources compile only on macOS.
files
{
- "src/**.mm",
- "ext/imgui/backends/imgui_impl_vulkan.cpp"
+ "src/**.mm"
}
-- Compile the Slang shaders to assets/shaders/generated/ before building.
@@ -391,8 +418,8 @@ project "Donut"
}
-- Vulkan (via MoltenVK) from Homebrew; see tools/vulkan-env.sh for runtime.
- includedirs { "/opt/homebrew/include" }
- libdirs { "/opt/homebrew/lib" }
+ externalincludedirs { "/opt/homebrew/include" }
+ libdirs { "/opt/homebrew/lib" }
links
{
diff --git a/src/core/application.cpp b/src/core/application.cpp
index 5a3a21b..433f0e7 100644
--- a/src/core/application.cpp
+++ b/src/core/application.cpp
@@ -250,7 +250,7 @@ namespace Donut
auto Application::on_event(Event& event) -> void
{
EventDispatcher dispatcher(event);
- dispatcher.dispatch<WindowCloseEvent>([this, &event](WindowCloseEvent& e)
+ dispatcher.dispatch<WindowCloseEvent>([this, &event](WindowCloseEvent& /*e*/)
{
m_running = false;
event.handled = true;
diff --git a/src/core/camera.cpp b/src/core/camera.cpp
index 35b7a2f..ab12782 100644
--- a/src/core/camera.cpp
+++ b/src/core/camera.cpp
@@ -33,7 +33,6 @@ namespace Donut
{
float pitch = glm::radians(m_rotation.x);
float yaw = glm::radians(m_rotation.y);
- float roll = glm::radians(m_rotation.z);
glm::vec3 direction;
direction.x = cos(yaw) * cos(pitch);
@@ -199,7 +198,7 @@ namespace Donut
update_orbital();
}
- auto Camera::process_orbital_mouse_button(int button, int action, int mods) -> void
+ auto Camera::process_orbital_mouse_button(int button, int action, int /*mods*/) -> void
{
if (button == GLFW_MOUSE_BUTTON_LEFT)
{
@@ -216,7 +215,7 @@ namespace Donut
}
}
- auto Camera::process_orbital_scroll(double x_offset, double y_offset) -> void
+ auto Camera::process_orbital_scroll(double /*x_offset*/, double y_offset) -> void
{
m_orbital_radius -= y_offset * m_zoom_speed;
m_orbital_radius = glm::clamp(m_orbital_radius, m_orbital_min_radius, m_orbital_max_radius);
diff --git a/src/core/camera.h b/src/core/camera.h
index c997c35..79e257c 100644
--- a/src/core/camera.h
+++ b/src/core/camera.h
@@ -110,7 +110,6 @@ namespace Donut
float m_mouse_sensitivity = 0.1f;
float m_movement_speed = 5.0f;
- bool m_first_mouse = true;
float m_last_x = 0.0f;
float m_last_y = 0.0f;
diff --git a/src/core/log.h b/src/core/log.h
index db6b4b4..4237d1c 100644
--- a/src/core/log.h
+++ b/src/core/log.h
@@ -142,11 +142,11 @@ namespace Donut
}
#if defined(DONUT_DEBUG)
- #define DONUT_TRACE(format, ...) ::Donut::Logger::trace(format, ##__VA_ARGS__)
- #define DONUT_INFO(format, ...) ::Donut::Logger::info(format, ##__VA_ARGS__)
- #define DONUT_WARN(format, ...) ::Donut::Logger::warn(format, ##__VA_ARGS__)
- #define DONUT_ERROR(format, ...) ::Donut::Logger::error(format, ##__VA_ARGS__)
- #define DONUT_FATAL(format, ...) ::Donut::Logger::fatal(format, ##__VA_ARGS__)
+ #define DONUT_TRACE(format, ...) ::Donut::Logger::trace(format __VA_OPT__(,) __VA_ARGS__)
+ #define DONUT_INFO(format, ...) ::Donut::Logger::info(format __VA_OPT__(,) __VA_ARGS__)
+ #define DONUT_WARN(format, ...) ::Donut::Logger::warn(format __VA_OPT__(,) __VA_ARGS__)
+ #define DONUT_ERROR(format, ...) ::Donut::Logger::error(format __VA_OPT__(,) __VA_ARGS__)
+ #define DONUT_FATAL(format, ...) ::Donut::Logger::fatal(format __VA_OPT__(,) __VA_ARGS__)
#else
#define DONUT_TRACE(format, ...) {}
#define DONUT_INFO(format, ...) {}
diff --git a/src/core/window.cpp b/src/core/window.cpp
index 085d7bc..9a8d1ec 100644
--- a/src/core/window.cpp
+++ b/src/core/window.cpp
@@ -170,8 +170,8 @@ namespace Donut
win->m_event_handler.on_event(event);
}
- auto Window::glfw_key_callback(GLFWwindow* window, int key, int scancode,
- int action, int mods) -> void
+ auto Window::glfw_key_callback(GLFWwindow* window, int key, int /*scancode*/,
+ int action, int /*mods*/) -> void
{
Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
@@ -203,7 +203,7 @@ namespace Donut
}
auto Window::glfw_mouse_button_callback(GLFWwindow* window, int button,
- int action, int mods) -> void
+ int action, int /*mods*/) -> void
{
Window* win = static_cast<Window*>(glfwGetWindowUserPointer(window));
diff --git a/src/platform/opengl/shader.cpp b/src/platform/opengl/shader.cpp
index 757382b..a56a1b7 100644
--- a/src/platform/opengl/shader.cpp
+++ b/src/platform/opengl/shader.cpp
@@ -85,7 +85,7 @@ namespace Donut
{
in.seekg(0, std::ios::end);
size_t size = in.tellg();
- if (size != -1)
+ if (size != static_cast<size_t>(-1))
{
result.resize(size);
in.seekg(0, std::ios::beg);
diff --git a/src/platform/opengl/texture.cpp b/src/platform/opengl/texture.cpp
index d2d2233..5036ca6 100644
--- a/src/platform/opengl/texture.cpp
+++ b/src/platform/opengl/texture.cpp
@@ -255,7 +255,7 @@ namespace Donut
glDeleteRenderbuffers(1, &capture_rbo);
}
- auto CubemapTexture::set_data(void* data, uint32_t size) -> void
+ auto CubemapTexture::set_data(void* /*data*/, uint32_t /*size*/) -> void
{
DONUT_WARN("set_data not implemented for cubemaps");
}
diff --git a/src/ui/ui_layer.cpp b/src/ui/ui_layer.cpp
index dc61d2d..1c014e6 100644
--- a/src/ui/ui_layer.cpp
+++ b/src/ui/ui_layer.cpp
@@ -107,7 +107,7 @@ namespace Donut
return m_mode == Mode::Scene ? View::Scene : View::BlackHole;
}
- auto UILayer::draw_menu_bar(const UIContext& ctx) -> void
+ auto UILayer::draw_menu_bar(const UIContext& /*ctx*/) -> void
{
if (!ImGui::BeginMainMenuBar()) return;