commit
This commit is contained in:
parent
dfe9b1abe9
commit
c82c8c0887
35 changed files with 245 additions and 10 deletions
33
src/base/module/Crafter.Graphics.Base-Window.cppm
Normal file
33
src/base/module/Crafter.Graphics.Base-Window.cppm
Normal file
|
|
@ -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 <vector>
|
||||
|
||||
export module Crafter.Graphics:Window;
|
||||
import :UiElement;
|
||||
|
||||
export namespace Crafter::Graphics::Base {
|
||||
class Window {
|
||||
public:
|
||||
std::vector<UiElement> elements;
|
||||
};
|
||||
}
|
||||
46
src/base/module/Crafter.Graphics.Base-WindowBuffer.cppm
Normal file
46
src/base/module/Crafter.Graphics.Base-WindowBuffer.cppm
Normal file
|
|
@ -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 <cstdint>
|
||||
#include <string>
|
||||
|
||||
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);
|
||||
};
|
||||
}
|
||||
32
src/base/module/Crafter.Graphics.Base-WindowClose.cppm
Normal file
32
src/base/module/Crafter.Graphics.Base-WindowClose.cppm
Normal file
|
|
@ -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<void> onClose;
|
||||
bool open = true;
|
||||
};
|
||||
}
|
||||
37
src/base/module/Crafter.Graphics.Base-WindowKeyboard.cppm
Normal file
37
src/base/module/Crafter.Graphics.Base-WindowKeyboard.cppm
Normal file
|
|
@ -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<void> onKeyDown[255];
|
||||
Event<void> onKeyHold[255];
|
||||
Event<void> onKeyUp[255];
|
||||
Event<char> onAnyKeyDown;
|
||||
Event<char> onAnyKeyHold;
|
||||
Event<char> onAnyKeyUp;
|
||||
};
|
||||
}
|
||||
51
src/base/module/Crafter.Graphics.Base-WindowMouse.cppm
Normal file
51
src/base/module/Crafter.Graphics.Base-WindowMouse.cppm
Normal file
|
|
@ -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 <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
export module Crafter.Graphics:Window;
|
||||
import Crafter.Event;
|
||||
import :UiElement;
|
||||
import :Types;
|
||||
|
||||
export namespace Crafter::Graphics::Base {
|
||||
class WindowMouse {
|
||||
public:
|
||||
Event<MousePoint> onMouseRightClick;
|
||||
Event<MousePoint> onMouseLeftClick;
|
||||
Event<MousePoint> onMouseRightHold;
|
||||
Event<MousePoint> onMouseLeftHold;
|
||||
Event<MousePoint> onMouseRightRelease;
|
||||
Event<MousePoint> onMouseLeftRelease;
|
||||
Event<MouseMoveEvent> onMouseMove;
|
||||
Event<MouseMoveEvent> onMouseEnter;
|
||||
Event<MouseMoveEvent> onMouseLeave;
|
||||
Event<double> onMouseScroll;
|
||||
MousePoint currentMousePos;
|
||||
MousePoint lastMousePos;
|
||||
MousePoint mouseDelta;
|
||||
bool mouseLeftHeld = false;
|
||||
bool mouseRightHeld = false;
|
||||
};
|
||||
}
|
||||
22
src/base/module/Crafter.Graphics.Base.cppm
Normal file
22
src/base/module/Crafter.Graphics.Base.cppm
Normal file
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 <typename MeshShader, typename FragmentShader>
|
||||
class VulkanPipeline {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ module;
|
|||
#include <vulkan/vulkan_wayland.h>
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
#include <vulkan/vk_enum_string_helper.h>
|
||||
// #include <vulkan/vk_enum_string_helper.h>
|
||||
#include <cstring>
|
||||
#include <print>
|
||||
#include <cstdio>
|
||||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue