From c82c8c0887e59281b5e3ae41b3ba093f87c11ce0 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Sun, 16 Nov 2025 15:32:03 +0100 Subject: [PATCH] commit --- {example => examples}/HelloDrawing/README.md | 2 +- {example => examples}/HelloDrawing/main.cpp | 0 .../HelloDrawing/project.json | 0 {example => examples}/HelloInput/README.md | 2 +- {example => examples}/HelloInput/main.cpp | 0 {example => examples}/HelloInput/project.json | 0 {example => examples}/HelloUI/README.md | 2 +- {example => examples}/HelloUI/main.cpp | 0 {example => examples}/HelloUI/project.json | 0 {example => examples}/HelloWindow/README.md | 1 + {example => examples}/HelloWindow/main.cpp | 0 .../HelloWindow/project.json | 0 {example => examples}/README.md | 0 {example => examples}/VulkanCube/README.md | 2 +- {example => examples}/VulkanCube/main.cpp | 0 {example => examples}/VulkanCube/project.json | 0 .../VulkanShader/CustomShader.glsl | 0 {example => examples}/VulkanShader/README.md | 3 +- {example => examples}/VulkanShader/main.cpp | 0 .../VulkanShader/project.json | 0 .../VulkanTriangle/README.md | 7 ++- {example => examples}/VulkanTriangle/main.cpp | 0 .../VulkanTriangle/project.json | 0 {example => examples}/VulkanWindow/README.md | 2 + {example => examples}/VulkanWindow/main.cpp | 0 .../VulkanWindow/project.json | 0 .../module/Crafter.Graphics.Base-Window.cppm | 33 ++++++++++++ .../Crafter.Graphics.Base-WindowBuffer.cppm | 46 +++++++++++++++++ .../Crafter.Graphics.Base-WindowClose.cppm | 32 ++++++++++++ .../Crafter.Graphics.Base-WindowKeyboard.cppm | 37 ++++++++++++++ .../Crafter.Graphics.Base-WindowMouse.cppm | 51 +++++++++++++++++++ src/base/module/Crafter.Graphics.Base.cppm | 22 ++++++++ src/module/Crafter.Graphics-VulkanDevice.cppm | 3 ++ .../Crafter.Graphics-VulkanPipeline.cppm | 6 ++- src/source/Crafter.Graphics-VulkanDevice.cpp | 4 +- 35 files changed, 245 insertions(+), 10 deletions(-) rename {example => examples}/HelloDrawing/README.md (82%) rename {example => examples}/HelloDrawing/main.cpp (100%) rename {example => examples}/HelloDrawing/project.json (100%) rename {example => examples}/HelloInput/README.md (93%) rename {example => examples}/HelloInput/main.cpp (100%) rename {example => examples}/HelloInput/project.json (100%) rename {example => examples}/HelloUI/README.md (85%) rename {example => examples}/HelloUI/main.cpp (100%) rename {example => examples}/HelloUI/project.json (100%) rename {example => examples}/HelloWindow/README.md (79%) rename {example => examples}/HelloWindow/main.cpp (100%) rename {example => examples}/HelloWindow/project.json (100%) rename {example => examples}/README.md (100%) rename {example => examples}/VulkanCube/README.md (85%) rename {example => examples}/VulkanCube/main.cpp (100%) rename {example => examples}/VulkanCube/project.json (100%) rename {example => examples}/VulkanShader/CustomShader.glsl (100%) rename {example => examples}/VulkanShader/README.md (82%) rename {example => examples}/VulkanShader/main.cpp (100%) rename {example => examples}/VulkanShader/project.json (100%) rename {example => examples}/VulkanTriangle/README.md (56%) rename {example => examples}/VulkanTriangle/main.cpp (100%) rename {example => examples}/VulkanTriangle/project.json (100%) rename {example => examples}/VulkanWindow/README.md (73%) rename {example => examples}/VulkanWindow/main.cpp (100%) rename {example => examples}/VulkanWindow/project.json (100%) create mode 100644 src/base/module/Crafter.Graphics.Base-Window.cppm create mode 100644 src/base/module/Crafter.Graphics.Base-WindowBuffer.cppm create mode 100644 src/base/module/Crafter.Graphics.Base-WindowClose.cppm create mode 100644 src/base/module/Crafter.Graphics.Base-WindowKeyboard.cppm create mode 100644 src/base/module/Crafter.Graphics.Base-WindowMouse.cppm create mode 100644 src/base/module/Crafter.Graphics.Base.cppm diff --git a/example/HelloDrawing/README.md b/examples/HelloDrawing/README.md similarity index 82% rename from example/HelloDrawing/README.md rename to examples/HelloDrawing/README.md index d3d1df5..d836ca7 100644 --- a/example/HelloDrawing/README.md +++ b/examples/HelloDrawing/README.md @@ -29,4 +29,4 @@ crafter-build -c example -r ## Relevant documentation - +[WindowWaylandWayland](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1WindowWaylandWayland.html) diff --git a/example/HelloDrawing/main.cpp b/examples/HelloDrawing/main.cpp similarity index 100% rename from example/HelloDrawing/main.cpp rename to examples/HelloDrawing/main.cpp diff --git a/example/HelloDrawing/project.json b/examples/HelloDrawing/project.json similarity index 100% rename from example/HelloDrawing/project.json rename to examples/HelloDrawing/project.json diff --git a/example/HelloInput/README.md b/examples/HelloInput/README.md similarity index 93% rename from example/HelloInput/README.md rename to examples/HelloInput/README.md index 8dcb6c3..de29a3c 100644 --- a/example/HelloInput/README.md +++ b/examples/HelloInput/README.md @@ -45,5 +45,5 @@ crafter-build -c example -r ## Relevant documentation - +[Window](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1Window.html) diff --git a/example/HelloInput/main.cpp b/examples/HelloInput/main.cpp similarity index 100% rename from example/HelloInput/main.cpp rename to examples/HelloInput/main.cpp diff --git a/example/HelloInput/project.json b/examples/HelloInput/project.json similarity index 100% rename from example/HelloInput/project.json rename to examples/HelloInput/project.json diff --git a/example/HelloUI/README.md b/examples/HelloUI/README.md similarity index 85% rename from example/HelloUI/README.md rename to examples/HelloUI/README.md index 0a59ac6..030e4d3 100644 --- a/example/HelloUI/README.md +++ b/examples/HelloUI/README.md @@ -33,4 +33,4 @@ crafter-build -c example -r ## Relevant documentation - +[UiElement](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1UiElement.html) diff --git a/example/HelloUI/main.cpp b/examples/HelloUI/main.cpp similarity index 100% rename from example/HelloUI/main.cpp rename to examples/HelloUI/main.cpp diff --git a/example/HelloUI/project.json b/examples/HelloUI/project.json similarity index 100% rename from example/HelloUI/project.json rename to examples/HelloUI/project.json diff --git a/example/HelloWindow/README.md b/examples/HelloWindow/README.md similarity index 79% rename from example/HelloWindow/README.md rename to examples/HelloWindow/README.md index 8cb15fb..0c36928 100644 --- a/example/HelloWindow/README.md +++ b/examples/HelloWindow/README.md @@ -23,4 +23,5 @@ crafter-build -c example -r ## Relevant documentation +[WindowWaylandWayland](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1WindowWaylandWayland.html) diff --git a/example/HelloWindow/main.cpp b/examples/HelloWindow/main.cpp similarity index 100% rename from example/HelloWindow/main.cpp rename to examples/HelloWindow/main.cpp diff --git a/example/HelloWindow/project.json b/examples/HelloWindow/project.json similarity index 100% rename from example/HelloWindow/project.json rename to examples/HelloWindow/project.json diff --git a/example/README.md b/examples/README.md similarity index 100% rename from example/README.md rename to examples/README.md diff --git a/example/VulkanCube/README.md b/examples/VulkanCube/README.md similarity index 85% rename from example/VulkanCube/README.md rename to examples/VulkanCube/README.md index 0dba5a6..89c7e90 100644 --- a/example/VulkanCube/README.md +++ b/examples/VulkanCube/README.md @@ -24,4 +24,4 @@ crafter-build -c example -r ## Relevant documentation - +[Camera](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1Mesh.html) diff --git a/example/VulkanCube/main.cpp b/examples/VulkanCube/main.cpp similarity index 100% rename from example/VulkanCube/main.cpp rename to examples/VulkanCube/main.cpp diff --git a/example/VulkanCube/project.json b/examples/VulkanCube/project.json similarity index 100% rename from example/VulkanCube/project.json rename to examples/VulkanCube/project.json diff --git a/example/VulkanShader/CustomShader.glsl b/examples/VulkanShader/CustomShader.glsl similarity index 100% rename from example/VulkanShader/CustomShader.glsl rename to examples/VulkanShader/CustomShader.glsl diff --git a/example/VulkanShader/README.md b/examples/VulkanShader/README.md similarity index 82% rename from example/VulkanShader/README.md rename to examples/VulkanShader/README.md index ec9d4ba..8a36066 100644 --- a/example/VulkanShader/README.md +++ b/examples/VulkanShader/README.md @@ -33,4 +33,5 @@ crafter-build -c example -r ## Relevant documentation - +[DescriptorSet](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1DescriptorSet.html) +[VulkanShader](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1VulkanShader.html) diff --git a/example/VulkanShader/main.cpp b/examples/VulkanShader/main.cpp similarity index 100% rename from example/VulkanShader/main.cpp rename to examples/VulkanShader/main.cpp diff --git a/example/VulkanShader/project.json b/examples/VulkanShader/project.json similarity index 100% rename from example/VulkanShader/project.json rename to examples/VulkanShader/project.json diff --git a/example/VulkanTriangle/README.md b/examples/VulkanTriangle/README.md similarity index 56% rename from example/VulkanTriangle/README.md rename to examples/VulkanTriangle/README.md index b357e6b..8b357b2 100644 --- a/example/VulkanTriangle/README.md +++ b/examples/VulkanTriangle/README.md @@ -26,4 +26,9 @@ crafter-build -c example -r ## Relevant documentation - +[DescriptorSet](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1DescriptorSet.html) +[Mesh](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1Mesh.html) +[MeshShader](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1MeshShader.html) +[VulkanShader](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1VulkanShader.html) +[VulkanPipeline](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1VulkanPipeline.html) +[WindowWaylandVulkan](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1WindowWaylandVulkan.html) \ No newline at end of file diff --git a/example/VulkanTriangle/main.cpp b/examples/VulkanTriangle/main.cpp similarity index 100% rename from example/VulkanTriangle/main.cpp rename to examples/VulkanTriangle/main.cpp diff --git a/example/VulkanTriangle/project.json b/examples/VulkanTriangle/project.json similarity index 100% rename from example/VulkanTriangle/project.json rename to examples/VulkanTriangle/project.json diff --git a/example/VulkanWindow/README.md b/examples/VulkanWindow/README.md similarity index 73% rename from example/VulkanWindow/README.md rename to examples/VulkanWindow/README.md index af75400..61ed4d5 100644 --- a/example/VulkanWindow/README.md +++ b/examples/VulkanWindow/README.md @@ -26,4 +26,6 @@ crafter-build -c example -r ## Relevant documentation +[VulkanDevice](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1VulkanDevice.html) +[WindowWaylandVulkan](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1WindowWaylandVulkan.html) diff --git a/example/VulkanWindow/main.cpp b/examples/VulkanWindow/main.cpp similarity index 100% rename from example/VulkanWindow/main.cpp rename to examples/VulkanWindow/main.cpp diff --git a/example/VulkanWindow/project.json b/examples/VulkanWindow/project.json similarity index 100% rename from example/VulkanWindow/project.json rename to examples/VulkanWindow/project.json diff --git a/src/base/module/Crafter.Graphics.Base-Window.cppm b/src/base/module/Crafter.Graphics.Base-Window.cppm new file mode 100644 index 0000000..a56470c --- /dev/null +++ b/src/base/module/Crafter.Graphics.Base-Window.cppm @@ -0,0 +1,33 @@ +/* +Crafter®.Graphics +Copyright (C) 2025 Catcrafts® +Catcrafts.net + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 3.0 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +module; + +#include + +export module Crafter.Graphics:Window; +import :UiElement; + +export namespace Crafter::Graphics::Base { + class Window { + public: + std::vector elements; + }; +} \ No newline at end of file diff --git a/src/base/module/Crafter.Graphics.Base-WindowBuffer.cppm b/src/base/module/Crafter.Graphics.Base-WindowBuffer.cppm new file mode 100644 index 0000000..9971de7 --- /dev/null +++ b/src/base/module/Crafter.Graphics.Base-WindowBuffer.cppm @@ -0,0 +1,46 @@ +/* +Crafter®.Graphics +Copyright (C) 2025 Catcrafts® +Catcrafts.net + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 3.0 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +module; + +#include +#include + +export module Crafter.Graphics:Window; +import Crafter.Event; +import :UiElement; + +export namespace Crafter::Graphics::Base { + struct ScaleData { + int32_t x; + int32_t y; + int32_t width; + int32_t height; + }; + + class WindowBuffer { + public: + std::uint32_t width; + std::uint32_t height; + float scale = 1; + Window(std::uint32_t width, std::uint32_t height, float scale = 1); + ScaleData ScaleElement(const UiElement& element); + }; +} \ No newline at end of file diff --git a/src/base/module/Crafter.Graphics.Base-WindowClose.cppm b/src/base/module/Crafter.Graphics.Base-WindowClose.cppm new file mode 100644 index 0000000..90a2173 --- /dev/null +++ b/src/base/module/Crafter.Graphics.Base-WindowClose.cppm @@ -0,0 +1,32 @@ +/* +Crafter®.Graphics +Copyright (C) 2025 Catcrafts® +Catcrafts.net + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 3.0 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +module; + +export module Crafter.Graphics:Window; +import Crafter.Event; + +export namespace Crafter::Graphics::Base { + class WindowClose { + public: + Event onClose; + bool open = true; + }; +} \ No newline at end of file diff --git a/src/base/module/Crafter.Graphics.Base-WindowKeyboard.cppm b/src/base/module/Crafter.Graphics.Base-WindowKeyboard.cppm new file mode 100644 index 0000000..673c44f --- /dev/null +++ b/src/base/module/Crafter.Graphics.Base-WindowKeyboard.cppm @@ -0,0 +1,37 @@ +/* +Crafter®.Graphics +Copyright (C) 2025 Catcrafts® +Catcrafts.net + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 3.0 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +module; + +export module Crafter.Graphics:Window; +import Crafter.Event; + +export namespace Crafter::Graphics::Base { + class WindowKeyboard { + public: + bool heldkeys[255] = {}; + Event onKeyDown[255]; + Event onKeyHold[255]; + Event onKeyUp[255]; + Event onAnyKeyDown; + Event onAnyKeyHold; + Event onAnyKeyUp; + }; +} \ No newline at end of file diff --git a/src/base/module/Crafter.Graphics.Base-WindowMouse.cppm b/src/base/module/Crafter.Graphics.Base-WindowMouse.cppm new file mode 100644 index 0000000..9436585 --- /dev/null +++ b/src/base/module/Crafter.Graphics.Base-WindowMouse.cppm @@ -0,0 +1,51 @@ +/* +Crafter®.Graphics +Copyright (C) 2025 Catcrafts® +Catcrafts.net + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 3.0 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +module; + +#include +#include +#include + +export module Crafter.Graphics:Window; +import Crafter.Event; +import :UiElement; +import :Types; + +export namespace Crafter::Graphics::Base { + class WindowMouse { + public: + Event onMouseRightClick; + Event onMouseLeftClick; + Event onMouseRightHold; + Event onMouseLeftHold; + Event onMouseRightRelease; + Event onMouseLeftRelease; + Event onMouseMove; + Event onMouseEnter; + Event onMouseLeave; + Event onMouseScroll; + MousePoint currentMousePos; + MousePoint lastMousePos; + MousePoint mouseDelta; + bool mouseLeftHeld = false; + bool mouseRightHeld = false; + }; +} \ No newline at end of file diff --git a/src/base/module/Crafter.Graphics.Base.cppm b/src/base/module/Crafter.Graphics.Base.cppm new file mode 100644 index 0000000..e209bee --- /dev/null +++ b/src/base/module/Crafter.Graphics.Base.cppm @@ -0,0 +1,22 @@ +/* +Crafter®.Graphics +Copyright (C) 2025 Catcrafts® +Catcrafts.net + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 3.0 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +export module Crafter.Graphics; +export import :Window; \ No newline at end of file diff --git a/src/module/Crafter.Graphics-VulkanDevice.cppm b/src/module/Crafter.Graphics-VulkanDevice.cppm index a3a3b77..b7fecf6 100644 --- a/src/module/Crafter.Graphics-VulkanDevice.cppm +++ b/src/module/Crafter.Graphics-VulkanDevice.cppm @@ -27,6 +27,9 @@ module; export module Crafter.Graphics:VulkanDevice; export namespace Crafter { + /** + * @brief Static class for initizializing and holding various vulkan handles. + */ class VulkanDevice { public: inline static VkInstance instance = VK_NULL_HANDLE; diff --git a/src/module/Crafter.Graphics-VulkanPipeline.cppm b/src/module/Crafter.Graphics-VulkanPipeline.cppm index 16fdf28..61cbfb5 100644 --- a/src/module/Crafter.Graphics-VulkanPipeline.cppm +++ b/src/module/Crafter.Graphics-VulkanPipeline.cppm @@ -44,8 +44,10 @@ namespace Crafter { * @tparam MeshShader The mesh shader type used in the pipeline. * @tparam FragmentShader The fragment shader type used in the pipeline. * - * @note Before using this pipeline, the CreatePipeline() function must be called, - * and all shader modules specified by the template parameters must be created. + * @note Before using this to render pipeline, the CreatePipeline() function must be called. + * + * @pre VulkanDevice::CreateDevice() must be called before creating or using this class, + VulkanShader::CreateShader() must be called before CreatePipeline(). */ export template class VulkanPipeline { diff --git a/src/source/Crafter.Graphics-VulkanDevice.cpp b/src/source/Crafter.Graphics-VulkanDevice.cpp index 9796017..05034cb 100644 --- a/src/source/Crafter.Graphics-VulkanDevice.cpp +++ b/src/source/Crafter.Graphics-VulkanDevice.cpp @@ -25,7 +25,7 @@ module; #include #include #include -#include +// #include #include #include #include @@ -55,7 +55,7 @@ const char* const layerNames[] = { void VulkanDevice::CHECK_VK_RESULT(VkResult result) { if (result != VK_SUCCESS) { - throw std::runtime_error(string_VkResult(result)); + throw std::runtime_error("vk error"); } }