/* 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 */ #include #include #include #include #include #include "VulkanInitializers.hpp" import Crafter.Graphics; import Crafter.Asset; import Crafter.Event; import Crafter.Math; using namespace Crafter; typedef VulkanShader<"MeshShaderHeightmapRGBA.spirv", "main", VK_SHADER_STAGE_MESH_BIT_EXT, 2, {{{VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0}, {VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1}}}> MeshVulkanShader; typedef VulkanShader<"FragmentShaderVertexColor.spirv", "main", VK_SHADER_STAGE_FRAGMENT_BIT, 0, {}> FragmentShader; typedef VulkanPipeline Pipeline; int main() { VulkanDevice::CreateDevice(); MeshVulkanShader::CreateShader(); FragmentShader::CreateShader(); Pipeline::CreatePipeline(); WindowWaylandVulkan window("Crafter.Graphics", 1280, 720); Camera camera(1.57079633, 1280.0f / 720.0f, 0.01, 512); camera.view = MatrixRowMajor::Translation(0, 2, -10); camera.Update(); VkCommandBuffer cmd = window.StartInit(); DescriptorSet descriptors; HeightmapShader meshShader(4, 4, 1, &camera); for(uint32_t i = 0; i < 1*1*4*64; i++) { meshShader.heights.value[i].height = -0.5; meshShader.heights.value[i].r = 255; meshShader.heights.value[i].g = 255; meshShader.heights.value[i].b = 255; meshShader.heights.value[i].a = 255; } meshShader.WriteDescriptors(descriptors.set[0]); meshShader.Update(); window.FinishInit(); EventListener listener(&window.onDraw, [&descriptors, &meshShader](VkCommandBuffer cmd){ vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, Pipeline::pipelineLayout, 0, 2, &descriptors.set[0], 0, NULL); vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, Pipeline::pipeline); VulkanDevice::vkCmdDrawMeshTasksEXTProc(cmd, meshShader.threadCount, 1, 1); }); window.Start(); while(true) { } }