From 42e6cf5fedc6ce8771aa3c6c5cf729c7a947949a Mon Sep 17 00:00:00 2001 From: James Gangur Date: Wed, 6 Mar 2024 16:26:52 +1100 Subject: [PATCH] update code style - update seperators, hopefully I should waste less time deciding where to put them now - remove copyright message from headers --- include/sqee/app/Application.hpp | 19 ++++-------- include/sqee/app/AudioContext.hpp | 25 ++++++---------- include/sqee/app/DebugOverlay.hpp | 15 +++------- include/sqee/app/Event.hpp | 13 ++------ include/sqee/app/Gamepad.hpp | 13 ++------ include/sqee/app/GuiSystem.hpp | 27 +++++++---------- include/sqee/app/GuiWidgets.hpp | 43 ++++++++++---------------- include/sqee/app/InputDevices.hpp | 20 ++++++------- include/sqee/app/Scene.hpp | 25 ++++++---------- include/sqee/app/Window.hpp | 32 ++++++++++---------- include/sqee/app/WrenForward.hpp | 15 ++++------ include/sqee/app/WrenPlus.hpp | 45 +++++++++++++--------------- include/sqee/core/EnumHelper.hpp | 15 ++-------- include/sqee/core/Macros.hpp | 13 ++++---- include/sqee/core/Strings.hpp | 15 +++------- include/sqee/core/TypeAliases.hpp | 3 -- include/sqee/core/TypeNames.hpp | 3 -- include/sqee/core/TypeTraits.hpp | 3 -- include/sqee/core/Utilities.hpp | 13 ++------ include/sqee/data/BuiltinShaders.hpp | 5 ++-- include/sqee/data/UbuntuMinimal.hpp | 5 ++-- include/sqee/data/VolumeMeshes.hpp | 5 ++-- include/sqee/debug/Assert.hpp | 7 ++--- include/sqee/debug/Logging.hpp | 21 +++++-------- include/sqee/export.hpp | 5 ---- include/sqee/maths/Colours.hpp | 3 -- include/sqee/maths/Culling.hpp | 45 ++++++++++++---------------- include/sqee/maths/Functions.hpp | 3 -- include/sqee/maths/Matrices.hpp | 3 -- include/sqee/maths/Quaternion.hpp | 3 -- include/sqee/maths/Random.hpp | 3 -- include/sqee/maths/Scalar.hpp | 3 -- include/sqee/maths/Vectors.hpp | 3 -- include/sqee/maths/Volumes.hpp | 21 +++++-------- include/sqee/misc/Files.hpp | 15 +++------- include/sqee/misc/Json.hpp | 3 -- include/sqee/misc/Parsing.hpp | 19 ++++-------- include/sqee/misc/ResourceCache.hpp | 15 +++------- include/sqee/misc/ResourceHandle.hpp | 21 +++++-------- include/sqee/misc/StackString.hpp | 3 -- include/sqee/misc/StackVector.hpp | 3 -- include/sqee/objects/Armature.hpp | 31 ++++++++----------- include/sqee/objects/DrawItem.hpp | 10 ++----- include/sqee/objects/Mesh.hpp | 33 ++++++++------------ include/sqee/objects/Pipeline.hpp | 18 +++++------ include/sqee/objects/Sound.hpp | 19 ++++-------- include/sqee/objects/Texture.hpp | 28 ++++++++--------- include/sqee/setup.hpp | 9 ++---- include/sqee/vk/Helpers.hpp | 24 +++++++-------- include/sqee/vk/PassConfig.hpp | 10 ++----- include/sqee/vk/SwapBuffer.hpp | 21 +++++-------- include/sqee/vk/VulkanContext.hpp | 26 +++++++--------- include/sqee/vk/VulkanMemory.hpp | 32 +++++++++----------- include/sqee/vk/Wrappers.hpp | 14 ++++----- source/sqee/app/Application.cpp | 6 ++-- source/sqee/app/AudioContext.cpp | 18 +++++------ source/sqee/app/DebugOverlay.cpp | 12 ++++---- source/sqee/app/GuiSystem.cpp | 34 ++++++++++----------- source/sqee/app/GuiWidgets.cpp | 16 +++++----- source/sqee/app/InputDevices.cpp | 8 ++--- source/sqee/app/Scene.cpp | 6 ++-- source/sqee/app/Window.cpp | 30 +++++++++---------- source/sqee/app/WrenPlus.cpp | 20 ++++++------- source/sqee/data/BuiltinShaders.cpp | 4 +-- source/sqee/data/UbuntuMinimal.cpp | 8 ++--- source/sqee/data/VolumeMeshes.cpp | 6 ++-- source/sqee/debug/Logging.cpp | 6 ++-- source/sqee/misc/Files.cpp | 16 +++++----- source/sqee/misc/Parsing.cpp | 6 ++-- source/sqee/objects/Armature.cpp | 34 ++++++++++----------- source/sqee/objects/DrawItem.cpp | 8 ++--- source/sqee/objects/Mesh.cpp | 20 ++++++------- source/sqee/objects/Pipeline.cpp | 22 +++++++------- source/sqee/objects/Sound.cpp | 4 +-- source/sqee/objects/Texture.cpp | 36 +++++++++++----------- source/sqee/vk/Helpers.cpp | 10 +++---- source/sqee/vk/SwapBuffer.cpp | 4 +-- source/sqee/vk/VulkanContext.cpp | 6 ++-- source/sqee/vk/VulkanMemory.cpp | 14 ++++----- source/sqee/vk/Wrappers.cpp | 12 ++++---- testing/Common.hpp | 8 ++--- tests/vkdemo/src/DemoApp.cpp | 30 +++++++++---------- tests/vkdemo/src/DemoApp.hpp | 30 ++++++++----------- tests/vkdemo/src/Resources.cpp | 4 +-- tests/vkdemo/src/setup.hpp | 8 ++--- 85 files changed, 512 insertions(+), 780 deletions(-) diff --git a/include/sqee/app/Application.hpp b/include/sqee/app/Application.hpp index 6fa7a0b..b6fd75f 100644 --- a/include/sqee/app/Application.hpp +++ b/include/sqee/app/Application.hpp @@ -1,20 +1,15 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### /// The SQEE Application base class. class SQEE_API Application { -public: //====================================================// +public: //====================================================== Application() = default; @@ -23,7 +18,7 @@ class SQEE_API Application virtual ~Application() = default; - //--------------------------------------------------------// + //---------------------------------------------------------- /// Launch the main application loop. int run(int argc, char** argv); @@ -34,7 +29,7 @@ class SQEE_API Application /// Reset timer for going into inactive mode. void reset_inactivity() { mElapsedSinceActivity = 0.0; } -protected: //=================================================// +protected: //=================================================== /// Called once before the main loop starts. virtual void initialise(std::vector args) = 0; @@ -42,7 +37,7 @@ class SQEE_API Application /// Called continuously while running. virtual void update(double elapsed) = 0; - //--------------------------------------------------------// + //---------------------------------------------------------- /// How long to go without user input before limiting update rate. double mMaxInactivePeriod = INFINITY; @@ -60,6 +55,4 @@ class SQEE_API Application std::function mCallNextFrame = nullptr; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/app/AudioContext.hpp b/include/sqee/app/AudioContext.hpp index 7b79773..4a0eacf 100644 --- a/include/sqee/app/AudioContext.hpp +++ b/include/sqee/app/AudioContext.hpp @@ -1,13 +1,8 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include -namespace sq { - -//====== Forward Declarations and Enums ======================================// +namespace sq { //############################################################### class Sound; @@ -32,12 +27,12 @@ struct SoundGroups /// Bitwise OR operator for enum class type. constexpr SoundGroups operator|(SoundGroup a, SoundGroup b) { return SoundGroups(uint8_t(a) | uint8_t(b)); } -//============================================================================// +//============================================================================== /// Handles the initialisation and playback of audio. class SQEE_API AudioContext { -public: //====================================================// +public: //====================================================== AudioContext(); @@ -46,12 +41,12 @@ class SQEE_API AudioContext ~AudioContext(); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Play a sound using the next available id. int32_t play_sound(const Sound& sound, SoundGroup group, float volume, bool loop); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Pause or resume an individual sound. void set_sound_paused(int32_t id, bool pause); @@ -59,7 +54,7 @@ class SQEE_API AudioContext /// Remove an individual sound. void stop_sound(int32_t id); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Pause or resume zero or more sounds. void set_sounds_paused(std::span ids, bool pause); @@ -67,7 +62,7 @@ class SQEE_API AudioContext /// Remove zero or more sounds. void stop_sounds(std::span ids); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Do not start sounds from one or more groups. void set_groups_ignored(SoundGroups groups, bool ignore); @@ -78,7 +73,7 @@ class SQEE_API AudioContext /// Remove all sounds in the specified groups. void stop_groups(SoundGroups groups); -private: //===================================================// +private: //===================================================== struct ActiveSound { @@ -107,6 +102,4 @@ class SQEE_API AudioContext friend Sound; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/app/DebugOverlay.hpp b/include/sqee/app/DebugOverlay.hpp index 627eb23..dff976f 100644 --- a/include/sqee/app/DebugOverlay.hpp +++ b/include/sqee/app/DebugOverlay.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include @@ -9,14 +6,12 @@ #include #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### /// The SQEE Debugging Overlay. class SQEE_API DebugOverlay final : public Scene { -public: //====================================================// +public: //====================================================== DebugOverlay(); @@ -34,7 +29,7 @@ class SQEE_API DebugOverlay final : public Scene /// Check if the overlay is drawn. bool check_active() const { return mActive; } -private: //===================================================// +private: //===================================================== void update() override; @@ -65,6 +60,4 @@ class SQEE_API DebugOverlay final : public Scene String mFrameSubTimerTotalDisplay; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/app/Event.hpp b/include/sqee/app/Event.hpp index 91eeed9..fb8638e 100644 --- a/include/sqee/app/Event.hpp +++ b/include/sqee/app/Event.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include @@ -9,9 +6,7 @@ #include #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### enum class Keyboard_Key : int8_t { @@ -36,7 +31,7 @@ enum class Mouse_Button : int8_t ExtraA, ExtraB }; -//============================================================================// +//============================================================================== struct Event final { @@ -69,9 +64,7 @@ struct Event final Data data {}; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## SQEE_ENUM_HELPER ( diff --git a/include/sqee/app/Gamepad.hpp b/include/sqee/app/Gamepad.hpp index 45629ca..5379c5d 100644 --- a/include/sqee/app/Gamepad.hpp +++ b/include/sqee/app/Gamepad.hpp @@ -1,15 +1,10 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### enum class Gamepad_Button : int8_t { @@ -30,7 +25,7 @@ enum class Gamepad_Axis : int8_t RightTrigger }; -//============================================================================// +//============================================================================== /// The raw state of a gamepad. struct GamepadState @@ -78,9 +73,7 @@ struct Gamepad : public GamepadState } }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## SQEE_ENUM_HELPER ( diff --git a/include/sqee/app/GuiSystem.hpp b/include/sqee/app/GuiSystem.hpp index 4ea28c3..7c45455 100644 --- a/include/sqee/app/GuiSystem.hpp +++ b/include/sqee/app/GuiSystem.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include @@ -9,19 +6,17 @@ #include #include -namespace sq { - -//====== Forward Declarations ================================================// +namespace sq { //############################################################### struct Event; class InputDevices; class Window; -//============================================================================// +//============================================================================== class SQEE_API GuiSystem { -public: //====================================================// +public: //====================================================== GuiSystem(Window& window, InputDevices& inputDevices); @@ -30,7 +25,7 @@ class SQEE_API GuiSystem ~GuiSystem(); - //--------------------------------------------------------// + //---------------------------------------------------------- void set_style_widgets_default(); void set_style_widgets_supertux(); @@ -40,7 +35,7 @@ class SQEE_API GuiSystem void set_style_colours_light(); void set_style_colours_supertux(); - //--------------------------------------------------------// + //---------------------------------------------------------- bool handle_event(Event event); @@ -50,16 +45,16 @@ class SQEE_API GuiSystem void render_gui(vk::CommandBuffer cmdbuf); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Contains a single CombinedImageSampler. vk::DescriptorSetLayout get_descriptor_set_layout() const { return mDescriptorSetLayout; } - //--------------------------------------------------------// + //---------------------------------------------------------- void show_imgui_demo(); -private: //===================================================// +private: //===================================================== void load_ubuntu_fonts(); @@ -69,7 +64,7 @@ class SQEE_API GuiSystem Window& window; InputDevices& input; - //--------------------------------------------------------// + //---------------------------------------------------------- Texture mFontTexture; SwapBuffer mVertexBuffer; @@ -82,6 +77,4 @@ class SQEE_API GuiSystem vk::Pipeline mPipeline; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/app/GuiWidgets.hpp b/include/sqee/app/GuiWidgets.hpp index 430cccb..5591c27 100644 --- a/include/sqee/app/GuiWidgets.hpp +++ b/include/sqee/app/GuiWidgets.hpp @@ -1,7 +1,4 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - -#pragma once +#pragma once #include @@ -21,7 +18,7 @@ #include -//============================================================================// +//============================================================================== namespace ImGui { @@ -31,11 +28,7 @@ SQEE_API bool DragScalarRange2(ImStrv label, ImGuiDataType data_type, void* p_cu } // namespace ImGui -//============================================================================// - -namespace ImPlus { - -//----------------------------------------------------------------------------// +namespace ImPlus { //########################################################### constexpr const int FONT_REGULAR = 0; constexpr const int FONT_BOLD = 1; @@ -51,7 +44,7 @@ enum class DialogResult { None, Confirm, Cancel }; template using FormatString = std::conditional_t, fmt::string_view>; -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ inline void Text(std::string_view text) { ImGui::TextUnformatted(text); } @@ -67,7 +60,7 @@ SQEE_API void BulletText(std::string_view text); SQEE_API void SetTooltip(std::string_view text); -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ /// DisplaySize.x - offset SQEE_API float FromScreenRight(float offset); @@ -96,7 +89,7 @@ SQEE_API bool InputColour(ImStrv label, sq::Vec4F& colour, ImGuiColorEditFlags f /// Show a dialog prompting the user for confirmation. SQEE_API DialogResult DialogConfirmation(ImStrv title, std::string_view message = {}); -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ SQEE_API void HoverTooltipV(bool delay, ImGuiDir dir, fmt::string_view fstr, fmt::format_args args); @@ -108,7 +101,7 @@ inline void HoverTooltip(bool delay, ImGuiDir dir, FormatString fstr, A template inline void HoverTooltip(FormatString fstr, Args&&... args) { HoverTooltipV(true, ImGuiDir_None, fstr, fmt::make_format_args(args...)); } -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ namespace detail { @@ -140,7 +133,7 @@ SQEE_API bool is_temp_input_open(); } // namespace detail -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ template inline bool InputValue(ImStrv label, Type& ref, decltype(Type()) step, const char* format = nullptr) @@ -186,7 +179,7 @@ inline bool DragValueRange2(ImStrv label, Type& refMin, Type& refMax, float spee return changed; } -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ template inline bool InputVector(ImStrv label, sq::maths::Vector& ref, decltype(Type()) step, const char* format = nullptr) @@ -222,7 +215,7 @@ inline bool InputQuaternion(ImStrv label, sq::maths::Quaternion& ref, decl return changed; } -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ /// C++ style API for combo boxes. If none is given, it can be selected to set the index to -1. template @@ -308,7 +301,7 @@ inline bool ComboEnum(ImStrv label, Enum& ref, ImGuiComboFlags flags = 0) return changed; } -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ /// Assign ref to value when pressed. template @@ -319,7 +312,7 @@ inline bool RadioButton(ImStrv label, Type& ref, Type value) return pressed; } -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ /// Wrapper for Begin, End. struct Scope_Window final : detail::ScopeBase @@ -337,7 +330,7 @@ struct Scope_WindowClosable final : detail::ScopeBase ~Scope_WindowClosable() { ImGui::End(); } }; -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ /// Wrapper for BeginChild, EndChild. template @@ -415,7 +408,7 @@ inline void if_Table(ImStrv id, int columns, ImGuiTableFlags flags, ImVec2 outer if (ImGui::BeginTable(id, columns, flags, outerSize, innerWidth)) { body(); ImGui::EndTable(); } } -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ /// Wrapper for PushID, PopID. struct Scope_ID final : detail::ScopeBase @@ -465,7 +458,7 @@ struct Scope_FontScale final : detail::ScopeBase ~Scope_FontScale() { font->Scale = scale; ImGui::PopFont(); } }; -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ /// Wrapper for PushStyleVar(float), PopStyleVar. template @@ -491,14 +484,10 @@ using Style_CellPadding = Scope_StyleVec; using Style_ButtonTextAlign = Scope_StyleVec; using Style_SelectableTextAlign = Scope_StyleVec; -//----------------------------------------------------------------------------// +} // namespace ImPlus ########################################################## #define IMPLUS_WITH_CONCAT_INNER(a, b) a##b #define IMPLUS_WITH_CONCAT(a, b) IMPLUS_WITH_CONCAT_INNER(a, b) /// Declare a variable with a generated name of the given ImPlus class. #define IMPLUS_WITH(Class) const ImPlus::Class IMPLUS_WITH_CONCAT(implus_with_, __LINE__) - -//============================================================================// - -} // namespace ImPlus diff --git a/include/sqee/app/InputDevices.hpp b/include/sqee/app/InputDevices.hpp index 03ab044..d3eb7a3 100644 --- a/include/sqee/app/InputDevices.hpp +++ b/include/sqee/app/InputDevices.hpp @@ -4,11 +4,11 @@ #include -//====== Forward Declarations ================================================// +//============================================================================== extern "C" { typedef struct GLFWwindow GLFWwindow; } -namespace sq { +namespace sq { //############################################################### enum class Keyboard_Key : int8_t; enum class Mouse_Button : int8_t; @@ -16,24 +16,24 @@ enum class Mouse_Button : int8_t; class Window; struct GamepadState; -//============================================================================// +//============================================================================== /// Access to Keyboard/Mouse/Gamepad state. class SQEE_API InputDevices { -public: //====================================================// +public: //====================================================== InputDevices(Window& window); SQEE_COPY_DELETE(InputDevices) SQEE_MOVE_DELETE(InputDevices) - //--------------------------------------------------------// + //---------------------------------------------------------- /// Check if the given key is pressed. bool is_pressed(Keyboard_Key key) const; - //--------------------------------------------------------// + //---------------------------------------------------------- /// Get the location of the cursor. Vec2I get_cursor_location(bool flipY) const; @@ -44,7 +44,7 @@ class SQEE_API InputDevices /// Move the cursor to the window centre. Vec2I cursor_to_centre(); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Check if a gamepad is connected. bool check_gamepad_connected(int port) const; @@ -52,11 +52,9 @@ class SQEE_API InputDevices /// Get the current state of a gamepad. GamepadState poll_gamepad_state(int port) const; -private: //===================================================// +private: //===================================================== GLFWwindow* const mGlfwWindow; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/app/Scene.hpp b/include/sqee/app/Scene.hpp index 03f5a84..6fc1508 100644 --- a/include/sqee/app/Scene.hpp +++ b/include/sqee/app/Scene.hpp @@ -1,24 +1,19 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include #include -namespace sq { - -//====== Forward Declarations ================================================// +namespace sq { //############################################################### struct Event; -//============================================================================// +//============================================================================== /// The SQEE Scene base class. class SQEE_API Scene { -public: //====================================================// +public: //====================================================== Scene(double tickTime); @@ -27,12 +22,12 @@ class SQEE_API Scene virtual ~Scene() = default; - //--------------------------------------------------------// + //---------------------------------------------------------- /// Call to update and then integrate the scene. void update_and_integrate(double elapsed); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Optionally implement for event handling. virtual void handle_event(Event event); @@ -46,12 +41,12 @@ class SQEE_API Scene /// Optionally implement for ImGui widgets. virtual void show_imgui_widgets(); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Call between cmdbuf.begin() and cmdbuf.end() for drawing commands. virtual void populate_command_buffer(vk::CommandBuffer cmdbuf, vk::Framebuffer framebuf) = 0; -protected: //=================================================// +protected: //=================================================== /// Implement to simulate one tick. virtual void update() = 0; @@ -59,7 +54,7 @@ class SQEE_API Scene /// Implement to prepare for render. virtual void integrate(double elapsed, float blend) = 0; - //--------------------------------------------------------// + //---------------------------------------------------------- double mTickTime; @@ -69,6 +64,4 @@ class SQEE_API Scene bool mJustLoaded = true; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/app/Window.hpp b/include/sqee/app/Window.hpp index 86ed16a..a0da883 100644 --- a/include/sqee/app/Window.hpp +++ b/include/sqee/app/Window.hpp @@ -9,17 +9,15 @@ #include #include -//====== Forward Declarations ================================================// +//============================================================================== extern "C" { typedef struct GLFWwindow GLFWwindow; } -namespace sq { - -//============================================================================// +namespace sq { //############################################################### class SQEE_API Window { -public: //====================================================// +public: //====================================================== Window(const char* title, Vec2U size, const char* appName, Vec3U version); @@ -28,17 +26,17 @@ class SQEE_API Window ~Window(); - //--------------------------------------------------------// + //---------------------------------------------------------- void set_size_limits(std::optional minimum, std::optional maximum); - //--------------------------------------------------------// + //---------------------------------------------------------- void create_swapchain_and_friends(); void destroy_swapchain_and_friends(); - //--------------------------------------------------------// + //---------------------------------------------------------- const std::vector& fetch_events(); @@ -48,7 +46,7 @@ class SQEE_API Window void submit_present_swap(); - //--------------------------------------------------------// + //---------------------------------------------------------- GLFWwindow* get_glfw_window() { return mGlfwWindow; } @@ -56,7 +54,7 @@ class SQEE_API Window Vec2U get_size() const { return { mFramebufferSize.width, mFramebufferSize.height }; } - //--------------------------------------------------------// + //---------------------------------------------------------- void set_title(String title); @@ -64,7 +62,7 @@ class SQEE_API Window void set_vsync_enabled(bool enabled); - //--------------------------------------------------------// + //---------------------------------------------------------- const String& get_title() const { return mTitle; }; @@ -72,11 +70,11 @@ class SQEE_API Window bool get_vsync_enabled() const { return mVsyncEnabled; }; - //--------------------------------------------------------// + //---------------------------------------------------------- bool has_focus() const; -private: //===================================================// +private: //===================================================== GLFWwindow* mGlfwWindow = nullptr; @@ -87,7 +85,7 @@ class SQEE_API Window std::vector mEvents, mEventsOld; - //--------------------------------------------------------// + //---------------------------------------------------------- vk::Instance mInstance; vk::DebugUtilsMessengerEXT mDebugMessenger; @@ -111,7 +109,7 @@ class SQEE_API Window Swapper mRenderFinishedSemaphore; Swapper mRenderFinishedFence; - //--------------------------------------------------------// + //---------------------------------------------------------- String mTitle; bool mCursorHidden = false; @@ -119,10 +117,10 @@ class SQEE_API Window bool mPendingResize = true; - //--------------------------------------------------------// + //---------------------------------------------------------- struct Implementation; friend Implementation; }; -} // namesapce sq +} // namesapce sq ############################################################## diff --git a/include/sqee/app/WrenForward.hpp b/include/sqee/app/WrenForward.hpp index 16cadf7..e2f8cab 100644 --- a/include/sqee/app/WrenForward.hpp +++ b/include/sqee/app/WrenForward.hpp @@ -1,12 +1,9 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include #include -//============================================================================// +//============================================================================== // to use without sqee, replace this stuff with your own macros @@ -18,7 +15,7 @@ #define WRENPLUS_DEBUG #endif -//============================================================================// +//============================================================================== extern "C" { @@ -27,7 +24,7 @@ typedef struct WrenHandle WrenHandle; } // extern "C" -//============================================================================// +//============================================================================== namespace wren { @@ -44,7 +41,7 @@ class WrenPlusVM; } // namespace wren -//============================================================================// +//============================================================================== #define WRENPLUS_TRAITS_HEADER(Type) \ template<> struct wren::Traits : std::true_type \ @@ -59,7 +56,7 @@ const char* const wren::Traits::module = Module; \ const char* const wren::Traits::className = ClassName; \ const size_t wren::Traits::index = wren::detail::generate_type_index(); -//============================================================================// +//============================================================================== #define WRENPLUS_BASE_CLASS_HEADER(BaseType) \ template <> \ @@ -89,7 +86,7 @@ void wren::SlotHelper::set(WrenVM* vm, int slot, BaseType* ptr) \ wrenSetSlotNull(vm, slot); \ } -//============================================================================// +//============================================================================== #define WRENPLUS_ADD_METHOD(Pvm, Class, Method, Signature) \ Pvm.register_method<&Class::Method, Class>(Signature) diff --git a/include/sqee/app/WrenPlus.hpp b/include/sqee/app/WrenPlus.hpp index 5bda19e..fb44c0c 100644 --- a/include/sqee/app/WrenPlus.hpp +++ b/include/sqee/app/WrenPlus.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - // some parts based on https://github.com/Nelarius/wrenpp // should work without sqee with a few small changes @@ -26,9 +23,7 @@ #include #include -namespace wren { - -//============================================================================// +namespace wren { //############################################################# /// General exception to throw from functions bound to wren. struct Exception final : public std::runtime_error @@ -68,7 +63,7 @@ struct GetVar const char* const name; }; -//============================================================================// +//============================================================================== namespace detail { @@ -95,7 +90,7 @@ struct FieldHelper } // namespace detail -//============================================================================// +//============================================================================== /// Create a new SafeResult with either a value or an error. template @@ -142,18 +137,18 @@ template constexpr auto FieldGetter = &detail::FieldHelper constexpr auto FieldSetter = &detail::FieldHelper::set; -//============================================================================// +//============================================================================== /// RAII wrapper for WrenVM, with some nice extra features. class WRENPLUS_API WrenPlusVM { -public: //====================================================// +public: //====================================================== WrenPlusVM(); ~WrenPlusVM(); - //--------------------------------------------------------// + //---------------------------------------------------------- WrenPlusVM(const WrenPlusVM&) = delete; WrenPlusVM& operator=(const WrenPlusVM&) = delete; @@ -161,7 +156,7 @@ class WRENPLUS_API WrenPlusVM WrenPlusVM(WrenPlusVM&&) = delete; WrenPlusVM& operator=(WrenPlusVM&&) = delete; - //--------------------------------------------------------// + //---------------------------------------------------------- /// Allows WrenPlusVM& instead of WrenVM* with the wren api. operator WrenVM*() { return mWrenVM; } @@ -179,7 +174,7 @@ class WRENPLUS_API WrenPlusVM return mForeignClassHandles[Traits::index]; } - //--------------------------------------------------------// + //---------------------------------------------------------- /// Set the list of directories in which wren should search for modules. void set_module_import_dirs(std::vector dirs) @@ -222,7 +217,7 @@ class WRENPLUS_API WrenPlusVM (impl_cache_handle(Traits::module, Traits::className, Traits::index), ...); } - //--------------------------------------------------------// + //---------------------------------------------------------- /// Call a wren method with the given arguments and return the result. template @@ -248,7 +243,7 @@ class WRENPLUS_API WrenPlusVM throw Exception(mErrorString); } - //--------------------------------------------------------// + //---------------------------------------------------------- /// Call a wren method with the given arguments and return the result or any errors. template @@ -281,7 +276,7 @@ class WRENPLUS_API WrenPlusVM return std::string(); } - //--------------------------------------------------------// + //---------------------------------------------------------- /// Wrapper for wrenInterpret that throws. void interpret(const char* module, const char* source); @@ -298,12 +293,12 @@ class WRENPLUS_API WrenPlusVM /// Makes sure that no foreign class indices are missing. void validate_class_handle_cache(); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Lookup a variable that is known to exist. [[nodiscard]] WrenHandle* get_variable(const char* module, const char* variable); -private: //===================================================// +private: //===================================================== static void impl_write_fn(WrenVM*, const char*); @@ -315,19 +310,19 @@ class WRENPLUS_API WrenPlusVM static WrenLoadModuleResult impl_load_module_fn(WrenVM*, const char*); - //--------------------------------------------------------// + //---------------------------------------------------------- void impl_register_method(const char* module, const char* className, const char* signature, WrenForeignMethodFn func); void impl_cache_handle(const char* module, const char* className, size_t index); - //--------------------------------------------------------// + //---------------------------------------------------------- static void impl_pointer_equality_operator(WrenVM* vm); static void impl_pointer_inequality_operator(WrenVM* vm); - //--------------------------------------------------------// + //---------------------------------------------------------- WrenVM* mWrenVM = nullptr; @@ -340,7 +335,7 @@ class WRENPLUS_API WrenPlusVM std::string mErrorString; }; -//============================================================================// +//============================================================================== namespace detail { @@ -425,9 +420,9 @@ inline void base_class_slot_helper_set_inner(WrenVM* vm, int slot, BaseType* ptr } // namespace detail -} // namespace wren +} // namespace wren ############################################################ -//===== STANDARD SLOT HELPERS ================================================// +// STANDARD SLOT HELPERS ======================================================= /// Specialisation for compile-time null. template <> @@ -668,7 +663,7 @@ struct wren::SlotHelper> //} }; -//===== SQEE SLOT HELPERS ====================================================// +// SQEE SLOT HELPERS =========================================================== #include diff --git a/include/sqee/core/EnumHelper.hpp b/include/sqee/core/EnumHelper.hpp index 34148bb..0a27630 100644 --- a/include/sqee/core/EnumHelper.hpp +++ b/include/sqee/core/EnumHelper.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include @@ -15,9 +12,7 @@ #include #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### /// Try to convert an enum to a string. template @@ -59,11 +54,7 @@ constexpr Type enum_from_string(std::string_view arg) throw std::runtime_error(fmt::format("enum_from_string<{}>({})", type_name_v.c_str(), arg)); } -//============================================================================// - -} // namespace sq - -//============================================================================// +} // namespace sq ############################################################## #define SQEE_ENUM_HELPER(Type, First, ...) \ template <> inline constexpr auto sq::type_name_v = sq::StackString(#Type); \ @@ -72,7 +63,7 @@ template <> inline constexpr auto sq::enum_count_v = std::underlying_type_ template <> inline constexpr auto sq::enum_values_v = []() { using enum Type; return std::array { First, __VA_ARGS__ }; }(); \ template <> inline constexpr auto sq::enum_strings_v = []() { return std::array { SQEE_STRINGIFY_ARGS(First, __VA_ARGS__) }; }(); -//============================================================================// +//============================================================================== template struct fmt::formatter : fmt::formatter diff --git a/include/sqee/core/Macros.hpp b/include/sqee/core/Macros.hpp index 5bd9b71..c42bf2f 100644 --- a/include/sqee/core/Macros.hpp +++ b/include/sqee/core/Macros.hpp @@ -1,9 +1,6 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once -//============================================================================// +//============================================================================== #if defined(SQEE_GNU) || defined(SQEE_CLANG) @@ -31,7 +28,7 @@ _Pragma("GCC diagnostic pop") #endif -//============================================================================// +//============================================================================== #define SQEE_EXPAND(Arg) Arg // needed to work around an MSVC bug @@ -48,7 +45,7 @@ _Pragma("GCC diagnostic pop") _90, _91, _92, _93, _94, _95, _96, _97, _98, _99, \ Name, ...) Name -//============================================================================// +//============================================================================== #define SQEE_FOR_EACH_00(Functor, Arg) Functor(Arg) #define SQEE_FOR_EACH_01(Functor, Arg, ...) Functor(Arg) SQEE_EXPAND(SQEE_FOR_EACH_00(Functor, __VA_ARGS__)) @@ -174,7 +171,7 @@ _Pragma("GCC diagnostic pop") SQEE_FOR_EACH_04, SQEE_FOR_EACH_03, SQEE_FOR_EACH_02, SQEE_FOR_EACH_01, SQEE_FOR_EACH_00, \ ) ( Functor, __VA_ARGS__ ) ) -//============================================================================// +//============================================================================== #define SWITCH(Value) do { using SwitchValueT = std::decay_t; switch (Value) @@ -186,7 +183,7 @@ _Pragma("GCC diagnostic pop") #define CASE_DEFAULT break; default: -//============================================================================// +//============================================================================== #define SQEE_COUNT_ARGS_INNER(Arg) +1 #define SQEE_COUNT_ARGS(First, ...) (1 SQEE_FOR_EACH(SQEE_COUNT_ARGS_INNER, __VA_ARGS__)) diff --git a/include/sqee/core/Strings.hpp b/include/sqee/core/Strings.hpp index 3dec14d..0c9c363 100644 --- a/include/sqee/core/Strings.hpp +++ b/include/sqee/core/Strings.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include @@ -12,9 +9,7 @@ #include #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### template constexpr size_t string_length(const char(&)[Size]) @@ -54,7 +49,7 @@ inline std::string string_concat(const Args&... args) return result; } -//============================================================================// +//============================================================================== template consteval auto format_consteval() @@ -65,7 +60,7 @@ consteval auto format_consteval() return result; }; -//============================================================================// +//============================================================================== /// Only perform formatting if arguments are given. template @@ -86,6 +81,4 @@ inline OutputIt vformat_to_if_args(OutputIt out, fmt::string_view fstr, fmt::for return fmt::detail::get_iterator(buf, out); } -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/core/TypeAliases.hpp b/include/sqee/core/TypeAliases.hpp index f2aaa2a..7e69755 100644 --- a/include/sqee/core/TypeAliases.hpp +++ b/include/sqee/core/TypeAliases.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include // IWYU pragma: export diff --git a/include/sqee/core/TypeNames.hpp b/include/sqee/core/TypeNames.hpp index ddba7ef..31ceaca 100644 --- a/include/sqee/core/TypeNames.hpp +++ b/include/sqee/core/TypeNames.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include diff --git a/include/sqee/core/TypeTraits.hpp b/include/sqee/core/TypeTraits.hpp index 4d3683f..c59907f 100644 --- a/include/sqee/core/TypeTraits.hpp +++ b/include/sqee/core/TypeTraits.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include // IWYU pragma: export diff --git a/include/sqee/core/Utilities.hpp b/include/sqee/core/Utilities.hpp index 16c67d1..3f2cce6 100644 --- a/include/sqee/core/Utilities.hpp +++ b/include/sqee/core/Utilities.hpp @@ -1,13 +1,8 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### template struct Structure; @@ -27,7 +22,7 @@ template struct Structure template Structure(const Elements&...) -> Structure; -//============================================================================// +//============================================================================== /// Holds two values of the same type. template @@ -38,6 +33,4 @@ struct Swapper Type front, back; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/data/BuiltinShaders.hpp b/include/sqee/data/BuiltinShaders.hpp index 15fbc1d..18a3419 100644 --- a/include/sqee/data/BuiltinShaders.hpp +++ b/include/sqee/data/BuiltinShaders.hpp @@ -1,11 +1,10 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee +#pragma once #include #include -//============================================================================// +//============================================================================== SQEE_API extern const uint32_t sqee_GuiSystemVertSpv[234]; diff --git a/include/sqee/data/UbuntuMinimal.hpp b/include/sqee/data/UbuntuMinimal.hpp index ab69f81..d137c87 100644 --- a/include/sqee/data/UbuntuMinimal.hpp +++ b/include/sqee/data/UbuntuMinimal.hpp @@ -1,11 +1,10 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee +#pragma once #include #include -//============================================================================// +//============================================================================== SQEE_API extern const int32_t sqee_UbuntuRegular_size; SQEE_API extern const uint32_t sqee_UbuntuRegular[23180/4]; diff --git a/include/sqee/data/VolumeMeshes.hpp b/include/sqee/data/VolumeMeshes.hpp index 64f74fd..1d3ecd2 100644 --- a/include/sqee/data/VolumeMeshes.hpp +++ b/include/sqee/data/VolumeMeshes.hpp @@ -1,11 +1,10 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee +#pragma once #include #include -//============================================================================// +//============================================================================== // cone scale = 1.00864 diff --git a/include/sqee/debug/Assert.hpp b/include/sqee/debug/Assert.hpp index c262bd4..513240a 100644 --- a/include/sqee/debug/Assert.hpp +++ b/include/sqee/debug/Assert.hpp @@ -1,9 +1,6 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once -//============================================================================// +//============================================================================== #ifdef SQEE_DEBUG @@ -49,7 +46,7 @@ do { \ #endif -//============================================================================// +//============================================================================== #else diff --git a/include/sqee/debug/Logging.hpp b/include/sqee/debug/Logging.hpp index 96c1c50..bf3ac15 100644 --- a/include/sqee/debug/Logging.hpp +++ b/include/sqee/debug/Logging.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include @@ -10,9 +7,7 @@ #include #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### namespace detail { @@ -26,7 +21,7 @@ SQEE_API void log_multiline(std::string_view category, fmt::string_view fstr, fm } // namespace detail -//============================================================================// +//============================================================================== inline void log_info(std::string_view str) { @@ -50,7 +45,7 @@ inline void log_info_multiline(fmt::format_string fstr, Args&&... args) detail::log_multiline("INFO", fstr, fmt::make_format_args(args...)); } -//============================================================================// +//============================================================================== inline void log_warning(std::string_view str) { @@ -74,7 +69,7 @@ inline void log_warning_multiline(fmt::format_string fstr, Args&&... ar detail::log_multiline("WARNING", fstr, fmt::make_format_args(args...)); } -//============================================================================// +//============================================================================== [[noreturn]] inline void log_error(std::string_view str) { @@ -102,7 +97,7 @@ template std::abort(); } -//============================================================================// +//============================================================================== inline void log_debug(std::string_view str) { @@ -142,7 +137,7 @@ inline void log_debug_multiline(fmt::format_string fstr, Args&&... args #endif } -//============================================================================// +//============================================================================== inline void log_custom(std::string_view category, std::string_view str) { @@ -166,6 +161,4 @@ inline void log_custom_multiline(std::string_view category, fmt::format_string diff --git a/include/sqee/maths/Culling.hpp b/include/sqee/maths/Culling.hpp index ec1b48c..9c3a548 100644 --- a/include/sqee/maths/Culling.hpp +++ b/include/sqee/maths/Culling.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #include #include @@ -18,9 +15,7 @@ // - for frustum culling // - written ages ago, might miss some edge cases -namespace sq::maths { - -//============================================================================// +namespace sq::maths { //######################################################## /// Check for intersection between a @ref Sphere and a @ref Sphere. /// @@ -45,7 +40,7 @@ inline int8_t test_inout_sphere_sphere(Sphere first, Sphere second) return 0; // intersects } -//============================================================================// +//============================================================================== /// Check for intersection between a @ref Sphere and a @ref Capsule. /// @@ -74,7 +69,7 @@ inline int8_t test_inout_sphere_capsule(Sphere sphere, Capsule capsule) return 0; // intersects } -//============================================================================// +//============================================================================== /// Check for intersection between a @ref Sphere and an @ref Ortho2D. /// @@ -113,7 +108,7 @@ inline int8_t test_inout_sphere_ortho(Sphere sphere, Ortho2D ortho) return +1; // fully inside } -//============================================================================// +//============================================================================== /// Check for intersection between a @ref Capsule and a @ref Capsule. /// @@ -188,7 +183,7 @@ inline bool intersect_capsule_capsule(Capsule capsuleA, Capsule capsuleB) return distSquare <= radiusSum * radiusSum; } -//============================================================================// +//============================================================================== /// Check if a @ref Sphere and a @ref Sphere do not intersect. /// @@ -205,7 +200,7 @@ inline bool cull_sphere_sphere(Sphere first, Sphere second) return distSquare > radiusSum * radiusSum; } -//============================================================================// +//============================================================================== /// Check if a @ref Box and a @ref Sphere do not intersect. /// @@ -234,7 +229,7 @@ inline bool cull_box_sphere(Box box, Sphere sphere) return false; } -//============================================================================// +//============================================================================== /// Check if a @ref Sphere and an @ref Ortho2D do not intersect. /// @@ -258,7 +253,7 @@ inline bool cull_sphere_ortho(Sphere sphere, Ortho2D ortho) return dotZ + ortho.planeZ.offset >= sphere.radius; } -//============================================================================// +//============================================================================== /// Check if a @ref Box and an @ref Ortho2D do not intersect. /// @@ -272,7 +267,7 @@ inline bool cull_box_ortho(Box box, Ortho2D ortho) const int8_t sphereTest = test_inout_sphere_ortho({box.origin, box.radius}, ortho); if (sphereTest != 0) return sphereTest < 0; // early exit if fully out or in - //--------------------------------------------------------// + //---------------------------------------------------------- const Vec3F sideOffsetX = box.basis[0] * box.extents.x; const Vec3F sideOffsetY = box.basis[1] * box.extents.y; @@ -290,7 +285,7 @@ inline bool cull_box_ortho(Box box, Ortho2D ortho) box.origin + sideOffsetX + sideOffsetY + sideOffsetZ }; - //--------------------------------------------------------// + //---------------------------------------------------------- uint8_t bitsPosX = 0u, bitsNegX = 0u; @@ -303,7 +298,7 @@ inline bool cull_box_ortho(Box box, Ortho2D ortho) if (bitsPosX == 0u || bitsNegX == 0u) return true; - //--------------------------------------------------------// + //---------------------------------------------------------- uint8_t bitsPosY = 0u, bitsNegY = 0u; @@ -316,7 +311,7 @@ inline bool cull_box_ortho(Box box, Ortho2D ortho) if (bitsPosY == 0u || bitsNegY == 0u) return true; - //--------------------------------------------------------// + //---------------------------------------------------------- uint8_t bitsFar = 0u; @@ -328,7 +323,7 @@ inline bool cull_box_ortho(Box box, Ortho2D ortho) if (bitsFar == 0u) return true; - //--------------------------------------------------------// + //---------------------------------------------------------- return false; @@ -410,7 +405,7 @@ inline bool cull_box_ortho(Box box, Ortho2D ortho) */ } -//============================================================================// +//============================================================================== /// Check if a @ref Sphere and a @ref Frustum do not intersect. /// @@ -439,7 +434,7 @@ inline bool cull_sphere_frustum(Sphere sphere, Frustum frustum) return false; } -//============================================================================// +//============================================================================== /// Check if a @ref Box and a @ref Frustum do not intersect. /// @@ -452,7 +447,7 @@ inline bool cull_box_frustum(Box box, Frustum frustum) { if (cull_sphere_frustum({box.origin, box.radius}, frustum)) return true; - //--------------------------------------------------------// + //---------------------------------------------------------- const Vec3F offsetX = box.basis[0] * box.extents.x; const Vec3F offsetY = box.basis[1] * box.extents.y; @@ -467,7 +462,7 @@ inline bool cull_box_frustum(Box box, Frustum frustum) const Vec3F pointG = box.origin + offsetX + offsetY - offsetZ; const Vec3F pointH = box.origin + offsetX + offsetY + offsetZ; - //--------------------------------------------------------// + //---------------------------------------------------------- const auto test_points_plane = [&](Plane plane) -> uint8_t { @@ -485,7 +480,7 @@ inline bool cull_box_frustum(Box box, Frustum frustum) return result; }; - //--------------------------------------------------------// + //---------------------------------------------------------- if (test_points_plane(frustum.planes[0]) == 0u) return true; if (test_points_plane(frustum.planes[1]) == 0u) return true; @@ -496,6 +491,4 @@ inline bool cull_box_frustum(Box box, Frustum frustum) return false; } -//============================================================================// - -} // namespace sq::maths +} // namespace sq::maths ####################################################### diff --git a/include/sqee/maths/Functions.hpp b/include/sqee/maths/Functions.hpp index 420e98f..7602673 100644 --- a/include/sqee/maths/Functions.hpp +++ b/include/sqee/maths/Functions.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include diff --git a/include/sqee/maths/Matrices.hpp b/include/sqee/maths/Matrices.hpp index 70e5fe4..27c7ee3 100644 --- a/include/sqee/maths/Matrices.hpp +++ b/include/sqee/maths/Matrices.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include diff --git a/include/sqee/maths/Quaternion.hpp b/include/sqee/maths/Quaternion.hpp index 599181a..8439a5b 100644 --- a/include/sqee/maths/Quaternion.hpp +++ b/include/sqee/maths/Quaternion.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include diff --git a/include/sqee/maths/Random.hpp b/include/sqee/maths/Random.hpp index 6d9b555..1c2af66 100644 --- a/include/sqee/maths/Random.hpp +++ b/include/sqee/maths/Random.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include diff --git a/include/sqee/maths/Scalar.hpp b/include/sqee/maths/Scalar.hpp index 0b2d803..16d59e1 100644 --- a/include/sqee/maths/Scalar.hpp +++ b/include/sqee/maths/Scalar.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include diff --git a/include/sqee/maths/Vectors.hpp b/include/sqee/maths/Vectors.hpp index c3bd8d2..4471991 100644 --- a/include/sqee/maths/Vectors.hpp +++ b/include/sqee/maths/Vectors.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include diff --git a/include/sqee/maths/Volumes.hpp b/include/sqee/maths/Volumes.hpp index 1bd59d5..f606b6f 100644 --- a/include/sqee/maths/Volumes.hpp +++ b/include/sqee/maths/Volumes.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include @@ -9,9 +6,7 @@ #include #include -namespace sq::maths { - -//============================================================================// +namespace sq::maths { //######################################################## struct Plane { @@ -69,7 +64,7 @@ struct Frustum Plane planes[5]; // near, L, R, B, T }; -//============================================================================// +//============================================================================== inline Frustum make_frustum(Mat4F matrix, Vec3F origin, Vec3F direction, float radius) { @@ -100,7 +95,7 @@ inline Frustum make_frustum(Mat4F matrix, Vec3F origin, Vec3F direction, float r return result; } -//============================================================================// +//============================================================================== /// Check if a point is inside of a @ref Sphere. /// @@ -118,7 +113,7 @@ inline bool point_in_sphere(Vec3F point, Sphere sphere, float scale = 1.f) return dist < radius; } -//============================================================================// +//============================================================================== /// Check if a point is inside of a @ref Cone. /// @@ -140,7 +135,7 @@ inline bool point_in_cone(Vec3F point, Cone cone, float scale = 1.f) return circleDist < circleRadius; } -//============================================================================// +//============================================================================== /// Check if a point is inside of a @ref Plane. /// @@ -154,7 +149,7 @@ inline bool point_in_plane(Vec3F point, Plane plane) return maths::dot(point, plane.normal) < plane.offset; } -//============================================================================// +//============================================================================== /// Check if a point is inside of an @ref Ortho2D. /// @@ -174,6 +169,4 @@ inline bool point_in_ortho(Vec3F point, Ortho2D ortho) return true; } -//============================================================================// - -} // namespace sq::maths +} // namespace sq::maths ####################################################### diff --git a/include/sqee/misc/Files.hpp b/include/sqee/misc/Files.hpp index 66a5d2e..8c22180 100644 --- a/include/sqee/misc/Files.hpp +++ b/include/sqee/misc/Files.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include @@ -11,9 +8,7 @@ // Windows is kind enough to work just fine with unix paths, so there's no need // for anything platform specific. -namespace sq { - -//============================================================================// +namespace sq { //############################################################### /// Load a text file into a string. SQEE_API String read_text_from_file(const String& path); @@ -33,7 +28,7 @@ SQEE_API void write_text_to_file(const String& path, StringView text, bool endNe /// Save some bytes to a binary file. SQEE_API void write_bytes_to_file(const String& path, const void* bytes, size_t size); -//============================================================================// +//============================================================================== /// A file or string that has been split by spaces and newlines. struct SQEE_API TokenisedFile @@ -49,7 +44,7 @@ struct SQEE_API TokenisedFile /// Take ownership of a string and tokenise it. static TokenisedFile from_string(String&& text); - //--------------------------------------------------------// + //---------------------------------------------------------- using Tokens = std::vector; struct Line { Tokens tokens; size_t lineNum; }; @@ -58,6 +53,4 @@ struct SQEE_API TokenisedFile std::vector lines; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/misc/Json.hpp b/include/sqee/misc/Json.hpp index dcac632..a6e0e2c 100644 --- a/include/sqee/misc/Json.hpp +++ b/include/sqee/misc/Json.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include diff --git a/include/sqee/misc/Parsing.hpp b/include/sqee/misc/Parsing.hpp index ba66c56..493d8ea 100644 --- a/include/sqee/misc/Parsing.hpp +++ b/include/sqee/misc/Parsing.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include @@ -11,9 +8,7 @@ #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### /// Split a string into a fixed number of segments. Check for success with `!result.back().empty()`. template @@ -35,7 +30,7 @@ constexpr std::array split_string(StringVie return result; } -//============================================================================// +//============================================================================== /// Split a StringView into a vector of tokens. SQEE_API std::vector tokenise_string(StringView sv, char dlm); @@ -46,7 +41,7 @@ SQEE_API void tokenise_string(StringView sv, char dlm, std::vector& /// Split a StringView into lines, keeping empty lines. SQEE_API std::vector tokenise_string_lines(StringView sv); -//============================================================================// +//============================================================================== template inline Number parse_number(StringView sv) @@ -79,7 +74,7 @@ inline void parse_number(Number& out, StringView sv) requires std::floating_poin } #endif -//============================================================================// +//============================================================================== template inline void parse_numbers(maths::Vector<2, T>& out, StringView x, StringView y) @@ -114,7 +109,7 @@ inline void parse_numbers(maths::Quaternion& out, StringView x, StringView y, parse_number(out.w, w); } -//============================================================================// +//============================================================================== template inline void parse_numbers_normalize(maths::Vector<2, T>& out, StringView x, StringView y) @@ -144,6 +139,4 @@ inline void parse_numbers_normalize(maths::Quaternion& out, StringView x, Str out = maths::normalize(out); } -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/misc/ResourceCache.hpp b/include/sqee/misc/ResourceCache.hpp index 9cec20a..d0a9021 100644 --- a/include/sqee/misc/ResourceCache.hpp +++ b/include/sqee/misc/ResourceCache.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include @@ -9,15 +6,13 @@ #include #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### /// Class that provides caching of a type of resource. template class ResourceCache final { -public: //====================================================// +public: //====================================================== using Factory = std::function; @@ -92,7 +87,7 @@ class ResourceCache final } } -private: //===================================================// +private: //===================================================== // todo: experiment with using unordered_map instead std::map> mResourceMap; @@ -101,6 +96,4 @@ class ResourceCache final Factory mFactoryFunc; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/misc/ResourceHandle.hpp b/include/sqee/misc/ResourceHandle.hpp index 3dc540c..26c7607 100644 --- a/include/sqee/misc/ResourceHandle.hpp +++ b/include/sqee/misc/ResourceHandle.hpp @@ -1,15 +1,10 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### /// For internal use by ResourceCache and Handle. template @@ -26,13 +21,13 @@ struct Resource final size_t count; }; -//============================================================================// +//============================================================================== /// Provides reference counted access to a resource. template class Handle final { -public: //====================================================// +public: //====================================================== Handle(std::nullptr_t = nullptr) noexcept { @@ -78,7 +73,7 @@ class Handle final if (mResourcePtr) --mResourcePtr->count; } - //--------------------------------------------------------// + //---------------------------------------------------------- bool good() const noexcept { @@ -116,15 +111,13 @@ class Handle final return mResourcePtr->error; } - //--------------------------------------------------------// + //---------------------------------------------------------- bool operator==(const Handle& other) const noexcept { return mResourcePtr == other.mResourcePtr; } -private: //===================================================// +private: //===================================================== Resource* mResourcePtr; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/misc/StackString.hpp b/include/sqee/misc/StackString.hpp index 59a78f7..afa69eb 100644 --- a/include/sqee/misc/StackString.hpp +++ b/include/sqee/misc/StackString.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include diff --git a/include/sqee/misc/StackVector.hpp b/include/sqee/misc/StackVector.hpp index 95974e3..3020ee9 100644 --- a/include/sqee/misc/StackVector.hpp +++ b/include/sqee/misc/StackVector.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include diff --git a/include/sqee/objects/Armature.hpp b/include/sqee/objects/Armature.hpp index 6dafd72..1fa9eb6 100644 --- a/include/sqee/objects/Armature.hpp +++ b/include/sqee/objects/Armature.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include @@ -13,9 +10,7 @@ #include #include // Flags -namespace sq { - -//============================================================================// +namespace sq { //############################################################### /// A set of tracks that can be used to get an AnimSample. struct SQEE_API Animation @@ -44,12 +39,12 @@ struct SQEE_API Animation /// A sample from every bone and block track in an armature. using AnimSample = std::vector; -//============================================================================// +//============================================================================== /// Asset defining bones and other animation tracks. class SQEE_API Armature { -public: //====================================================// +public: //====================================================== enum class TrackType : uint8_t { @@ -86,7 +81,7 @@ class SQEE_API Armature Vec3F scale; }; - //--------------------------------------------------------// + //---------------------------------------------------------- Armature() = default; Armature(const String& path) { load_from_file(path); } @@ -97,7 +92,7 @@ class SQEE_API Armature /// Load the armature from JSON. void load_from_file(const String& path); - //--------------------------------------------------------// + //---------------------------------------------------------- size_t get_bone_count() const { return mBoneInfos.size(); } @@ -113,7 +108,7 @@ class SQEE_API Armature const std::vector& get_track_names() const { return mBlockNames; } - //--------------------------------------------------------// + //---------------------------------------------------------- /// Get the index of a bone by name, or -1 if not found. int8_t get_bone_index(TinyString name) const noexcept; @@ -130,7 +125,7 @@ class SQEE_API Armature /// Get the name of a bone by index, or null if the index is -1. JsonMutAny json_from_bone_index(JsonMutDocument& document, int8_t index) const noexcept; - //--------------------------------------------------------// + //---------------------------------------------------------- /// Load an associated animation from an SQA file. Animation load_animation_from_file(const String& path) const; @@ -138,7 +133,7 @@ class SQEE_API Armature /// Generate an animation contaning N frames of the rest pose. Animation make_null_animation(uint frameCount) const; - //--------------------------------------------------------// + //---------------------------------------------------------- /// Sample an animation at the given time. void compute_sample(const Animation& animation, float time, AnimSample& out) const; @@ -146,7 +141,7 @@ class SQEE_API Armature /// Blend between two animation samples. void blend_samples(const AnimSample& a, const AnimSample& b, float factor, AnimSample& out) const; - //--------------------------------------------------------// + //---------------------------------------------------------- // Bone matrices are absolute transforms. Used to transform objects not // bound to this armature, or for drawing a skeleton. @@ -171,7 +166,7 @@ class SQEE_API Armature const AnimSample& sample, Mat4F viewMatrix, Mat4F invViewMatrix, Mat4F modelMatrix, Vec2F billboardScale, Mat34F* modelMats, size_t len ) const; -private: //===================================================// +private: //===================================================== AnimSample mRestSample; @@ -186,14 +181,12 @@ class SQEE_API Armature std::vector mBlockNames; std::vector mTrackNames; - //--------------------------------------------------------// + //---------------------------------------------------------- Animation impl_load_animation_text(String&& text) const; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## SQEE_ENUM_HELPER ( diff --git a/include/sqee/objects/DrawItem.hpp b/include/sqee/objects/DrawItem.hpp index 751bc5b..65273ef 100644 --- a/include/sqee/objects/DrawItem.hpp +++ b/include/sqee/objects/DrawItem.hpp @@ -9,9 +9,7 @@ #include #include -namespace sq { - -//====== Forward Declarations ================================================// +namespace sq { //############################################################### using AnimSample = std::vector; @@ -20,7 +18,7 @@ class Mesh; class Pipeline; class Texture; -//============================================================================// +//============================================================================== /// Used to generate a draw call each frame. struct SQEE_API DrawItem @@ -134,9 +132,7 @@ struct SQEE_API DrawItem ) const; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## SQEE_ENUM_HELPER ( diff --git a/include/sqee/objects/Mesh.hpp b/include/sqee/objects/Mesh.hpp index 6cba640..d1a40d4 100644 --- a/include/sqee/objects/Mesh.hpp +++ b/include/sqee/objects/Mesh.hpp @@ -1,7 +1,4 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - -#pragma once +#pragma once #include @@ -11,14 +8,12 @@ #include #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### /// Asset with vertex layouts, bounding info, and sub meshes. class SQEE_API Mesh { -public: //====================================================// +public: //====================================================== enum class Attribute { @@ -45,7 +40,7 @@ class SQEE_API Mesh using Attributes = vk::Flags; - //--------------------------------------------------------// + //---------------------------------------------------------- Mesh() = default; @@ -56,12 +51,12 @@ class SQEE_API Mesh ~Mesh(); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Load the mesh from an SQM file. void load_from_file(const String& path); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Get the index of a sub mesh by name, or -1 if not found. int8_t get_sub_mesh_index(TinyString name) const noexcept; @@ -69,7 +64,7 @@ class SQEE_API Mesh /// Get the index of a sub mesh by name, or -1 if the json is null. int8_t json_as_sub_mesh_index(JsonAny json) const; - //--------------------------------------------------------// + //---------------------------------------------------------- /// Bind vertex and index buffers. void bind_buffers(vk::CommandBuffer cmdbuf) const; @@ -77,7 +72,7 @@ class SQEE_API Mesh /// Draw the entire mesh, or a sub mesh. void draw(vk::CommandBuffer cmdbuf, int8_t subMesh = -1) const; - //--------------------------------------------------------// + //---------------------------------------------------------- /// Check what attributes the mesh contains. Attributes get_attributes() const { return mAttributes; } @@ -85,7 +80,7 @@ class SQEE_API Mesh /// Access the mesh's bounding information. const Bounds& get_bounds() const { return mBounds; } - //--------------------------------------------------------// + //---------------------------------------------------------- /// Vertex Layout information, ready for vulkan. struct SQEE_API VertexConfig @@ -97,7 +92,7 @@ class SQEE_API Mesh vk::PipelineVertexInputStateCreateInfo state; }; -private: //===================================================// +private: //===================================================== BufferStuff mVertexBuffer; BufferStuff mIndexBuffer; @@ -110,20 +105,18 @@ class SQEE_API Mesh Bounds mBounds; std::vector mSubMeshes; - //--------------------------------------------------------// + //---------------------------------------------------------- void impl_load_text(String&& text); void impl_load_final(std::vector& vertexData, std::vector& indexData); }; -//============================================================================// +//============================================================================== inline Mesh::Attributes operator|(Mesh::Attribute lhs, Mesh::Attribute rhs) { return Mesh::Attributes(int(lhs) | int(rhs)); } -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/objects/Pipeline.hpp b/include/sqee/objects/Pipeline.hpp index 5576693..fe951ad 100644 --- a/include/sqee/objects/Pipeline.hpp +++ b/include/sqee/objects/Pipeline.hpp @@ -8,9 +8,7 @@ #include #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### /// A Vulkan Pipeline defined in JSON, with reflection data. /// @@ -21,7 +19,7 @@ namespace sq { /// class SQEE_API Pipeline { -public: //====================================================// +public: //====================================================== enum class PushConstantType : uint8_t { @@ -39,7 +37,7 @@ class SQEE_API Pipeline bool vertex, fragment; }; - //--------------------------------------------------------// + //---------------------------------------------------------- Pipeline() = default; @@ -50,7 +48,7 @@ class SQEE_API Pipeline ~Pipeline(); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Load the pipeline from a minified json string. void load_from_minified_json(const String& minified, const PassConfigMap& passes); @@ -58,7 +56,7 @@ class SQEE_API Pipeline /// Bind the pipeline for rendering. void bind(vk::CommandBuffer cmdbuf) const; - //--------------------------------------------------------// + //---------------------------------------------------------- const PassConfig* get_pass_config() const { return mPassConfig; } @@ -68,7 +66,7 @@ class SQEE_API Pipeline const std::vector& get_push_constants() const { return mPushConstants; } -protected: //=================================================// +protected: //=================================================== const PassConfig* mPassConfig = nullptr; @@ -77,9 +75,7 @@ class SQEE_API Pipeline std::vector mPushConstants; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## SQEE_ENUM_HELPER ( diff --git a/include/sqee/objects/Sound.hpp b/include/sqee/objects/Sound.hpp index 70b3c54..fdfce7f 100644 --- a/include/sqee/objects/Sound.hpp +++ b/include/sqee/objects/Sound.hpp @@ -1,24 +1,19 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include #include -namespace sq { - -//====== Forward Declarations ================================================// +namespace sq { //############################################################### class AudioContext; -//============================================================================// +//============================================================================== /// A sound buffer loaded from a file. class SQEE_API Sound { -public: //====================================================// +public: //====================================================== Sound(AudioContext& context); @@ -29,12 +24,12 @@ class SQEE_API Sound ~Sound(); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Load sound data from the specified file. void load_from_file(const String& path); -private: //===================================================// +private: //===================================================== AudioContext* mContext = nullptr; @@ -43,6 +38,4 @@ class SQEE_API Sound friend AudioContext; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/objects/Texture.hpp b/include/sqee/objects/Texture.hpp index ee73a9c..4016b4b 100644 --- a/include/sqee/objects/Texture.hpp +++ b/include/sqee/objects/Texture.hpp @@ -7,9 +7,7 @@ #include #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### /// Image and Sampler, with metadata loaded from JSON. /// @@ -18,7 +16,7 @@ namespace sq { /// class SQEE_API Texture { -public: //====================================================// +public: //====================================================== enum class FilterMode : int8_t { Nearest, Linear, Anisotropic }; @@ -37,7 +35,7 @@ class SQEE_API Texture uint mipLevels; }; - //--------------------------------------------------------// + //---------------------------------------------------------- Texture() = default; @@ -48,25 +46,25 @@ class SQEE_API Texture ~Texture(); - //--------------------------------------------------------// + //---------------------------------------------------------- void initialise_2D(const Config& config); void load_from_file_2D(const String& path); - //--------------------------------------------------------// + //---------------------------------------------------------- void initialise_array(const Config& config); void load_from_file_array(const String& path); - //--------------------------------------------------------// + //---------------------------------------------------------- void initialise_cube(const Config& config); void load_from_file_cube(const String& path); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Upload data to one layer of one level of the image. Will generate mipmaps if requested. void load_from_memory(const void* data, size_t length, uint level, uint layer, const Config& config); @@ -74,7 +72,7 @@ class SQEE_API Texture /// Upload the entire image's data all at once. void load_from_memory(const void* data, size_t length, const Config& config); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Load image data from a compressed binary file. Return false if file does not exist. bool try_load_from_compressed(const String& path, const Config& config); @@ -82,7 +80,7 @@ class SQEE_API Texture /// Save image data to a binary file compressed with lz4. void save_as_compressed(const String& path, vk::Format format, Vec3U size, uint mipLevels) const; - //--------------------------------------------------------// + //---------------------------------------------------------- /// Get info needed to update a descriptor set. vk::DescriptorImageInfo get_descriptor_info() const @@ -98,12 +96,12 @@ class SQEE_API Texture std::optional get_bindless_descriptor_index() const { return mBindlessDescriptorIndex; } - //--------------------------------------------------------// + //---------------------------------------------------------- /// Compute the total size of a texture, in bytes. static size_t compute_buffer_size(Vec3U size, uint mipLevels, size_t pixelSize); -protected: //=================================================// +protected: //=================================================== ImageStuff mStuff; vk::Sampler mSampler; @@ -111,6 +109,4 @@ class SQEE_API Texture std::optional mBindlessDescriptorIndex; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/setup.hpp b/include/sqee/setup.hpp index 12a11e5..5793f19 100644 --- a/include/sqee/setup.hpp +++ b/include/sqee/setup.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include // IWYU pragma: export @@ -42,7 +39,7 @@ #include // IWYU pragma: export #include // IWYU pragma: export -//============================================================================// +//============================================================================== // without these, IWYU sometimes reccomends stddef.h typedef std::ptrdiff_t ptrdiff_t; @@ -71,7 +68,7 @@ typedef unsigned int ImGuiID; #define SQEE_COPY_DEFAULT(Class) Class(const Class&) = default; Class& operator=(const Class&) = default; #define SQEE_MOVE_DEFAULT(Class) Class(Class&&) = default; Class& operator=(Class&&) = default; -//============================================================================// +//============================================================================== namespace sq { @@ -86,7 +83,7 @@ namespace views { using namespace std::ranges::views; } } // namespace sq -//============================================================================// +//============================================================================== /// @namespace sq /// @brief The primary SQEE namespace. diff --git a/include/sqee/vk/Helpers.hpp b/include/sqee/vk/Helpers.hpp index 777b33c..f7b890c 100644 --- a/include/sqee/vk/Helpers.hpp +++ b/include/sqee/vk/Helpers.hpp @@ -8,14 +8,12 @@ #include #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### template using ArrayProxyRef = const vk::ArrayProxy&; -//============================================================================// +//============================================================================== struct SQEE_API StagingBuffer { @@ -46,7 +44,7 @@ struct SQEE_API ShaderModules std::vector stages; }; -//============================================================================// +//============================================================================== template struct SpecialisationInfo { @@ -71,7 +69,7 @@ template struct SpecialisationInfo template SpecialisationInfo(Values...) -> SpecialisationInfo; -//============================================================================// +//============================================================================== SQEE_API vk::Pipeline vk_create_graphics_pipeline ( const VulkanContext& ctx, vk::PipelineLayout layout, vk::RenderPass renderPass, uint32_t subpass, @@ -87,7 +85,7 @@ SQEE_API vk::Pipeline vk_create_graphics_pipeline ( ArrayProxyRef dynamicStates ); -//============================================================================// +//============================================================================== SQEE_API vk::DescriptorSet vk_allocate_descriptor_set ( const VulkanContext& ctx, vk::DescriptorSetLayout layout @@ -97,7 +95,7 @@ SQEE_API Swapper vk_allocate_descriptor_set_swapper ( const VulkanContext& ctx, vk::DescriptorSetLayout layout ); -//============================================================================// +//============================================================================== struct DescriptorUniformBuffer { @@ -159,7 +157,7 @@ struct DescriptorInputAttachment vk::DescriptorImageInfo front, back; }; -//============================================================================// +//============================================================================== namespace detail { @@ -197,7 +195,7 @@ inline vk::WriteDescriptorSet make_write_descriptor_set(vk::DescriptorSet dset, } // namespace detail -//============================================================================// +//============================================================================== template inline void vk_update_descriptor_set(const VulkanContext& ctx, vk::DescriptorSet dset, Descriptors... descriptors) @@ -224,7 +222,7 @@ inline void vk_update_descriptor_set_swapper(const VulkanContext& ctx, Swapper #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### /// A set of constants to freeze when compiling a Pipeline. /// @@ -60,7 +58,7 @@ struct SpecialisationConstants final vk::SpecializationInfo info; }; -//============================================================================// +//============================================================================== /// Information about a RenderPass, for use by Pipelines. struct PassConfig final @@ -78,6 +76,4 @@ struct PassConfig final using PassConfigMap = std::map; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/vk/SwapBuffer.hpp b/include/sqee/vk/SwapBuffer.hpp index c68336a..6c97507 100644 --- a/include/sqee/vk/SwapBuffer.hpp +++ b/include/sqee/vk/SwapBuffer.hpp @@ -1,6 +1,3 @@ -// Copyright(c) 2020 James Gangur -// Part of https://github.com/jagoly/sqee - #pragma once #include @@ -9,13 +6,11 @@ #include #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### class SQEE_API SwapBuffer { -public: //====================================================// +public: //====================================================== SwapBuffer() = default; @@ -26,12 +21,12 @@ class SQEE_API SwapBuffer ~SwapBuffer(); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Create and allocate buffers. void initialise(size_t size, vk::BufferUsageFlags usage); - //--------------------------------------------------------// + //---------------------------------------------------------- /// Swap front and back buffers. void swap_only() { mStuff.swap(); mPointer.swap(); } @@ -45,7 +40,7 @@ class SQEE_API SwapBuffer /// Swap front and back, then map front. std::byte* swap_map() { swap_only(); return map_only(); }; - //--------------------------------------------------------// + //---------------------------------------------------------- /// Access the front buffer object. vk::Buffer front() const { return mStuff.front.buffer; } @@ -59,7 +54,7 @@ class SQEE_API SwapBuffer return { {mStuff.front.buffer, 0u, mSize}, {mStuff.back.buffer, 0u, mSize} }; } -private: //===================================================// +private: //===================================================== Swapper mStuff; Swapper mPointer; @@ -67,6 +62,4 @@ class SQEE_API SwapBuffer size_t mSize = 0u; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/vk/VulkanContext.hpp b/include/sqee/vk/VulkanContext.hpp index 2ab6bba..c7d153a 100644 --- a/include/sqee/vk/VulkanContext.hpp +++ b/include/sqee/vk/VulkanContext.hpp @@ -6,9 +6,7 @@ #include #include -namespace sq { - -//====== Forward Declarations ================================================// +namespace sq { //############################################################### class VulkanAllocator; class Window; @@ -16,11 +14,11 @@ class Window; template using ArrayProxyRef = const vk::ArrayProxy&; -//============================================================================// +//============================================================================== class SQEE_API VulkanContext { -public: //====================================================// +public: //====================================================== SQEE_COPY_DELETE(VulkanContext) SQEE_MOVE_DELETE(VulkanContext) @@ -28,7 +26,7 @@ class SQEE_API VulkanContext /// Access the static VulkanContext instance. static const VulkanContext& get(); - //--------------------------------------------------------// + //---------------------------------------------------------- VulkanAllocator& allocator; @@ -37,7 +35,7 @@ class SQEE_API VulkanContext vk::CommandPool commandPool; vk::DescriptorPool descriptorPool; - //--------------------------------------------------------// + //---------------------------------------------------------- /// Relevant hardware limits from device. struct @@ -48,7 +46,7 @@ class SQEE_API VulkanContext } limits; - //--------------------------------------------------------// + //---------------------------------------------------------- vk::DescriptorSetLayout create_descriptor_set_layout ( ArrayProxyRef bindings @@ -82,13 +80,13 @@ class SQEE_API VulkanContext vk::DescriptorPool pool, vk::DescriptorSetLayout layout ) const; - //--------------------------------------------------------// + //---------------------------------------------------------- /// Give an object a human readable name for debugging. template void set_debug_object_name(Object object, const char* name) const; -private: //===================================================// +private: //===================================================== VulkanContext(VulkanAllocator& allocator); @@ -102,7 +100,7 @@ class SQEE_API VulkanContext friend Window; }; -//============================================================================// +//============================================================================== inline vk::DescriptorSetLayout VulkanContext::create_descriptor_set_layout(ArrayProxyRef bindings) const { @@ -172,7 +170,7 @@ inline vk::Framebuffer VulkanContext::create_framebuffer(vk::RenderPass renderPa ); } -//============================================================================// +//============================================================================== template inline void VulkanContext::set_debug_object_name(Object object [[maybe_unused]], const char* name [[maybe_unused]]) const @@ -183,6 +181,4 @@ inline void VulkanContext::set_debug_object_name(Object object [[maybe_unused]], #endif } -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/vk/VulkanMemory.hpp b/include/sqee/vk/VulkanMemory.hpp index 265b50e..66f19a9 100644 --- a/include/sqee/vk/VulkanMemory.hpp +++ b/include/sqee/vk/VulkanMemory.hpp @@ -4,29 +4,27 @@ #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### class VulkanMemory; class SQEE_API VulkanAllocator { -public: //====================================================// +public: //====================================================== constexpr static size_t MIN_BLOCK_SIZE = 1024u * 1024u * 4u; constexpr static size_t MIN_ALIGNMENT = 256u; static_assert(MIN_BLOCK_SIZE % MIN_ALIGNMENT == 0u, ""); - //--------------------------------------------------------// + //---------------------------------------------------------- VulkanAllocator() = default; SQEE_COPY_DELETE(VulkanAllocator) SQEE_MOVE_DELETE(VulkanAllocator) - //--------------------------------------------------------// + //---------------------------------------------------------- void initialise(vk::Device device, uint32_t memTypeHost, uint32_t memTypeDevice, size_t maxItems); @@ -40,7 +38,7 @@ class SQEE_API VulkanAllocator size_t get_memory_usage(bool host) const; -private: //===================================================// +private: //===================================================== struct MemoryBlock; @@ -72,7 +70,7 @@ class SQEE_API VulkanAllocator Chunk chunk; }; - //--------------------------------------------------------// + //---------------------------------------------------------- Chunk* impl_find_usable_chunk(size_t size, Chunk& chunk); @@ -80,7 +78,7 @@ class SQEE_API VulkanAllocator void impl_delete_chunk(Chunk* ptr); - //--------------------------------------------------------// + //---------------------------------------------------------- vk::Device mDevice; @@ -98,17 +96,17 @@ class SQEE_API VulkanAllocator friend VulkanMemory; }; -//============================================================================// +//============================================================================== class SQEE_API VulkanMemory { -public: //====================================================// +public: //====================================================== VulkanMemory() : chunk(nullptr) {} VulkanMemory(VulkanAllocator::Chunk* _chunk) : chunk(_chunk) {} - //--------------------------------------------------------// + //---------------------------------------------------------- size_t get_offset() { return chunk->offset; } @@ -116,7 +114,7 @@ class SQEE_API VulkanMemory vk::DeviceMemory get_memory() { return chunk->block->memory; } - //--------------------------------------------------------// + //---------------------------------------------------------- std::byte* map(); @@ -124,15 +122,13 @@ class SQEE_API VulkanMemory void free(); - //--------------------------------------------------------// + //---------------------------------------------------------- operator bool() const { return chunk != nullptr; } -private: //===================================================// +private: //===================================================== VulkanAllocator::Chunk* chunk; }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/include/sqee/vk/Wrappers.hpp b/include/sqee/vk/Wrappers.hpp index 13f40cb..fa13703 100644 --- a/include/sqee/vk/Wrappers.hpp +++ b/include/sqee/vk/Wrappers.hpp @@ -6,16 +6,14 @@ #include #include -namespace sq { - -//============================================================================// +namespace sq { //############################################################### class VulkanContext; template using ArrayProxyRef = const vk::ArrayProxy&; -//============================================================================// +//============================================================================== struct SQEE_API BufferStuff { @@ -29,7 +27,7 @@ struct SQEE_API BufferStuff void destroy(const VulkanContext& ctx); }; -//============================================================================// +//============================================================================== struct SQEE_API ImageStuff { @@ -52,7 +50,7 @@ struct SQEE_API ImageStuff void destroy(const VulkanContext& ctx); }; -//============================================================================// +//============================================================================== struct SQEE_API RenderPassStuff { @@ -66,6 +64,4 @@ struct SQEE_API RenderPassStuff void destroy(const VulkanContext& ctx); }; -//============================================================================// - -} // namespace sq +} // namespace sq ############################################################## diff --git a/source/sqee/app/Application.cpp b/source/sqee/app/Application.cpp index c7b08c2..3cd7897 100644 --- a/source/sqee/app/Application.cpp +++ b/source/sqee/app/Application.cpp @@ -10,7 +10,7 @@ using namespace sq; -//============================================================================// +//============================================================================== int Application::run(int argc, char** argv) { @@ -44,7 +44,7 @@ int Application::run(int argc, char** argv) initialise(std::vector(argv, argv + argc)); - //--------------------------------------------------------// + //---------------------------------------------------------- // seconds stored as a double using Seconds = std::chrono::duration; @@ -71,7 +71,7 @@ int Application::run(int argc, char** argv) std::this_thread::sleep_for(Seconds(mMinSleepUpdatePeriod) - elapsed); } - //--------------------------------------------------------// + //---------------------------------------------------------- return mReturnCode; } diff --git a/source/sqee/app/AudioContext.cpp b/source/sqee/app/AudioContext.cpp index fc012e0..fafe1d0 100644 --- a/source/sqee/app/AudioContext.cpp +++ b/source/sqee/app/AudioContext.cpp @@ -10,7 +10,7 @@ using namespace sq; -//============================================================================// +//============================================================================== struct AudioContext::Implementation { @@ -22,7 +22,7 @@ struct AudioContext::Implementation static void data_callback(ma_device* pevice, void* pOutput, const void* pInput, ma_uint32 frameCount); }; -//============================================================================// +//============================================================================== void AudioContext::Implementation::data_callback(ma_device* pDevice, void* pOutput, const void* /*pInput*/, ma_uint32 frameCount) { @@ -52,7 +52,7 @@ void AudioContext::Implementation::data_callback(ma_device* pDevice, void* pOutp std::erase_if(context->mActiveSounds, predicate); } -//============================================================================// +//============================================================================== AudioContext::AudioContext() : impl(std::make_unique()) { @@ -73,14 +73,14 @@ AudioContext::AudioContext() : impl(std::make_unique()) ma_device_start(&impl->device); } -//============================================================================// +//============================================================================== AudioContext::~AudioContext() { ma_device_uninit(&impl->device); } -//============================================================================// +//============================================================================== int32_t AudioContext::play_sound(const Sound& sound, SoundGroup group, float volume, bool loop) { @@ -102,7 +102,7 @@ int32_t AudioContext::play_sound(const Sound& sound, SoundGroup group, float vol return mCurrentId; } -//============================================================================// +//============================================================================== void AudioContext::set_sound_paused(int32_t id, bool paused) { @@ -126,7 +126,7 @@ void AudioContext::stop_sound(int32_t id) if (iter->id == id) { mActiveSounds.erase(iter); break; } } -//============================================================================// +//============================================================================== // todo: could optimise these, since the ranges are all sorted @@ -153,7 +153,7 @@ void AudioContext::stop_sounds(std::span ids) std::erase_if(mActiveSounds, predicate); } -//============================================================================// +//============================================================================== void AudioContext::set_groups_ignored(SoundGroups groups, bool ignore) { @@ -177,7 +177,7 @@ void AudioContext::stop_groups(SoundGroups groups) std::erase_if(mActiveSounds, predicate); } -//============================================================================// +//============================================================================== void AudioContext::impl_destroy_sound(const Sound& sound) { diff --git a/source/sqee/app/DebugOverlay.cpp b/source/sqee/app/DebugOverlay.cpp index c92d333..c9836a8 100644 --- a/source/sqee/app/DebugOverlay.cpp +++ b/source/sqee/app/DebugOverlay.cpp @@ -4,11 +4,11 @@ using namespace sq; -//============================================================================// +//============================================================================== DebugOverlay::DebugOverlay() : Scene(1.0 / 4.0) {} -//============================================================================// +//============================================================================== void DebugOverlay::update() { @@ -50,14 +50,14 @@ void DebugOverlay::update() } } -//============================================================================// +//============================================================================== void DebugOverlay::integrate(double elapsed, float /*blend*/) { mFrameTimes.push_back(elapsed); } -//============================================================================// +//============================================================================== void DebugOverlay::show_imgui_widgets() { @@ -122,7 +122,7 @@ void DebugOverlay::show_imgui_widgets() } } -//============================================================================// +//============================================================================== void DebugOverlay::notify(String message) { @@ -136,7 +136,7 @@ void DebugOverlay::notify(String message) } } -//============================================================================// +//============================================================================== void DebugOverlay::set_sub_timers(std::initializer_list names) { diff --git a/source/sqee/app/GuiSystem.cpp b/source/sqee/app/GuiSystem.cpp index fc37026..30b2ed5 100644 --- a/source/sqee/app/GuiSystem.cpp +++ b/source/sqee/app/GuiSystem.cpp @@ -16,7 +16,7 @@ using namespace sq; -//============================================================================// +//============================================================================== static void impl_make_colors_linear(ImVec4* colors) { @@ -28,7 +28,7 @@ static void impl_make_colors_linear(ImVec4* colors) } } -//============================================================================// +//============================================================================== void GuiSystem::set_style_widgets_default() { @@ -124,7 +124,7 @@ void GuiSystem::set_style_widgets_supertux() style.MouseCursorScale = 1.f; } -//============================================================================// +//============================================================================== void GuiSystem::set_style_colours_classic() { @@ -211,7 +211,7 @@ void GuiSystem::set_style_colours_supertux() impl_make_colors_linear(colors); } -//============================================================================// +//============================================================================== GuiSystem::GuiSystem(Window& window, InputDevices& inputDevices) : window(window), input(inputDevices) @@ -236,7 +236,7 @@ GuiSystem::GuiSystem(Window& window, InputDevices& inputDevices) create_pipeline(); } -//============================================================================// +//============================================================================== GuiSystem::~GuiSystem() { @@ -249,7 +249,7 @@ GuiSystem::~GuiSystem() ctx.device.destroy(mPipelineLayout); } -//============================================================================// +//============================================================================== void GuiSystem::load_ubuntu_fonts() { @@ -273,7 +273,7 @@ void GuiSystem::load_ubuntu_fonts() io.Fonts->AddFontFromMemoryCompressedTTF(sqee_UbuntuMonoRegular, sqee_UbuntuMonoRegular_size, 16.f, &fontConfig); } -//============================================================================// +//============================================================================== void GuiSystem::create_objects() { @@ -311,7 +311,7 @@ void GuiSystem::create_objects() ImGui::GetIO().Fonts->TexID = &mDescriptorSet; } -//============================================================================// +//============================================================================== void GuiSystem::create_pipeline() { @@ -366,7 +366,7 @@ void GuiSystem::create_pipeline() } } -//============================================================================// +//============================================================================== bool GuiSystem::handle_event(Event event) { @@ -493,7 +493,7 @@ bool GuiSystem::handle_event(Event event) io.AddKeyEvent(ImGuiMod_Super, data.super); }; - //--------------------------------------------------------// + //---------------------------------------------------------- SWITCH ( event.type ) { @@ -551,7 +551,7 @@ bool GuiSystem::handle_event(Event event) } SWITCH_END; } -//============================================================================// +//============================================================================== void GuiSystem::finish_handle_events() { @@ -568,7 +568,7 @@ void GuiSystem::finish_handle_events() ImGui::NewFrame(); } -//============================================================================// +//============================================================================== void GuiSystem::finish_scene_update(double elapsed) { @@ -579,13 +579,13 @@ void GuiSystem::finish_scene_update(double elapsed) io.DeltaTime = float(elapsed); } -//============================================================================// +//============================================================================== void GuiSystem::render_gui(vk::CommandBuffer cmdbuf) { const auto& drawData = *ImGui::GetDrawData(); - //--------------------------------------------------------// + //---------------------------------------------------------- // copy all vertices/indices into same pair of buffers { @@ -604,7 +604,7 @@ void GuiSystem::render_gui(vk::CommandBuffer cmdbuf) } } - //--------------------------------------------------------// + //---------------------------------------------------------- cmdbuf.bindPipeline(vk::PipelineBindPoint::eGraphics, mPipeline); @@ -618,7 +618,7 @@ void GuiSystem::render_gui(vk::CommandBuffer cmdbuf) const vk::DescriptorSet* boundTexture = nullptr; - //--------------------------------------------------------// + //---------------------------------------------------------- // submit drawing commands using offsets into buffers { @@ -654,6 +654,6 @@ void GuiSystem::render_gui(vk::CommandBuffer cmdbuf) } } -//============================================================================// +//============================================================================== void GuiSystem::show_imgui_demo() { ImGui::ShowDemoWindow(); } diff --git a/source/sqee/app/GuiWidgets.cpp b/source/sqee/app/GuiWidgets.cpp index 3c0e57e..d29618f 100644 --- a/source/sqee/app/GuiWidgets.cpp +++ b/source/sqee/app/GuiWidgets.cpp @@ -7,7 +7,7 @@ DISABLE_WARNING_OLD_STYLE_CAST() -//============================================================================// +//============================================================================== namespace ImPlus::detail { @@ -87,7 +87,7 @@ bool ImPlus::detail::is_temp_input_open() return GImGui->TempInputId != 0; } -//============================================================================// +//============================================================================== bool ImGui::DragScalarRange2(ImStrv label, ImGuiDataType data_type, void* p_current_min, void* p_current_max, float v_speed, const void* p_min, const void* p_max, const char* format, const char* format_max, ImGuiSliderFlags flags) { @@ -156,7 +156,7 @@ bool ImGui::DragScalarRange2(ImStrv label, ImGuiDataType data_type, void* p_curr return value_changed; } -//============================================================================// +//============================================================================== float ImPlus::FromScreenRight(float offset) { @@ -185,7 +185,7 @@ void ImPlus::AutoArrange(float minItemWidth) ImGui::SameLine(prevItemMin + itemWidth - window.Pos.x); } -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ bool ImPlus::InputString(ImStrv label, std::string& str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* userData) { @@ -203,7 +203,7 @@ bool ImPlus::InputStringMultiline(ImStrv label, std::string& str, ImVec2 size, I return ImGui::InputTextEx(label, ImStrv(), str.data(), int(str.capacity()) + 1, size, flags, detail::input_string_callback, &cbUserData); } -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ bool ImPlus::InputColour(ImStrv label, sq::Vec3F& colour, ImGuiColorEditFlags flags) { @@ -223,7 +223,7 @@ bool ImPlus::InputColour(ImStrv label, sq::Vec4F& colour, ImGuiColorEditFlags fl return changed; } -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ ImPlus::DialogResult ImPlus::DialogConfirmation(ImStrv title, std::string_view message) { @@ -259,7 +259,7 @@ ImPlus::DialogResult ImPlus::DialogConfirmation(ImStrv title, std::string_view m return result; } -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ void ImPlus::HoverTooltipV(bool delay, ImGuiDir dir, fmt::string_view fstr, fmt::format_args args) { @@ -292,7 +292,7 @@ void ImPlus::HoverTooltipV(bool delay, ImGuiDir dir, fmt::string_view fstr, fmt: ImPlus::SetTooltip(text); } -//----------------------------------------------------------------------------// +//------------------------------------------------------------------------------ // These are exact copies of the ImGui versions of these functions, but taking // std::string_views instead of a c format string and va_args. This is to allow diff --git a/source/sqee/app/InputDevices.cpp b/source/sqee/app/InputDevices.cpp index 3e74c3e..04fd8ad 100644 --- a/source/sqee/app/InputDevices.cpp +++ b/source/sqee/app/InputDevices.cpp @@ -11,12 +11,12 @@ using namespace sq; -//============================================================================// +//============================================================================== InputDevices::InputDevices(Window& window) : mGlfwWindow(window.get_glfw_window()) {} -//============================================================================// +//============================================================================== bool InputDevices::is_pressed(Keyboard_Key key) const { @@ -138,7 +138,7 @@ bool InputDevices::is_pressed(Keyboard_Key key) const return bool(glfwGetKey(mGlfwWindow, sqee_to_glfw[int(key)])); } -//============================================================================// +//============================================================================== Vec2I InputDevices::get_cursor_location(bool flipY) const { @@ -185,7 +185,7 @@ Vec2I InputDevices::cursor_to_centre() // return { centre.x - position.x, centre.y - position.y }; } -//============================================================================// +//============================================================================== bool InputDevices::check_gamepad_connected(int port) const { diff --git a/source/sqee/app/Scene.cpp b/source/sqee/app/Scene.cpp index 4cebbdc..87eedd0 100644 --- a/source/sqee/app/Scene.cpp +++ b/source/sqee/app/Scene.cpp @@ -4,11 +4,11 @@ using namespace sq; -//============================================================================// +//============================================================================== Scene::Scene(double tickTime) : mTickTime(tickTime), mAccumulation(tickTime) {} -//============================================================================// +//============================================================================== void Scene::update_and_integrate(double elapsed) { @@ -30,7 +30,7 @@ void Scene::update_and_integrate(double elapsed) integrate(elapsed, float(mAccumulation / mTickTime)); } -//============================================================================// +//============================================================================== void Scene::handle_event(Event) {} diff --git a/source/sqee/app/Window.cpp b/source/sqee/app/Window.cpp index bfb82bf..0f63d54 100644 --- a/source/sqee/app/Window.cpp +++ b/source/sqee/app/Window.cpp @@ -10,7 +10,7 @@ using namespace sq; -//============================================================================// +//============================================================================== VKAPI_ATTR VkBool32 VKAPI_CALL impl_vulkan_debug_callback ( VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, @@ -30,7 +30,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL impl_vulkan_debug_callback ( return VK_FALSE; } -//============================================================================// +//============================================================================== constexpr Keyboard_Key impl_glfw_key_to_sqee(int key) { @@ -163,7 +163,7 @@ constexpr Keyboard_Key impl_glfw_key_to_sqee(int key) } // switch(key) } -//============================================================================// +//============================================================================== constexpr Mouse_Button impl_glfw_mouse_button_to_sqee(int button) { @@ -180,7 +180,7 @@ constexpr Mouse_Button impl_glfw_mouse_button_to_sqee(int button) } // switch(button) } -//============================================================================// +//============================================================================== struct Window::Implementation { @@ -256,7 +256,7 @@ struct Window::Implementation } }; -//============================================================================// +//============================================================================== Window::Window(const char* title, Vec2U size, const char* appName, Vec3U version) { @@ -570,7 +570,7 @@ Window::Window(const char* title, Vec2U size, const char* appName, Vec3U version } } -//============================================================================// +//============================================================================== Window::~Window() { @@ -603,7 +603,7 @@ Window::~Window() glfwTerminate(); } -//============================================================================// +//============================================================================== void Window::set_size_limits(std::optional minimum, std::optional maximum) { @@ -615,7 +615,7 @@ void Window::set_size_limits(std::optional minimum, std::optional glfwSetWindowSizeLimits(mGlfwWindow, signedMin.x, signedMin.y, signedMax.x, signedMax.y); } -//============================================================================// +//============================================================================== void Window::create_swapchain_and_friends() { @@ -666,7 +666,7 @@ void Window::create_swapchain_and_friends() mPendingResize = false; } -//============================================================================// +//============================================================================== void Window::destroy_swapchain_and_friends() { @@ -684,7 +684,7 @@ void Window::destroy_swapchain_and_friends() mSwapchainImageViews.clear(); } -//============================================================================// +//============================================================================== const std::vector& Window::fetch_events() { @@ -709,7 +709,7 @@ const std::vector& Window::fetch_events() return mEventsOld; } -//============================================================================// +//============================================================================== void Window::begin_frame() { @@ -717,7 +717,7 @@ void Window::begin_frame() SQASSERT(waitResult == vk::Result::eSuccess, ""); } -//============================================================================// +//============================================================================== std::tuple Window::acquire_image() { @@ -750,7 +750,7 @@ std::tuple Window::acquire_image() return { mCommandBuffer.front, mSwapchainFramebuffers[mImageIndex] }; } -//============================================================================// +//============================================================================== void Window::submit_present_swap() { @@ -786,7 +786,7 @@ void Window::submit_present_swap() mRenderFinishedFence.swap(); } -//============================================================================// +//============================================================================== void Window::set_title(String title) { @@ -809,7 +809,7 @@ void Window::set_vsync_enabled(bool enabled) mVsyncEnabled = enabled; } -//============================================================================// +//============================================================================== bool Window::has_focus() const { diff --git a/source/sqee/app/WrenPlus.cpp b/source/sqee/app/WrenPlus.cpp index 7cc40fc..692d7ed 100644 --- a/source/sqee/app/WrenPlus.cpp +++ b/source/sqee/app/WrenPlus.cpp @@ -9,7 +9,7 @@ using namespace wren; -//============================================================================// +//============================================================================== WrenPlusVM::WrenPlusVM() { @@ -29,7 +29,7 @@ WrenPlusVM::WrenPlusVM() mWrenVM = wrenNewVM(&config); } -//============================================================================// +//============================================================================== WrenPlusVM::~WrenPlusVM() { @@ -41,7 +41,7 @@ WrenPlusVM::~WrenPlusVM() mWrenVM = nullptr; } -//============================================================================// +//============================================================================== void WrenPlusVM::interpret(const char* module, const char* source) { @@ -103,7 +103,7 @@ void WrenPlusVM::validate_class_handle_cache() assert(mForeignClassHandles[index] != nullptr); // missing class registration for index } -//============================================================================// +//============================================================================== WrenHandle* WrenPlusVM::get_variable(const char* module, const char* variable) { @@ -112,7 +112,7 @@ WrenHandle* WrenPlusVM::get_variable(const char* module, const char* variable) return wrenGetSlotHandle(mWrenVM, 0); } -//============================================================================// +//============================================================================== void WrenPlusVM::impl_write_fn(WrenVM* /*vm*/, const char* text) { @@ -148,7 +148,7 @@ void WrenPlusVM::impl_error_fn(WrenVM* vm, WrenErrorType type, const char* modul } } -//============================================================================// +//============================================================================== WrenForeignClassMethods WrenPlusVM::impl_bind_foreign_class_fn(WrenVM* /*vm*/, const char* /*module*/, const char* /*className*/) { @@ -170,7 +170,7 @@ WrenForeignMethodFn WrenPlusVM::impl_bind_foreign_method_fn(WrenVM* vm, const ch return iter != pvm.mForeignMethods.end() ? iter->second : nullptr; } -//============================================================================// +//============================================================================== WrenLoadModuleResult WrenPlusVM::impl_load_module_fn(WrenVM* vm, const char* module) { @@ -199,7 +199,7 @@ WrenLoadModuleResult WrenPlusVM::impl_load_module_fn(WrenVM* vm, const char* mod return result; } -//============================================================================// +//============================================================================== void WrenPlusVM::impl_register_method(const char* module, const char* className, const char* signature, WrenForeignMethodFn func) { @@ -223,7 +223,7 @@ void WrenPlusVM::impl_cache_handle(const char* module, const char* className, si mForeignClassHandles[index] = wrenGetSlotHandle(mWrenVM, 0); } -//============================================================================// +//============================================================================== void WrenPlusVM::impl_pointer_equality_operator(WrenVM* vm) { @@ -247,7 +247,7 @@ void WrenPlusVM::impl_pointer_inequality_operator(WrenVM* vm) wrenSetSlotBool(vm, 0, true); } -//============================================================================// +//============================================================================== size_t wren::detail::generate_type_index() noexcept { diff --git a/source/sqee/data/BuiltinShaders.cpp b/source/sqee/data/BuiltinShaders.cpp index 5bfb9a4..d69c074 100644 --- a/source/sqee/data/BuiltinShaders.cpp +++ b/source/sqee/data/BuiltinShaders.cpp @@ -2,7 +2,7 @@ // glslc -O --target-env=vulkan1.2 -mfmt=num [shader] -o [shader].spv -//============================================================================// +//============================================================================== const uint32_t sqee_GuiSystemVertSpv[234] = { @@ -67,7 +67,7 @@ const uint32_t sqee_GuiSystemVertSpv[234] = 0x000100fd,0x00010038 }; -//============================================================================// +//============================================================================== const uint32_t sqee_GuiSystemFragSpv[142] = { diff --git a/source/sqee/data/UbuntuMinimal.cpp b/source/sqee/data/UbuntuMinimal.cpp index 1521297..58a6a36 100644 --- a/source/sqee/data/UbuntuMinimal.cpp +++ b/source/sqee/data/UbuntuMinimal.cpp @@ -1,6 +1,6 @@ #include -//============================================================================// +//============================================================================== // File: 'dehinted-subset-Ubuntu.ttf' (37248 bytes) const int32_t sqee_UbuntuRegular_size = 23177; @@ -491,7 +491,7 @@ const uint32_t sqee_UbuntuRegular[23180/4] = 0x0382665f, 0x03826920, 0x82056c21, 0x695f210b, 0x6c2f0584, 0x6c2e6906, 0x006c636f, 0xff010001, 0x050f00ff, 0xbd8f7ffa, 0x000000d5, }; -//============================================================================// +//============================================================================== // File: 'dehinted-subset-Ubuntu-Bold.ttf' (38984 bytes) const int32_t sqee_UbuntuBold_size = 23576; @@ -991,7 +991,7 @@ const uint32_t sqee_UbuntuBold[23576/4] = 0xfa050f00, 0xe52bc99f, }; -//============================================================================// +//============================================================================== // File: 'dehinted-subset-Ubuntu-Italic.ttf' (37840 bytes) const int32_t sqee_UbuntuItalic_size = 23368; @@ -1486,7 +1486,7 @@ const uint32_t sqee_UbuntuItalic[23368/4] = 0x20038266, 0x21038269, 0x0b82056c, 0x84695f21, 0x066c2f05, 0x6f6c2e69, 0x01006c63, 0xffff0100, 0xfa050f00, 0x3c41a5ae, }; -//============================================================================// +//============================================================================== // File: 'dehinted-subset-UbuntuMono-Regular.ttf' (24952 bytes) const int32_t sqee_UbuntuMonoRegular_size = 18415; diff --git a/source/sqee/data/VolumeMeshes.cpp b/source/sqee/data/VolumeMeshes.cpp index e0c6897..06a4aa9 100644 --- a/source/sqee/data/VolumeMeshes.cpp +++ b/source/sqee/data/VolumeMeshes.cpp @@ -1,6 +1,6 @@ #include -//============================================================================// +//============================================================================== const float sqee_ConeVertices[26*3] = { @@ -25,7 +25,7 @@ const uint8_t sqee_ConeIndices[48*3] = 0, 22, 23, 22, 3, 23, 0, 23, 24, 23, 3, 24, 0, 24, 25, 24, 3, 25, 0, 25, 1, 25, 3, 1 }; -//============================================================================// +//============================================================================== const float sqee_SphereVertices[42*3] = { @@ -59,7 +59,7 @@ const uint8_t sqee_SphereIndices[80*3] = 5, 2, 13, 2, 9, 13, 4, 7, 18, 4, 1, 7, 1, 0, 7, 2, 10, 9, 2, 1, 10, 1, 3, 10 }; -//============================================================================// +//============================================================================== const float sqee_CubeVertices[8*3] = { diff --git a/source/sqee/debug/Logging.cpp b/source/sqee/debug/Logging.cpp index 269cc02..617af5c 100644 --- a/source/sqee/debug/Logging.cpp +++ b/source/sqee/debug/Logging.cpp @@ -8,7 +8,7 @@ using namespace sq; -//============================================================================// +//============================================================================== inline void impl_append_time_and_category(std::string_view category, fmt::memory_buffer& buffer) { @@ -39,7 +39,7 @@ inline void impl_write_multiline(const fmt::memory_buffer& buffer, FILE* file) } } -//============================================================================// +//============================================================================== void sq::detail::log(std::string_view category, std::string_view str) { @@ -67,7 +67,7 @@ void sq::detail::log_multiline(std::string_view category, std::string_view str) std::fflush(stdout); } -//============================================================================// +//============================================================================== void sq::detail::log(std::string_view category, fmt::string_view fstr, fmt::format_args args) { diff --git a/source/sqee/misc/Files.cpp b/source/sqee/misc/Files.cpp index 2309b97..0b4fff0 100644 --- a/source/sqee/misc/Files.cpp +++ b/source/sqee/misc/Files.cpp @@ -2,7 +2,7 @@ using namespace sq; -//============================================================================// +//============================================================================== String sq::read_text_from_file(const String& path) { @@ -22,7 +22,7 @@ String sq::read_text_from_file(const String& path) return String(buffer.data(), stringSize); } -//============================================================================// +//============================================================================== std::vector sq::read_bytes_from_file(const String& path) { @@ -42,7 +42,7 @@ std::vector sq::read_bytes_from_file(const String& path) return buffer; } -//============================================================================// +//============================================================================== std::optional sq::try_read_text_from_file(const String& path) { @@ -62,7 +62,7 @@ std::optional sq::try_read_text_from_file(const String& path) return String(buffer.data(), stringSize); } -//============================================================================// +//============================================================================== std::optional> sq::try_read_bytes_from_file(const String& path) { @@ -82,7 +82,7 @@ std::optional> sq::try_read_bytes_from_file(const String& return buffer; } -//============================================================================// +//============================================================================== void sq::write_text_to_file(const String& path, StringView text, bool endNewLine) { @@ -99,7 +99,7 @@ void sq::write_text_to_file(const String& path, StringView text, bool endNewLine std::fclose(file); } -//============================================================================// +//============================================================================== void sq::write_bytes_to_file(const String& path, const void* bytes, size_t size) { @@ -112,14 +112,14 @@ void sq::write_bytes_to_file(const String& path, const void* bytes, size_t size) std::fclose(file); } -//============================================================================// +//============================================================================== TokenisedFile TokenisedFile::from_file(const String& path) { return from_string(read_text_from_file(path)); } -//============================================================================// +//============================================================================== TokenisedFile TokenisedFile::from_string(String&& text) { diff --git a/source/sqee/misc/Parsing.cpp b/source/sqee/misc/Parsing.cpp index c0ea047..3662246 100644 --- a/source/sqee/misc/Parsing.cpp +++ b/source/sqee/misc/Parsing.cpp @@ -4,7 +4,7 @@ using namespace sq; -//============================================================================// +//============================================================================== std::vector sq::tokenise_string(StringView sv, char dlm) { @@ -23,7 +23,7 @@ std::vector sq::tokenise_string(StringView sv, char dlm) return result; } -//============================================================================// +//============================================================================== void sq::tokenise_string(StringView sv, char dlm, std::vector& out) { @@ -40,7 +40,7 @@ void sq::tokenise_string(StringView sv, char dlm, std::vector& out) } } -//============================================================================// +//============================================================================== std::vector sq::tokenise_string_lines(StringView sv) { diff --git a/source/sqee/objects/Armature.cpp b/source/sqee/objects/Armature.cpp index 27d380e..12a2453 100644 --- a/source/sqee/objects/Armature.cpp +++ b/source/sqee/objects/Armature.cpp @@ -23,7 +23,7 @@ using namespace sq; thread_local std::vector gTempMats; -//============================================================================// +//============================================================================== void Armature::load_from_file(const String& path) { @@ -47,7 +47,7 @@ void Armature::load_from_file(const String& path) uint32_t dataOffset = 0u; - //--------------------------------------------------------// + //---------------------------------------------------------- for (const auto [boneIndex, jBone] : jBones | views::json_as) { @@ -106,7 +106,7 @@ void Armature::load_from_file(const String& path) mInverseMats.emplace_back(maths::affine_inverse(mBaseMats.back())); } - //--------------------------------------------------------// + //---------------------------------------------------------- for (const auto [blockName, jBlock] : jBlocks | views::json_as) { @@ -186,7 +186,7 @@ void Armature::load_from_file(const String& path) } } - //--------------------------------------------------------// + //---------------------------------------------------------- mTrackNames.shrink_to_fit(); mTrackInfos.shrink_to_fit(); @@ -195,7 +195,7 @@ void Armature::load_from_file(const String& path) SQEE_THROW("animSampleSize does not match tracks"); } -//============================================================================// +//============================================================================== int8_t Armature::get_bone_index(TinyString name) const noexcept { @@ -236,7 +236,7 @@ JsonMutAny Armature::json_from_bone_index(JsonMutDocument& document, int8_t inde return JsonMutAny(document, nullptr); } -//============================================================================// +//============================================================================== Animation Armature::load_animation_from_file(const String& path) const { @@ -249,7 +249,7 @@ Animation Armature::load_animation_from_file(const String& path) const else SQEE_THROW("could not find animation '{}'", path); } -//============================================================================// +//============================================================================== Animation Armature::impl_load_animation_text(String&& text) const { @@ -264,7 +264,7 @@ Animation Armature::impl_load_animation_text(String&& text) const std::byte* bytePtr = nullptr; - //--------------------------------------------------------// + //---------------------------------------------------------- const auto assert_num_tokens = [](const std::vector& tokens, size_t lineNum, size_t expected) { @@ -416,7 +416,7 @@ Animation Armature::impl_load_animation_text(String&& text) const } SQEE_UNREACHABLE(); }; - //--------------------------------------------------------// + //---------------------------------------------------------- for (const auto& [tokens, lineNum] : TokenisedFile::from_string(std::move(text)).lines) { @@ -488,12 +488,12 @@ Animation Armature::impl_load_animation_text(String&& text) const else SQEE_THROW("missing SECTION"); } - //--------------------------------------------------------// + //---------------------------------------------------------- return result; } -//============================================================================// +//============================================================================== Animation Armature::make_null_animation(uint frameCount) const { @@ -526,7 +526,7 @@ Animation Armature::make_null_animation(uint frameCount) const return result; } -//============================================================================// +//============================================================================== void Armature::compute_sample(const Animation& animation, float time, AnimSample& out) const { @@ -701,7 +701,7 @@ void Armature::blend_samples(const AnimSample& a, const AnimSample& b, float fac } } -//============================================================================// +//============================================================================== Mat4F Armature::compute_bone_matrix(const AnimSample& sample, uint8_t index) const { @@ -722,7 +722,7 @@ Mat4F Armature::compute_bone_matrix(const AnimSample& sample, uint8_t index) con return result; } -//============================================================================// +//============================================================================== std::vector Armature::compute_bone_matrices(const AnimSample& sample) const { @@ -747,7 +747,7 @@ std::vector Armature::compute_bone_matrices(const AnimSample& sample) con return result; } -//============================================================================// +//============================================================================== Mat4F Armature::compute_model_matrix(const AnimSample& sample, Mat4F modelMatrix, uint8_t index) const { @@ -771,7 +771,7 @@ Mat4F Armature::compute_model_matrix(const AnimSample& sample, Mat4F modelMatrix return modelMatrix * result * mInverseMats[index]; } -//============================================================================// +//============================================================================== void Armature::compute_model_matrices ( const AnimSample& sample, Mat4F viewMatrix, Mat4F invViewMatrix, Mat4F modelMatrix, Vec2F billboardScale, Mat34F* modelMats, size_t len @@ -807,7 +807,7 @@ void Armature::compute_model_matrices ( } } -//============================================================================// +//============================================================================== Animation::SampleTime Animation::compute_sample_time(float time) const { diff --git a/source/sqee/objects/DrawItem.cpp b/source/sqee/objects/DrawItem.cpp index 98aad13..abe6763 100644 --- a/source/sqee/objects/DrawItem.cpp +++ b/source/sqee/objects/DrawItem.cpp @@ -12,7 +12,7 @@ using namespace sq; -//============================================================================// +//============================================================================== std::vector DrawItem::load_from_json(const String& path, const Armature& armature, MeshCache& meshes, PipelineCache& pipelines, TextureCache& textures) { @@ -56,7 +56,7 @@ std::vector DrawItem::load_from_json(const String& path, const Armatur const auto jsonMeshes = jsonAssets["meshes"].as(); const auto jsonPipelines = jsonAssets["pipelines"].as(); - //--------------------------------------------------------// + //---------------------------------------------------------- const auto jsonItems = json["items"].as(); @@ -254,7 +254,7 @@ std::vector DrawItem::load_from_json(const String& path, const Armatur return result; } -//============================================================================// +//============================================================================== bool DrawItem::check_visibility(const AnimSample& sample) const { @@ -272,7 +272,7 @@ bool DrawItem::check_visibility(const AnimSample& sample) const } SQEE_UNREACHABLE(); } -//============================================================================// +//============================================================================== void DrawItem::compute_push_constants(const AnimSample& sample, uint modelMatsIndex, uint normalMatsIndex, std::array& out) const { diff --git a/source/sqee/objects/Mesh.cpp b/source/sqee/objects/Mesh.cpp index c9de754..4773526 100644 --- a/source/sqee/objects/Mesh.cpp +++ b/source/sqee/objects/Mesh.cpp @@ -10,7 +10,7 @@ using namespace sq; -//============================================================================// +//============================================================================== inline void impl_ascii_append_normal(std::byte*& ptr, StringView svx, StringView svy, StringView svz, StringView svw) { @@ -46,7 +46,7 @@ inline void impl_ascii_append_int8(std::byte*& ptr, StringView sv) ptr += sizeof(int8_t); } -//============================================================================// +//============================================================================== Mesh::Mesh(Mesh&& other) { @@ -74,7 +74,7 @@ Mesh::~Mesh() mIndexBuffer.destroy(ctx); } -//============================================================================// +//============================================================================== void Mesh::load_from_file(const String& path) { @@ -89,7 +89,7 @@ void Mesh::load_from_file(const String& path) else SQEE_THROW("could not find mesh '{}'", path); } -//============================================================================// +//============================================================================== int8_t Mesh::get_sub_mesh_index(TinyString name) const noexcept { @@ -106,7 +106,7 @@ int8_t Mesh::json_as_sub_mesh_index(JsonAny json) const json.throw_with_context("invalid sub mesh name"); } -//============================================================================// +//============================================================================== void Mesh::bind_buffers(vk::CommandBuffer cmdbuf) const { @@ -125,7 +125,7 @@ void Mesh::draw(vk::CommandBuffer cmdbuf, int8_t subMesh) const else cmdbuf.drawIndexed(mIndexTotal, 1u, 0u, 0, 0u); } -//============================================================================// +//============================================================================== void Mesh::impl_load_text(String&& text) { @@ -142,7 +142,7 @@ void Mesh::impl_load_text(String&& text) mVertexSize = sizeof(float[3]); size_t numValuesPerVertex = 3u; - //--------------------------------------------------------// + //---------------------------------------------------------- for (const auto& [line, num] : TokenisedFile::from_string(std::move(text)).lines) { @@ -306,7 +306,7 @@ void Mesh::impl_load_text(String&& text) else SQEE_THROW("missing SECTION"); } - //--------------------------------------------------------// + //---------------------------------------------------------- SQASSERT(vertexPtr == vertexData.data() + vertexData.size(), "not enough vertices"); SQASSERT(indexPtr == indexData.data() + indexData.size(), "not enough indices"); @@ -314,7 +314,7 @@ void Mesh::impl_load_text(String&& text) impl_load_final(vertexData, indexData); } -//============================================================================// +//============================================================================== void Mesh::impl_load_final(std::vector& vertexData, std::vector& indexData) { @@ -337,7 +337,7 @@ void Mesh::impl_load_final(std::vector& vertexData, std::vector flags, vk::Flags ignored) { diff --git a/source/sqee/objects/Pipeline.cpp b/source/sqee/objects/Pipeline.cpp index d8f3839..66199f9 100644 --- a/source/sqee/objects/Pipeline.cpp +++ b/source/sqee/objects/Pipeline.cpp @@ -13,7 +13,7 @@ using namespace sq; namespace cross = spirv_cross; -//============================================================================// +//============================================================================== inline vk::PipelineRasterizationStateCreateInfo impl_make_rasterization_state(JsonAny jCullFace) { @@ -103,7 +103,7 @@ inline vk::PipelineColorBlendAttachmentState impl_make_color_blend_state(JsonAny jBlendMode.throw_with_context("invalid colour blend mode"); } -//============================================================================// +//============================================================================== Pipeline::Pipeline(Pipeline&& other) { @@ -124,7 +124,7 @@ Pipeline::~Pipeline() if (mPipeline) ctx.device.destroy(mPipeline); } -//============================================================================// +//============================================================================== // todo: remove asserts relating to shaders, to support live editing @@ -135,7 +135,7 @@ void Pipeline::load_from_minified_json(const String& minified, const PassConfigM const auto document = JsonDocument::parse_string(minified, "Pipeline"); const auto json = document.root().as(); - //--------------------------------------------------------// + //---------------------------------------------------------- // because the minified json is used as a resource key, pipeline json must be in a consistent order // we ensure this by iterating through the object instead of doing lookups @@ -150,7 +150,7 @@ void Pipeline::load_from_minified_json(const String& minified, const PassConfigM return value; }; - //--------------------------------------------------------// + //---------------------------------------------------------- // Note that we always reflect push constants, so that we can create DrawItems for a // pass even if the pass is disabled. The offsets won't ever change, so DrawItems don't @@ -242,7 +242,7 @@ void Pipeline::load_from_minified_json(const String& minified, const PassConfigM reflect_shader(*vertexShaderCode, false); reflect_shader(*fragmentShaderCode, true); - //--------------------------------------------------------// + //---------------------------------------------------------- const auto jPass = next_element("pass"); @@ -254,7 +254,7 @@ void Pipeline::load_from_minified_json(const String& minified, const PassConfigM // if the pass is disabled, then we only need to do reflection if (check_pass_enabled() == false) return; - //--------------------------------------------------------// + //---------------------------------------------------------- const auto jAttributes = next_element("attributes"); @@ -286,7 +286,7 @@ void Pipeline::load_from_minified_json(const String& minified, const PassConfigM const auto vertexConfig = Mesh::VertexConfig(attributes, ignoredAttributes); - //--------------------------------------------------------// + //---------------------------------------------------------- const auto jCullFace = next_element("cullFace"); const auto jAlphaCoverage = next_element("alphaCoverage"); @@ -300,7 +300,7 @@ void Pipeline::load_from_minified_json(const String& minified, const PassConfigM for (const auto [_, jBlendMode] : jBlendModes) colourBlendAttachments.emplace_back(impl_make_color_blend_state(jBlendMode)); - //--------------------------------------------------------// + //---------------------------------------------------------- const auto& ctx = VulkanContext::get(); @@ -315,7 +315,7 @@ void Pipeline::load_from_minified_json(const String& minified, const PassConfigM &specialisation.info ); - //--------------------------------------------------------// + //---------------------------------------------------------- if (jsonRootIter != json.end()) jsonRootIter->second.throw_with_context("unrecognised extra key"); @@ -331,7 +331,7 @@ void Pipeline::load_from_minified_json(const String& minified, const PassConfigM ); } -//============================================================================// +//============================================================================== void Pipeline::bind(vk::CommandBuffer cmdbuf) const { diff --git a/source/sqee/objects/Sound.cpp b/source/sqee/objects/Sound.cpp index 9a16001..0ff651b 100644 --- a/source/sqee/objects/Sound.cpp +++ b/source/sqee/objects/Sound.cpp @@ -8,7 +8,7 @@ using namespace sq; -//============================================================================// +//============================================================================== Sound::Sound(AudioContext& context) : mContext(&context) {} @@ -30,7 +30,7 @@ Sound::~Sound() mContext->impl_destroy_sound(*this); } -//============================================================================// +//============================================================================== void Sound::load_from_file(const String& path) { diff --git a/source/sqee/objects/Texture.cpp b/source/sqee/objects/Texture.cpp index ba776c4..8552189 100644 --- a/source/sqee/objects/Texture.cpp +++ b/source/sqee/objects/Texture.cpp @@ -13,7 +13,7 @@ using namespace sq; -//============================================================================// +//============================================================================== static vk::Format impl_json_to_format(JsonAny json) { @@ -103,7 +103,7 @@ static Texture::MipmapsMode impl_json_to_mipmaps(JsonAny json) json.throw_with_context("invalid mipmaps mode"); } -//============================================================================// +//============================================================================== static auto impl_get_format_info(vk::Format format) { @@ -130,7 +130,7 @@ static auto impl_get_format_info(vk::Format format) SQEE_THROW("invalid format '{}'", vk::to_string(format)); } -//============================================================================// +//============================================================================== static auto impl_load_image(vk::Format format, const String& path) { @@ -198,7 +198,7 @@ static auto impl_load_image(vk::Format format, const String& path) } } -//============================================================================// +//============================================================================== static vk::Sampler impl_create_sampler(const VulkanContext& ctx, const Texture::Config& config) { @@ -212,7 +212,7 @@ static vk::Sampler impl_create_sampler(const VulkanContext& ctx, const Texture:: ); } -//============================================================================// +//============================================================================== Texture::Texture(Texture&& other) { @@ -235,7 +235,7 @@ Texture::~Texture() ctx.device.destroy(mSampler); } -//============================================================================// +//============================================================================== void Texture::initialise_2D(const Config& config) { @@ -252,7 +252,7 @@ void Texture::initialise_2D(const Config& config) mSampler = impl_create_sampler(ctx, config); } -//============================================================================// +//============================================================================== void Texture::load_from_file_2D(const String& path) { @@ -292,7 +292,7 @@ void Texture::load_from_file_2D(const String& path) load_from_memory(image.data, image.length, 0u, 0u, config); } -//============================================================================// +//============================================================================== void Texture::initialise_array(const Config& config) { @@ -309,7 +309,7 @@ void Texture::initialise_array(const Config& config) mSampler = impl_create_sampler(ctx, config); } -//============================================================================// +//============================================================================== void Texture::load_from_file_array(const String& path) { @@ -355,7 +355,7 @@ void Texture::load_from_file_array(const String& path) } } -//============================================================================// +//============================================================================== void Texture::initialise_cube(const Config& config) { @@ -372,7 +372,7 @@ void Texture::initialise_cube(const Config& config) mSampler = impl_create_sampler(ctx, config); } -//============================================================================// +//============================================================================== void Texture::load_from_file_cube(const String& path) { @@ -418,7 +418,7 @@ void Texture::load_from_file_cube(const String& path) } } -//============================================================================// +//============================================================================== void Texture::load_from_memory(const void* data, size_t length, uint level, uint layer, const Config& config) { @@ -468,7 +468,7 @@ void Texture::load_from_memory(const void* data, size_t length, uint level, uint return; // no mipmap generation } - //--------------------------------------------------------// + //---------------------------------------------------------- Vec2I sourceSize = Vec2I(config.size.x, config.size.y); @@ -515,7 +515,7 @@ void Texture::load_from_memory(const void* data, size_t length, uint level, uint ); } -//============================================================================// +//============================================================================== void Texture::load_from_memory(const void* data, size_t length, const Config& config) { @@ -569,7 +569,7 @@ void Texture::load_from_memory(const void* data, size_t length, const Config& co ); } -//============================================================================// +//============================================================================== bool Texture::try_load_from_compressed(const String& path, const Config& config) { @@ -607,7 +607,7 @@ bool Texture::try_load_from_compressed(const String& path, const Config& config) return true; } -//============================================================================// +//============================================================================== void Texture::save_as_compressed(const String& path, vk::Format format, Vec3U size, uint mipLevels) const { @@ -674,7 +674,7 @@ void Texture::save_as_compressed(const String& path, vk::Format format, Vec3U si } } -//============================================================================// +//============================================================================== size_t Texture::compute_buffer_size(Vec3U size, uint mipLevels, size_t pixelSize) { @@ -690,7 +690,7 @@ size_t Texture::compute_buffer_size(Vec3U size, uint mipLevels, size_t pixelSize return bufferTotalSize; } -//============================================================================// +//============================================================================== void Texture::add_to_bindless_descriptor_set(vk::DescriptorSet descriptorSet, uint32_t index) { diff --git a/source/sqee/vk/Helpers.cpp b/source/sqee/vk/Helpers.cpp index 119ceda..a2bf077 100644 --- a/source/sqee/vk/Helpers.cpp +++ b/source/sqee/vk/Helpers.cpp @@ -4,7 +4,7 @@ using namespace sq; -//============================================================================// +//============================================================================== StagingBuffer::StagingBuffer(const VulkanContext& _ctx, bool source, bool destination, size_t size) : ctx(_ctx) @@ -28,7 +28,7 @@ StagingBuffer::~StagingBuffer() memory.free(); } -//============================================================================// +//============================================================================== OneTimeCommands::OneTimeCommands(const VulkanContext& _ctx) : ctx(_ctx) @@ -56,7 +56,7 @@ OneTimeCommands::~OneTimeCommands() ctx.device.free(ctx.commandPool, cmdbuf); } -//============================================================================// +//============================================================================== ShaderModules::ShaderModules(const VulkanContext& _ctx, const String& vertex, const String& geometry, const String& fragment, const vk::SpecializationInfo* specialisation) : ctx(_ctx) @@ -112,7 +112,7 @@ ShaderModules::~ShaderModules() ctx.device.destroy(module); } -//============================================================================// +//============================================================================== vk::Pipeline sq::vk_create_graphics_pipeline(const VulkanContext& ctx, vk::PipelineLayout layout, vk::RenderPass renderPass, uint32_t subpass, ArrayProxyRef stages, const vk::PipelineVertexInputStateCreateInfo& vertexInputState, const vk::PipelineInputAssemblyStateCreateInfo& inputAssemblyState, const vk::PipelineRasterizationStateCreateInfo& rasterizationState, const vk::PipelineMultisampleStateCreateInfo& multisampleState, const vk::PipelineDepthStencilStateCreateInfo& depthStencilState, ArrayProxyRef viewports, ArrayProxyRef scissors, ArrayProxyRef colorBlendAttachments, ArrayProxyRef dynamicStates) { @@ -143,7 +143,7 @@ vk::Pipeline sq::vk_create_graphics_pipeline(const VulkanContext& ctx, vk::Pipel return result.value; } -//============================================================================// +//============================================================================== vk::DescriptorSet sq::vk_allocate_descriptor_set(const VulkanContext& ctx, vk::DescriptorSetLayout layout) { diff --git a/source/sqee/vk/SwapBuffer.cpp b/source/sqee/vk/SwapBuffer.cpp index 611ec0d..bdfc10c 100644 --- a/source/sqee/vk/SwapBuffer.cpp +++ b/source/sqee/vk/SwapBuffer.cpp @@ -6,7 +6,7 @@ using namespace sq; -//============================================================================// +//============================================================================== SwapBuffer::SwapBuffer(SwapBuffer&& other) { @@ -29,7 +29,7 @@ SwapBuffer::~SwapBuffer() mStuff.back.destroy(ctx); } -//============================================================================// +//============================================================================== void SwapBuffer::initialise(size_t size, vk::BufferUsageFlags usage) { diff --git a/source/sqee/vk/VulkanContext.cpp b/source/sqee/vk/VulkanContext.cpp index 9f710ae..ebf6bdf 100644 --- a/source/sqee/vk/VulkanContext.cpp +++ b/source/sqee/vk/VulkanContext.cpp @@ -4,13 +4,13 @@ using namespace sq; -//============================================================================// +//============================================================================== static VulkanContext* gContextPtr = nullptr; const VulkanContext& VulkanContext::get() { return *gContextPtr; } -//============================================================================// +//============================================================================== VulkanContext::VulkanContext(VulkanAllocator& _allocator) : allocator(_allocator) {} @@ -29,7 +29,7 @@ void VulkanContext::destruct() VulkanContext& VulkanContext::get_mutable() { return *gContextPtr; } -//============================================================================// +//============================================================================== vk::DescriptorSet VulkanContext::allocate_descriptor_set(vk::DescriptorPool pool, vk::DescriptorSetLayout layout) const { diff --git a/source/sqee/vk/VulkanMemory.cpp b/source/sqee/vk/VulkanMemory.cpp index 56d2955..633ecc2 100644 --- a/source/sqee/vk/VulkanMemory.cpp +++ b/source/sqee/vk/VulkanMemory.cpp @@ -15,14 +15,14 @@ using namespace sq; -//============================================================================// +//============================================================================== inline size_t impl_round_up(size_t size, size_t alignment) { return ((size + alignment - 1u) / alignment) * alignment; } -//============================================================================// +//============================================================================== void VulkanAllocator::initialise(vk::Device device, uint32_t memTypeHost, uint32_t memTypeDevice, size_t maxItems) { @@ -59,7 +59,7 @@ void VulkanAllocator::destroy() } } -//============================================================================// +//============================================================================== VulkanMemory VulkanAllocator::allocate(size_t alignment, size_t size, bool host) { @@ -131,7 +131,7 @@ VulkanMemory VulkanAllocator::allocate(const vk::MemoryRequirements& requirement return allocate(requirements.alignment, requirements.size, host); } -//============================================================================// +//============================================================================== void VulkanAllocator::free_empty_blocks() { @@ -159,7 +159,7 @@ size_t VulkanAllocator::get_memory_usage(bool host) const return result; } -//============================================================================// +//============================================================================== VulkanAllocator::Chunk* VulkanAllocator::impl_find_usable_chunk(size_t size, Chunk& chunk) { @@ -201,7 +201,7 @@ void VulkanAllocator::impl_delete_chunk(Chunk* ptr) } } -//============================================================================// +//============================================================================== std::byte* VulkanMemory::map() { @@ -235,7 +235,7 @@ void VulkanMemory::unmap() chunk->mapped = false; } -//============================================================================// +//============================================================================== void VulkanMemory::free() { diff --git a/source/sqee/vk/Wrappers.cpp b/source/sqee/vk/Wrappers.cpp index 5d342cd..5252bf6 100644 --- a/source/sqee/vk/Wrappers.cpp +++ b/source/sqee/vk/Wrappers.cpp @@ -5,7 +5,7 @@ using namespace sq; -//============================================================================// +//============================================================================== void BufferStuff::initialise(const VulkanContext& ctx, size_t size, vk::BufferUsageFlags usage, bool host) { @@ -19,7 +19,7 @@ void BufferStuff::initialise(const VulkanContext& ctx, size_t size, vk::BufferUs ctx.device.bindBufferMemory(buffer, memory.get_memory(), memory.get_offset()); } -//============================================================================// +//============================================================================== void ImageStuff::initialise_2D(const VulkanContext& ctx, vk::Format format, Vec2U size, uint mipLevels, vk::SampleCountFlagBits samples, vk::ImageUsageFlags usage, bool host, vk::ComponentMapping swizzle, vk::ImageAspectFlags aspect) { @@ -40,7 +40,7 @@ void ImageStuff::initialise_2D(const VulkanContext& ctx, vk::Format format, Vec2 ); } -//============================================================================// +//============================================================================== void ImageStuff::initialise_array(const VulkanContext& ctx, vk::Format format, Vec3U size, uint mipLevels, vk::SampleCountFlagBits samples, vk::ImageUsageFlags usage, bool host, vk::ComponentMapping swizzle, vk::ImageAspectFlags aspect) { @@ -61,7 +61,7 @@ void ImageStuff::initialise_array(const VulkanContext& ctx, vk::Format format, V ); } -//============================================================================// +//============================================================================== void ImageStuff::initialise_cube(const VulkanContext& ctx, vk::Format format, uint size, uint mipLevels, vk::SampleCountFlagBits samples, vk::ImageUsageFlags usage, bool host, vk::ComponentMapping swizzle, vk::ImageAspectFlags aspect) { @@ -82,7 +82,7 @@ void ImageStuff::initialise_cube(const VulkanContext& ctx, vk::Format format, ui ); } -//============================================================================// +//============================================================================== void RenderPassStuff::initialise(const VulkanContext& ctx, ArrayProxyRef attachments, ArrayProxyRef subpasses, ArrayProxyRef dependencies, Vec2U imageSize, uint layers, ArrayProxyRef imageViews) { @@ -99,7 +99,7 @@ void RenderPassStuff::initialise(const VulkanContext& ctx, ArrayProxyRef& arg) } // namespace sq::maths -//============================================================================// +//============================================================================== template class WithinAbsMatcher_Vector final : public MatcherBase> @@ -127,7 +127,7 @@ class WithinAbsMatcher_Quaternion final : public MatcherBase m_target; T m_margin; }; -//============================================================================// +//============================================================================== constexpr double DEFAULT_MARGIN = 0.000001; diff --git a/tests/vkdemo/src/DemoApp.cpp b/tests/vkdemo/src/DemoApp.cpp index 7ed4480..bc64b01 100644 --- a/tests/vkdemo/src/DemoApp.cpp +++ b/tests/vkdemo/src/DemoApp.cpp @@ -13,7 +13,7 @@ using namespace demo; -//============================================================================// +//============================================================================== void DemoApp::initialise(std::vector /*args*/) { @@ -44,7 +44,7 @@ void DemoApp::initialise(std::vector /*args*/) initialise_models(); } -//============================================================================// +//============================================================================== DemoApp::~DemoApp() { @@ -65,7 +65,7 @@ DemoApp::~DemoApp() destroy_pipelines(); } -//============================================================================// +//============================================================================== void DemoApp::update(double elapsed) { @@ -93,7 +93,7 @@ void DemoApp::update(double elapsed) } } -//============================================================================// +//============================================================================== void DemoApp::handle_event(sq::Event event) { @@ -120,7 +120,7 @@ void DemoApp::handle_event(sq::Event event) } } -//============================================================================// +//============================================================================== void DemoApp::refresh_graphics_config() { @@ -143,7 +143,7 @@ void DemoApp::refresh_graphics_config() float(ctx.allocator.get_memory_usage(false)) / 1048576.f); } -//============================================================================// +//============================================================================== void DemoApp::initialise_layouts() { @@ -184,7 +184,7 @@ void DemoApp::initialise_layouts() } } -//============================================================================// +//============================================================================== void DemoApp::initialise_camera() { @@ -204,7 +204,7 @@ void DemoApp::initialise_camera() ); } -//============================================================================// +//============================================================================== void DemoApp::initialise_models() { @@ -220,7 +220,7 @@ void DemoApp::initialise_models() } } -//============================================================================// +//============================================================================== void DemoApp::create_render_targets() { @@ -322,7 +322,7 @@ void DemoApp::create_render_targets() }; } -//============================================================================// +//============================================================================== void DemoApp::destroy_render_targets() { @@ -336,7 +336,7 @@ void DemoApp::destroy_render_targets() mMsRenderPass.destroy(ctx); } -//============================================================================// +//============================================================================== void DemoApp::create_pipelines() { @@ -376,7 +376,7 @@ void DemoApp::create_pipelines() } } -//============================================================================// +//============================================================================== void DemoApp::destroy_pipelines() { @@ -385,7 +385,7 @@ void DemoApp::destroy_pipelines() ctx.device.destroy(mCompositePipeline); } -//============================================================================// +//============================================================================== void DemoApp::update_window_title(double elapsed) { @@ -402,7 +402,7 @@ void DemoApp::update_window_title(double elapsed) } } -//============================================================================// +//============================================================================== void DemoApp::update_uniform_buffer(double elapsed) { @@ -459,7 +459,7 @@ void DemoApp::update_uniform_buffer(double elapsed) } } -//============================================================================// +//============================================================================== void DemoApp::populate_command_buffer(vk::CommandBuffer cmdbuf, vk::Framebuffer framebuf) { diff --git a/tests/vkdemo/src/DemoApp.hpp b/tests/vkdemo/src/DemoApp.hpp index f1dba25..ebccd93 100644 --- a/tests/vkdemo/src/DemoApp.hpp +++ b/tests/vkdemo/src/DemoApp.hpp @@ -15,29 +15,27 @@ #include -namespace demo { - -//============================================================================// +namespace demo { //############################################################# class DemoApp : public sq::Application { -public: //====================================================// +public: //====================================================== ~DemoApp() override; -private: //===================================================// +private: //===================================================== void initialise(std::vector args) override; void update(double elapsed) override; - //--------------------------------------------------------// + //---------------------------------------------------------- void handle_event(sq::Event event); void refresh_graphics_config(); - //--------------------------------------------------------// + //---------------------------------------------------------- void initialise_layouts(); @@ -45,7 +43,7 @@ class DemoApp : public sq::Application void initialise_models(); - //--------------------------------------------------------// + //---------------------------------------------------------- void create_render_targets(); @@ -55,7 +53,7 @@ class DemoApp : public sq::Application void destroy_pipelines(); - //--------------------------------------------------------// + //---------------------------------------------------------- void update_window_title(double elapsed); @@ -63,7 +61,7 @@ class DemoApp : public sq::Application void populate_command_buffer(vk::CommandBuffer cmdbuf, vk::Framebuffer framebuf); - //--------------------------------------------------------// + //---------------------------------------------------------- vk::SampleCountFlagBits mMultisampleMode = vk::SampleCountFlagBits::e4; @@ -73,7 +71,7 @@ class DemoApp : public sq::Application std::unique_ptr mCaches; - //--------------------------------------------------------// + //---------------------------------------------------------- vk::DescriptorSetLayout mModelDescriptorSetLayout; vk::PipelineLayout mModelPipelineLayout; @@ -86,7 +84,7 @@ class DemoApp : public sq::Application sq::PassConfig* mPassConfigOpaque = nullptr; - //--------------------------------------------------------// + //---------------------------------------------------------- sq::SwapBuffer mCameraUbo; sq::SwapBuffer mLightUbo; @@ -107,14 +105,14 @@ class DemoApp : public sq::Application std::vector mStaticModels; - //--------------------------------------------------------// + //---------------------------------------------------------- sq::ImageStuff mMsColourImage; sq::ImageStuff mResolveColourImage; vk::Sampler mResolveColourSampler; sq::RenderPassStuff mMsRenderPass; - //--------------------------------------------------------// + //---------------------------------------------------------- vk::Pipeline mCompositePipeline; @@ -122,6 +120,4 @@ class DemoApp : public sq::Application uint mFramesAccum = 0u; }; -//============================================================================// - -} // namespace sqt +} // namespace demo ############################################################ diff --git a/tests/vkdemo/src/Resources.cpp b/tests/vkdemo/src/Resources.cpp index a27538a..5c19dc2 100644 --- a/tests/vkdemo/src/Resources.cpp +++ b/tests/vkdemo/src/Resources.cpp @@ -7,7 +7,7 @@ using namespace demo; -//============================================================================// +//============================================================================== ResourceCaches::ResourceCaches() { @@ -20,7 +20,7 @@ ResourceCaches::ResourceCaches() bindlessTextureSet = ctx.allocate_descriptor_set(ctx.descriptorPool, bindlessTextureSetLayout); - //-- Assign Factory Functions ----------------------------// + // Assign Factory Functions -------------------------------- meshes.assign_factory([](const String& key) { diff --git a/tests/vkdemo/src/setup.hpp b/tests/vkdemo/src/setup.hpp index 40e0836..4e73ba9 100644 --- a/tests/vkdemo/src/setup.hpp +++ b/tests/vkdemo/src/setup.hpp @@ -9,9 +9,7 @@ #include // IWYU pragma: export #include // IWYU pragma: export -namespace demo { - -//============================================================================// +namespace demo { //############################################################# using namespace sq::coretypes; @@ -21,6 +19,4 @@ namespace maths = sq::maths; class DemoApp; struct ResourceCaches; -//============================================================================// - -} // namespace sts +} // namespace demo ############################################################