new structure

This commit is contained in:
Jorijn van der Graaf 2025-11-16 15:32:11 +01:00
commit 1155e67d63
37 changed files with 2399 additions and 751 deletions

View file

@ -20,12 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module; module;
#include <cstdint>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <iostream>
#include <format>
module Crafter.Graphics; module Crafter.Graphics:Camera_impl;
import :Camera;
import Crafter.Math; import Crafter.Math;
import Crafter.Event; import Crafter.Event;
using namespace Crafter; using namespace Crafter;

View file

@ -18,11 +18,9 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
module; module Crafter.Graphics:UiElement_impl;
import :UiElement;
#include <cstdint>
module Crafter.Graphics;
using namespace Crafter; using namespace Crafter;
UiElement::UiElement(float anchorX, float anchorY, std::uint32_t bufferWidth, std::uint32_t bufferHeight, std::uint32_t absoluteWidth, std::uint32_t absoluteHeight, float anchorOffsetX, float anchorOffsetY, float z, bool ignoreScaling) : anchorX(anchorX), anchorY(anchorY), bufferWidth(bufferWidth), bufferHeight(bufferHeight), absoluteWidth(absoluteWidth), absoluteHeight(absoluteHeight), anchorOffsetX(anchorOffsetX), anchorOffsetY(anchorOffsetY), z(z), buffer(bufferWidth*bufferHeight), useRelativeSize(false), ignoreScaling(ignoreScaling) { UiElement::UiElement(float anchorX, float anchorY, std::uint32_t bufferWidth, std::uint32_t bufferHeight, std::uint32_t absoluteWidth, std::uint32_t absoluteHeight, float anchorOffsetX, float anchorOffsetY, float z, bool ignoreScaling) : anchorX(anchorX), anchorY(anchorY), bufferWidth(bufferWidth), bufferHeight(bufferHeight), absoluteWidth(absoluteWidth), absoluteHeight(absoluteHeight), anchorOffsetX(anchorOffsetX), anchorOffsetY(anchorOffsetY), z(z), buffer(bufferWidth*bufferHeight), useRelativeSize(false), ignoreScaling(ignoreScaling) {

View file

@ -20,20 +20,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module; module;
#include <cstdint>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <vulkan/vulkan_wayland.h> #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>
#include "../../lib/VulkanInitializers.hpp"
#define GET_EXTENSION_FUNCTION(_id) ((PFN_##_id)(vkGetInstanceProcAddr(instance, #_id))) #define GET_EXTENSION_FUNCTION(_id) ((PFN_##_id)(vkGetInstanceProcAddr(instance, #_id)))
module Crafter.Graphics; module Crafter.Graphics:VulkanDevice_impl;
import :VulkanDevice;
using namespace Crafter; using namespace Crafter;
const char* const instanceExtensionNames[] = { const char* const instanceExtensionNames[] = {
"VK_EXT_debug_utils", "VK_EXT_debug_utils",

View file

@ -23,7 +23,8 @@ module;
#include <cstdint> #include <cstdint>
#include <string> #include <string>
module Crafter.Graphics; module Crafter.Graphics:Window_impl;
import :Window;
import Crafter.Event; import Crafter.Event;
using namespace Crafter; using namespace Crafter;

View file

@ -23,41 +23,24 @@ module;
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <linux/input.h> #include <linux/input.h>
#include <string>
#include <sys/mman.h>
#include <unistd.h> #include <unistd.h>
#include <wayland-cursor.h> #include <wayland-cursor.h>
#include <xkbcommon/xkbcommon.h>
#include <iostream>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <vulkan/vulkan_wayland.h> #include <vulkan/vulkan_wayland.h>
#include <wayland-client.h> #include <wayland-client.h>
#include <cstring>
#include "../../lib/xdg-shell-client-protocol.h"
#include "../../lib/wayland-xdg-decoration-unstable-v1-client-protocol.h"
#define _POSIX_C_SOURCE 200809L
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <sys/mman.h>
#include <time.h>
#include <unistd.h>
#include <print>
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <unistd.h> #include <unistd.h>
#include <wayland-client.h> #include <wayland-client.h>
#include <wayland-client-protocol.h> #include <wayland-client-protocol.h>
#include <linux/input-event-codes.h> #include <linux/input-event-codes.h>
#include <cmath>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#include <cstdio>
module Crafter.Graphics; module Crafter.Graphics:WindowWaylandWayland;
import :WindowWaylandWayland;
import std;
import Crafter.Event; import Crafter.Event;
using namespace Crafter; using namespace Crafter;

View file

@ -20,20 +20,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module; module;
#include <cstdint>
#include <string>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <vulkan/vulkan_wayland.h> #include <vulkan/vulkan_wayland.h>
#include <vector>
#include <wayland-client.h> #include <wayland-client.h>
#include <thread>
#include <iostream>
#include <cassert>
#include <exception>
#include "../../lib/VulkanInitializers.hpp"
#include "../../lib/VulkanTransition.hpp"
module Crafter.Graphics; module Crafter.Graphics;
import std;
import Crafter.Event; import Crafter.Event;
using namespace Crafter; using namespace Crafter;

View file

@ -23,22 +23,15 @@ module;
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <linux/input.h> #include <linux/input.h>
#include <string>
#include <sys/mman.h> #include <sys/mman.h>
#include <unistd.h> #include <unistd.h>
#include <wayland-cursor.h> #include <wayland-cursor.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#include <iostream>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <vulkan/vulkan_wayland.h> #include <vulkan/vulkan_wayland.h>
#include <wayland-client.h> #include <wayland-client.h>
#include <cstring>
#include "../../lib/xdg-shell-client-protocol.h"
#include "../../lib/wayland-xdg-decoration-unstable-v1-client-protocol.h"
#define _POSIX_C_SOURCE 200809L
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
@ -46,16 +39,14 @@ module;
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <unistd.h> #include <unistd.h>
#include <wayland-client.h> #include <wayland-client.h>
#include <wayland-client-protocol.h> #include <wayland-client-protocol.h>
#include <linux/input-event-codes.h> #include <linux/input-event-codes.h>
#include <cmath>
#include <thread>
module Crafter.Graphics; module Crafter.Graphics;
import std;
import Crafter.Event; import Crafter.Event;
using namespace Crafter; using namespace Crafter;

View file

@ -18,12 +18,8 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
module;
#include <cstdint>
export module Crafter.Graphics:Camera; export module Crafter.Graphics:Camera;
import :VulkanBuffer; import std;
import Crafter.Math; import Crafter.Math;
import Crafter.Event; import Crafter.Event;
@ -58,6 +54,6 @@ namespace Crafter {
* @param y The y-coordinate on the screen (in pixels). * @param y The y-coordinate on the screen (in pixels).
* @return A normalized 3D direction vector representing the ray from the camera. * @return A normalized 3D direction vector representing the ray from the camera.
*/ */
Vector<float, 3> ToRay(uint32_t x, uint32_t y); Vector<float, 3> ToRay(std::uint32_t x, std::uint32_t y);
}; };
} }

View file

@ -20,14 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module; module;
#include <cstdint>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <cstring>
#include <iostream>
#include <vector>
#include "../../lib/VulkanInitializers.hpp"
export module Crafter.Graphics:DescriptorSet; export module Crafter.Graphics:DescriptorSet;
import std;
import Crafter.Event; import Crafter.Event;
import :VulkanDevice; import :VulkanDevice;
import :VulkanShader; import :VulkanShader;

View file

@ -20,14 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module; module;
#include <cstdint>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <cstring>
#include <iostream>
#include <cmath>
#include "../../lib/VulkanInitializers.hpp"
export module Crafter.Graphics:HeightmapShader; export module Crafter.Graphics:HeightmapShader;
import std;
import :Camera; import :Camera;
import :VulkanPipeline; import :VulkanPipeline;
import :DescriptorSet; import :DescriptorSet;

View file

@ -20,12 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module; module;
#include <cstdint>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <cstring>
#include <iostream>
export module Crafter.Graphics:Mesh; export module Crafter.Graphics:Mesh;
import std;
import Crafter.Math; import Crafter.Math;
import :VulkanBuffer; import :VulkanBuffer;
import :Types; import :Types;

View file

@ -20,14 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module; module;
#include <cstdint>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <cstring>
#include <iostream>
#include <cmath>
#include "../../lib/VulkanInitializers.hpp"
export module Crafter.Graphics:MeshShader; export module Crafter.Graphics:MeshShader;
import std;
import :Mesh; import :Mesh;
import :Camera; import :Camera;
import :VulkanPipeline; import :VulkanPipeline;

View file

@ -20,13 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module; module;
#include <cstdint>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <cstring>
#include <iostream>
#include "../../lib/VulkanInitializers.hpp"
export module Crafter.Graphics:TextureShader; export module Crafter.Graphics:TextureShader;
import std;
import :VulkanTexture; import :VulkanTexture;
import :VulkanPipeline; import :VulkanPipeline;
import :DescriptorSet; import :DescriptorSet;

View file

@ -18,11 +18,8 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
module;
#include <cstdint>
export module Crafter.Graphics:Types; export module Crafter.Graphics:Types;
import std;
namespace Crafter { namespace Crafter {
export struct MousePoint { export struct MousePoint {

View file

@ -18,12 +18,8 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
module;
#include <cstdint>
#include <vector>
export module Crafter.Graphics:UiElement; export module Crafter.Graphics:UiElement;
import std;
import Crafter.Event; import Crafter.Event;
import :Types; import :Types;

View file

@ -18,16 +18,10 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
module;
#include <cstdint>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <cstring>
#include <iostream>
#include <cmath>
#include "../../lib/VulkanInitializers.hpp"
export module Crafter.Graphics:VoxelShader; export module Crafter.Graphics:VoxelShader;
import std;
import :Mesh; import :Mesh;
import :Camera; import :Camera;
import :VulkanPipeline; import :VulkanPipeline;

View file

@ -18,13 +18,10 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
module;
#include <cstdint>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include "../../lib/VulkanInitializers.hpp"
export module Crafter.Graphics:VulkanBuffer; export module Crafter.Graphics:VulkanBuffer;
import std;
import :VulkanDevice; import :VulkanDevice;
namespace Crafter { namespace Crafter {

View file

@ -18,13 +18,11 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
module;
#include <cstdint>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <vulkan/vulkan_wayland.h> #include <vulkan/vulkan_wayland.h>
export module Crafter.Graphics:VulkanDevice; export module Crafter.Graphics:VulkanDevice;
import std;
export namespace Crafter { export namespace Crafter {
class VulkanDevice { class VulkanDevice {

View file

@ -20,13 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module; module;
#include <cstdint>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <array>
#include "../../lib/VulkanInitializers.hpp"
#include <unordered_map>
export module Crafter.Graphics:VulkanPipeline; export module Crafter.Graphics:VulkanPipeline;
import std;
import :VulkanDevice; import :VulkanDevice;
import :VulkanShader; import :VulkanShader;
import :WindowWaylandVulkan; import :WindowWaylandVulkan;

View file

@ -20,15 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module; module;
#include <iostream>
#include <algorithm>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <fstream>
#include <cstdint>
#include <vector>
#include <array>
export module Crafter.Graphics:VulkanShader; export module Crafter.Graphics:VulkanShader;
import std;
import :VulkanDevice; import :VulkanDevice;
namespace Crafter { namespace Crafter {

View file

@ -20,12 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module; module;
#include <cstdint>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <cstring>
#include <iostream>
export module Crafter.Graphics:VulkanTexture; export module Crafter.Graphics:VulkanTexture;
import std;
import :VulkanDevice; import :VulkanDevice;
import :VulkanBuffer; import :VulkanBuffer;

View file

@ -18,23 +18,18 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
module;
#include <cstdint>
#include <string>
#include <vector>
export module Crafter.Graphics:Window; export module Crafter.Graphics:Window;
import std;
import Crafter.Event; import Crafter.Event;
import :UiElement; import :UiElement;
import :Types; import :Types;
export namespace Crafter { export namespace Crafter {
struct ScaleData { struct ScaleData {
int32_t x; std::int32_t x;
int32_t y; std::int32_t y;
int32_t width; std::int32_t width;
int32_t height; std::int32_t height;
}; };
/** /**

View file

@ -20,13 +20,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module; module;
#include <cstdint>
#include <string>
#include <wayland-client.h> #include <wayland-client.h>
#include "../../lib/xdg-shell-client-protocol.h" #include <xkbcommon/xkbcommon.h>
#include "../../lib/wayland-xdg-decoration-unstable-v1-client-protocol.h"
export module Crafter.Graphics:WindowWayland; export module Crafter.Graphics:WindowWayland;
import std;
import Crafter.Event; import Crafter.Event;
import :UiElement; import :UiElement;
import :Types; import :Types;

View file

@ -20,14 +20,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module; module;
#include <cstdint>
#include <string>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <vulkan/vulkan_wayland.h> #include <vulkan/vulkan_wayland.h>
#include <vector>
#include <thread>
export module Crafter.Graphics:WindowWaylandVulkan; export module Crafter.Graphics:WindowWaylandVulkan;
import std;
import Crafter.Event; import Crafter.Event;
import :WindowWayland; import :WindowWayland;

View file

@ -18,13 +18,8 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
module;
#include <cstdint>
#include <string>
#include <thread>
export module Crafter.Graphics:WindowWaylandWayland; export module Crafter.Graphics:WindowWaylandWayland;
import std;
import Crafter.Event; import Crafter.Event;
import :WindowWayland; import :WindowWayland;

File diff suppressed because it is too large Load diff

View file

@ -23,18 +23,19 @@ export module Crafter.Graphics;
export import :Window; export import :Window;
export import :WindowWayland; export import :WindowWayland;
export import :WindowWaylandWayland; export import :WindowWaylandWayland;
export import :WindowWaylandVulkan;
export import :UiElement; export import :UiElement;
export import :Types; export import :Types;
export import :VulkanDevice;
export import :VulkanPipeline;
export import :VulkanShader;
export import :Camera; export import :Camera;
export import :VulkanBuffer;
export import :VoxelShader; // export import :WindowWaylandVulkan;
export import :Mesh; // export import :VulkanBuffer;
export import :MeshShader; // export import :VoxelShader;
export import :VulkanTexture; // export import :Mesh;
export import :TextureShader; // export import :MeshShader;
export import :DescriptorSet; // export import :VulkanTexture;
export import :HeightmapShader; // export import :TextureShader;
// export import :DescriptorSet;
// export import :HeightmapShader;
// export import :VulkanDevice;
// export import :VulkanPipeline;
// export import :VulkanShader;

View file

@ -3,16 +3,23 @@
"configurations": [ "configurations": [
{ {
"name": "base", "name": "base",
"standard": "c++26", "implementations": ["implementations/Crafter.Graphics-Window", "implementations/Crafter.Graphics-UiElement", "implementations/Crafter.Graphics-Camera"],
"source_files": ["src/source/Crafter.Graphics-Window","src/source/Crafter.Graphics-WindowWayland","src/source/Crafter.Graphics-WindowWaylandWayland", "src/source/Crafter.Graphics-UiElement", "src/source/Crafter.Graphics-VulkanDevice", "src/source/Crafter.Graphics-WindowWaylandVulkan", "lib/VulkanTools", "src/source/Crafter.Graphics-Camera"], "interfaces": ["interfaces/Crafter.Graphics-Window", "interfaces/Crafter.Graphics", "interfaces/Crafter.Graphics-UiElement", "interfaces/Crafter.Graphics-Types", "interfaces/Crafter.Graphics-Camera"],
"c_files": ["lib/wayland-xdg-decoration-unstable-v1-client-protocol", "lib/xdg-shell-protocol", "lib/shm"], "type": "library"
"module_files": ["src/module/Crafter.Graphics-Window","src/module/Crafter.Graphics-WindowWayland","src/module/Crafter.Graphics-WindowWaylandWayland", "src/module/Crafter.Graphics", "src/module/Crafter.Graphics-UiElement", "src/module/Crafter.Graphics-Types", "src/module/Crafter.Graphics-VulkanDevice", "src/module/Crafter.Graphics-VulkanPipeline", "src/module/Crafter.Graphics-VulkanShader", "src/module/Crafter.Graphics-WindowWaylandVulkan", "src/module/Crafter.Graphics-Camera", "src/module/Crafter.Graphics-VulkanBuffer", "src/module/Crafter.Graphics-Mesh", "src/module/Crafter.Graphics-MeshShader", "src/module/Crafter.Graphics-HeightmapShader","src/module/Crafter.Graphics-VoxelShader", "src/module/Crafter.Graphics-VulkanTexture", "src/module/Crafter.Graphics-TextureShader", "src/module/Crafter.Graphics-DescriptorSet"], },
"build_dir": "build", {
"output_dir": "bin", "name": "wayland",
"type":"library", "implementations": ["implementations/Crafter.Graphics-WindowWayland", "implementations/Crafter.Graphics-WindowWaylandWayland"],
"libs": ["wayland-client", "vulkan", "xkbcommon"], "interfaces": ["interfaces/Crafter.Graphics-WindowWayland", "interfaces/Crafter.Graphics-WindowWaylandWayland"],
"flags": ["-Wno-uninitialized"], "libs": ["wayland-client", "xkbcommon"],
"shaders": [ "extends": ["base"]
},
{
"name": "vulkan",
"implementations": ["implementations/Crafter.Graphics-VulkanDevice", "implementations/Crafter.Graphics-WindowWaylandVulkan"],
"interfaces": ["interfaces/Crafter.Graphics-WindowWayland", "interfaces/Crafter.Graphics-WindowWaylandWayland", "interfaces/Crafter.Graphics-VulkanDevice", "interfaces/Crafter.Graphics-VulkanPipeline", "interfaces/Crafter.Graphics-VulkanShader", "interfaces/Crafter.Graphics-WindowWaylandVulkan", "interfaces/Crafter.Graphics-VulkanBuffer", "interfaces/Crafter.Graphics-Mesh", "interfaces/Crafter.Graphics-MeshShader", "interfaces/Crafter.Graphics-HeightmapShader","interfaces/Crafter.Graphics-VoxelShader", "interfaces/Crafter.Graphics-VulkanTexture", "interfaces/Crafter.Graphics-TextureShader", "interfaces/Crafter.Graphics-DescriptorSet"],
"libs": ["vulkan"],
"shaders": [
{ {
"path":"src/shader/MeshShaderXYZ.glsl", "path":"src/shader/MeshShaderXYZ.glsl",
"type":13, "type":13,
@ -53,22 +60,30 @@
"type":4, "type":4,
"entrypoint":"main" "entrypoint":"main"
} }
],
"extends": ["wayland"]
},
{
"name": "deps",
"dependencies": [
{
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Event.git",
"configuration":"lib"
},
{
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git",
"configuration":"lib"
}
] ]
}, },
{ {
"name": "lib-debug", "name": "deps-debug",
"extends": ["base"],
"optimization_level": "0",
"debug": true, "debug": true,
"dependencies": [ "dependencies": [
{ {
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Event.git", "path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Event.git",
"configuration":"lib-debug" "configuration":"lib-debug"
}, },
{
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Asset.git",
"configuration":"lib-debug"
},
{ {
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git", "path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git",
"configuration":"lib-debug" "configuration":"lib-debug"
@ -76,29 +91,12 @@
] ]
}, },
{ {
"name": "lib-release", "name": "lib-wayland",
"extends": ["base"], "extends": ["wayland", "deps"]
"optimization_level": "3",
"dependencies": [
{
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Event.git",
"configuration":"lib-release"
},
{
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Asset.git",
"configuration":"lib-release"
},
{
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git",
"configuration":"lib-release"
}
]
}, },
{ {
"name": "develop", "name": "lib-wayland-debug",
"extends": ["lib-debug"], "extends": ["wayland", "deps-debug"]
"source_files": ["src/source/main"],
"type":"executable"
} }
] ]
} }

View file

@ -1,28 +0,0 @@
/*
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
*/
#version 450
layout(location = 0) out vec4 outFragColor;
void main()
{
outFragColor = vec4(1, 1, 1, 1);
}

View file

@ -1,78 +0,0 @@
/*
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
*/
#version 450
layout(location = 0) in vec2 fragUV;
layout(location = 0) out vec4 outColor;
layout(set = 1, binding = 0) uniform sampler2D texSampler;
void main()
{
outColor = texture(texSampler, fragUV);
}
/*
float getFilledAlpha(vec2 uv, vec2 center, float radius, float fillAmount) {
vec2 dir = uv - center;
float dist = length(dir);
// If outside the circle, return 0
if (dist > radius)
return 0.0;
// Normalize direction vector and compute angle
float angle = atan(dir.y, dir.x); // atan returns from -PI to PI
if (angle < 0.0) angle += 2.0 * 3.14159265359; // Convert to 0 to 2PI
float filledAngle = fillAmount * 2.0 * 3.14159265359;
// If the point is within the filled angle, return 1
if (angle <= filledAngle)
return 1.0;
return 0.0;
}
*/
/*
float getFilledAlphaAA(vec2 uv, vec2 center, float radius, float fillAmount, float edgeSoftness) {
vec2 dir = uv - center;
float dist = length(dir);
// If completely outside the circle, return 0
if (dist > radius + edgeSoftness)
return 0.0;
// Normalize direction vector and compute angle
float angle = atan(dir.y, dir.x); // -PI to PI
if (angle < 0.0) angle += 2.0 * 3.14159265359; // Convert to 0 to 2PI
float filledAngle = fillAmount * 2.0 * 3.14159265359;
// Calculate smooth edge for radius
float radiusAlpha = 1.0 - smoothstep(radius, radius + edgeSoftness, dist);
// Calculate smooth edge for angle
float angleAlpha = smoothstep(filledAngle - 0.02, filledAngle + 0.02, angle); // 0.02 rad ~ edge softness
return radiusAlpha * angleAlpha;
}
*/

View file

@ -1,29 +0,0 @@
/*
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
*/
#version 450
layout(location = 0) in vec4 inColor;
layout(location = 0) out vec4 outColor;
void main()
{
outColor = inColor;
}

View file

@ -1,82 +0,0 @@
/*
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
*/
#version 450
#extension GL_EXT_mesh_shader : require
layout (binding = 0) uniform UBO
{
mat4 modelProjectionView;
uint stride;
float spacing;
uint padding[14];
} ubo;
struct VertexType
{
float height;
float padding[3];
vec4 color;
};
layout (binding = 1) buffer VERTEX
{
VertexType pos[];
} vertex;
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
layout(triangles, max_vertices = 256, max_primitives = 128) out;
layout (location = 0) out PerVertexData
{
vec4 color;
} outVert[];
void main()
{
SetMeshOutputsEXT(256, 128);
uint linearID = gl_GlobalInvocationID.x;
uint quadX = linearID % ubo.stride;
uint quadZ = linearID / ubo.stride;
VertexType vertex1 = vertex.pos[quadZ * ubo.stride + quadX];
VertexType vertex2 = vertex.pos[quadZ * ubo.stride + quadX + 1];
VertexType vertex3 = vertex.pos[(quadZ+1) * ubo.stride + quadX];
VertexType vertex4 = vertex.pos[(quadZ+1) * ubo.stride + quadX + 1];
uint vertexID = gl_LocalInvocationID.x*4;
gl_MeshVerticesEXT[vertexID].gl_Position = ubo.modelProjectionView * vec4(ubo.spacing*quadX, vertex1.height, ubo.spacing*quadZ, 1); // Top-left
gl_MeshVerticesEXT[vertexID + 1].gl_Position = ubo.modelProjectionView * vec4(ubo.spacing*quadX+ubo.spacing, vertex2.height, ubo.spacing*quadZ, 1); // Top-right
gl_MeshVerticesEXT[vertexID + 2].gl_Position = ubo.modelProjectionView * vec4(ubo.spacing*quadX, vertex3.height, ubo.spacing*quadZ+ubo.spacing, 1); // Bottom-left
gl_MeshVerticesEXT[vertexID + 3].gl_Position = ubo.modelProjectionView * vec4(ubo.spacing*quadX+ubo.spacing, vertex4.height, ubo.spacing*quadZ+ubo.spacing, 1); // Bottom-right
outVert[vertexID].color = vertex1.color;
outVert[vertexID + 1].color = vertex2.color;
outVert[vertexID+ 2].color = vertex3.color;
outVert[vertexID + 3].color = vertex4.color;
uint triangleID = gl_LocalInvocationID.x*2;
gl_PrimitiveTriangleIndicesEXT[triangleID] = uvec3(vertexID+2, vertexID+1, vertexID);
gl_PrimitiveTriangleIndicesEXT[triangleID + 1] = uvec3(vertexID+3, vertexID+1, vertexID+2);
}

View file

@ -1,159 +0,0 @@
/*
* 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
*/
#version 450
#extension GL_EXT_mesh_shader : require
layout (binding = 0) uniform UBO
{
mat4 modelProjectionView;
uint sizeX;
uint sizeY;
uint sizeZ;
} ubo;
struct VoxelType
{
uint type;
};
layout (binding = 1) buffer VOXELS
{
VoxelType voxel[];
} voxels;
layout (location = 0) out PerVertexData
{
vec4 color;
} outVert[];
shared uint writeCounter;
layout(local_size_x = 16, local_size_y = 1, local_size_z = 1) in;
layout(triangles, max_vertices = 128, max_primitives = 192) out;
void main()
{
if (gl_LocalInvocationIndex == 0) {
writeCounter = 0;
}
barrier();
uint type = voxels.voxel[gl_GlobalInvocationID.x].type;
if(type != 0) {
uint old = atomicAdd(writeCounter, 1);
uint z = gl_GlobalInvocationID.x / (ubo.sizeX * ubo.sizeY);
uint y = (gl_GlobalInvocationID.x % (ubo.sizeX * ubo.sizeY)) / ubo.sizeX;
uint x = gl_GlobalInvocationID.x % ubo.sizeX;
float zF = float(z);
float yF = float(y);
float xF = float(x);
uint oldVertexOffset = old*8;
float xC = xF / float((ubo.sizeX) - 1);
float yC = yF / float((ubo.sizeY) - 1);
float zC = zF / float((ubo.sizeZ) - 1);
gl_MeshVerticesEXT[oldVertexOffset + 0].gl_Position = ubo.modelProjectionView * vec4(xF - 0.5, yF - 0.5, zF - 0.5, 1.0);
gl_MeshVerticesEXT[oldVertexOffset + 1].gl_Position = ubo.modelProjectionView * vec4(xF + 0.5, yF - 0.5, zF - 0.5, 1.0);
gl_MeshVerticesEXT[oldVertexOffset + 2].gl_Position = ubo.modelProjectionView * vec4(xF + 0.5, yF + 0.5, zF - 0.5, 1.0);
gl_MeshVerticesEXT[oldVertexOffset + 3].gl_Position = ubo.modelProjectionView * vec4(xF - 0.5, yF + 0.5, zF - 0.5, 1.0);
gl_MeshVerticesEXT[oldVertexOffset + 4].gl_Position = ubo.modelProjectionView * vec4(xF - 0.5, yF - 0.5, zF + 0.5, 1.0);
gl_MeshVerticesEXT[oldVertexOffset + 5].gl_Position = ubo.modelProjectionView * vec4(xF + 0.5, yF - 0.5, zF + 0.5, 1.0);
gl_MeshVerticesEXT[oldVertexOffset + 6].gl_Position = ubo.modelProjectionView * vec4(xF + 0.5, yF + 0.5, zF + 0.5, 1.0);
gl_MeshVerticesEXT[oldVertexOffset + 7].gl_Position = ubo.modelProjectionView * vec4(xF - 0.5, yF + 0.5, zF + 0.5, 1.0);
outVert[oldVertexOffset + 0].color = vec4(xC, yC, zC, 1);
outVert[oldVertexOffset + 1].color = vec4(xC, yC, zC, 1);
outVert[oldVertexOffset + 2].color = vec4(xC, yC, zC, 1);
outVert[oldVertexOffset + 3].color = vec4(xC, yC, zC, 1);
outVert[oldVertexOffset + 4].color = vec4(xC, yC, zC, 1);
outVert[oldVertexOffset + 5].color = vec4(xC, yC, zC, 1);
outVert[oldVertexOffset + 6].color = vec4(xC, yC, zC, 1);
outVert[oldVertexOffset + 7].color = vec4(xC, yC, zC, 1);
uint oldPrimOffset = old*12;
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 0] = uvec3(oldVertexOffset + 2, oldVertexOffset + 1, oldVertexOffset + 0);
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 1] = uvec3(oldVertexOffset + 0, oldVertexOffset + 3, oldVertexOffset + 2);
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 2] = uvec3(oldVertexOffset + 4, oldVertexOffset + 5, oldVertexOffset + 6);
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 3] = uvec3(oldVertexOffset + 4, oldVertexOffset + 6, oldVertexOffset + 7);
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 4] = uvec3(oldVertexOffset + 0, oldVertexOffset + 1, oldVertexOffset + 5);
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 5] = uvec3(oldVertexOffset + 5, oldVertexOffset + 4, oldVertexOffset + 0);
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 6] = uvec3(oldVertexOffset + 3, oldVertexOffset + 6, oldVertexOffset + 2);
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 7] = uvec3(oldVertexOffset + 3, oldVertexOffset + 7, oldVertexOffset + 6);
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 8] = uvec3(oldVertexOffset + 7, oldVertexOffset + 3, oldVertexOffset + 0);
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 9] = uvec3(oldVertexOffset + 4, oldVertexOffset + 7, oldVertexOffset + 0);
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 10] = uvec3(oldVertexOffset + 1, oldVertexOffset + 2, oldVertexOffset + 6);
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 11] = uvec3(oldVertexOffset + 6, oldVertexOffset + 5, oldVertexOffset + 1);
}
barrier();
SetMeshOutputsEXT(writeCounter*8, writeCounter*12);
}
/**
int z = gl_GlobalInvocationID.x / (ubo.sizeX * ubo.sizeY);
int y = (gl_GlobalInvocationID.x % (ubo.sizeX * ubo.sizeY)) / ubo.sizeX;
int x = gl_GlobalInvocationID.x % ubo.sizeX;
// Top (y+1) if within bounds
if (y < ubo.sizeY - 1 && vertex.pos[gl_GlobalInvocationID.x + ubo.sizeX]) {
}
// Bottom (y-1) if within bounds
if (y > 0 && vertex.pos[gl_GlobalInvocationID.x - ubo.sizeX]) {
}
// Left (x-1) if within bounds
if (x > 0 && vertex.pos[gl_GlobalInvocationID.x - 1]) {
}
// Right (x+1) if within bounds
if (x < ubo.sizeX - 1 && vertex.pos[gl_GlobalInvocationID.x + 1]) {
}
// Front (z+1) if within bounds
if (z < ubo.sizeZ - 1 && vertex.pos[gl_GlobalInvocationID.x + ubo.sizeX * ubo.sizeY]) {
}
// Back (z-1) if within bounds
if (z > 0 && vertex.pos[gl_GlobalInvocationID.x - ubo.sizeX * ubo.sizeY]) {
}
**/

View file

@ -1,50 +0,0 @@
/*
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
*/
#version 450
#extension GL_EXT_mesh_shader : require
layout (binding = 0) uniform UBO
{
mat4 modelProjectionView;
} ubo;
layout (binding = 1) buffer VERTEX
{
vec4 pos[];
} vertex;
layout (binding = 2) buffer INDEX {
uint index[];
} index;
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
layout(triangles, max_vertices = 192, max_primitives = 64) out;
void main()
{
SetMeshOutputsEXT(192, 64);
uint triangleID = ((gl_WorkGroupID.x * gl_WorkGroupSize.x) + gl_LocalInvocationIndex.x)*3;
uint localID = gl_LocalInvocationIndex.x*3;
gl_MeshVerticesEXT[localID].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID]];
gl_MeshVerticesEXT[localID+1].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID+1]];
gl_MeshVerticesEXT[localID+2].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID+2]];
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex.x] = uvec3(localID, localID+1, localID+2);
}

View file

@ -1,65 +0,0 @@
/*
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
*/
#version 450
#extension GL_EXT_mesh_shader : require
layout (binding = 0) uniform UBO
{
mat4 modelProjectionView;
} ubo;
struct VertexType
{
vec4 position;
vec4 color;
};
layout (std140, binding = 1) buffer VERTEX
{
VertexType pos[];
} vertex;
layout (binding = 2) buffer INDEX {
uint index[];
} index;
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
layout(triangles, max_vertices = 192, max_primitives = 64) out;
layout (location = 0) out PerVertexData
{
vec4 color;
} outVert[];
void main()
{
SetMeshOutputsEXT(192, 64);
uint triangleID = ((gl_WorkGroupID.x * gl_WorkGroupSize.x) + gl_LocalInvocationIndex.x)*3;
uint localID = gl_LocalInvocationIndex.x*3;
gl_MeshVerticesEXT[localID].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID]].position;
gl_MeshVerticesEXT[localID+1].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID+1]].position;
gl_MeshVerticesEXT[localID+2].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID+2]].position;
outVert[localID].color = vertex.pos[index.index[triangleID]].color;
outVert[localID + 1].color = vertex.pos[index.index[triangleID+1]].color;
outVert[localID + 2].color = vertex.pos[index.index[triangleID+2]].color;
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex.x] = uvec3(localID, localID+1, localID+2);
}

View file

@ -1,66 +0,0 @@
/*
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
*/
#version 450
#extension GL_EXT_mesh_shader : require
layout (binding = 0) uniform UBO
{
mat4 modelProjectionView;
} ubo;
struct VertexType
{
vec4 position;
vec2 uv;
vec2 pad;
};
layout (std140, binding = 1) buffer VERTEX
{
VertexType pos[];
} vertex;
layout (binding = 2) buffer INDEX {
uint index[];
} index;
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
layout(triangles, max_vertices = 192, max_primitives = 64) out;
layout (location = 0) out PerVertexData
{
vec2 uv;
} outVert[];
void main()
{
SetMeshOutputsEXT(192, 64);
uint triangleID = ((gl_WorkGroupID.x * gl_WorkGroupSize.x) + gl_LocalInvocationIndex.x)*3;
uint localID = gl_LocalInvocationIndex.x*3;
gl_MeshVerticesEXT[localID].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID]].position;
gl_MeshVerticesEXT[localID+1].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID+1]].position;
gl_MeshVerticesEXT[localID+2].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID+2]].position;
outVert[localID].uv = vertex.pos[index.index[triangleID]].uv;
outVert[localID + 1].uv = vertex.pos[index.index[triangleID+1]].uv;
outVert[localID + 2].uv = vertex.pos[index.index[triangleID+2]].uv;
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex.x] = uvec3(localID, localID+1, localID+2);
}