Added multi triangle support

This commit is contained in:
Pasha Bibko
2025-11-19 22:58:48 +00:00
parent 36fbbefe55
commit ff7f3e86ee
9 changed files with 341 additions and 151 deletions

View File

@@ -4,9 +4,16 @@
namespace PB::Renderer
{
struct Vertex2D
{
float x, y;
};
class VulkanManager
{
public:
// === Public functions === //
/* Static class so (de)constructors have been deleted to stop accidental creation */
VulkanManager() = delete;
~VulkanManager() = delete;
@@ -88,9 +95,22 @@ namespace PB::Renderer
*/
static bool RenderPass(GLFWwindow* window);
static void CreateNewRenderObject(const std::vector<float>& vertices, const std::vector<uint32_t>& indices);
private:
// === Internal helper structs === //
struct RenderObject
{
VkBuffer VertexBuffer;
VkDeviceMemory VertexBufferMemory;
VkBuffer IndexBuffer;
VkDeviceMemory IndexBufferMemory;
uint32_t IndexCount;
};
struct QueueFamilyIndices
{
static constexpr uint32_t UNDEFINED_UINT32_VALUE = 0xFFFFFFFF;
@@ -113,6 +133,13 @@ namespace PB::Renderer
std::vector<VkPresentModeKHR> presentModes;
};
struct BufferCreationInfo
{
VkDeviceSize size;
VkBufferUsageFlags usage;
VkMemoryPropertyFlags properties;
};
// === Vulkan init helpers === //
static bool IsDeviceSuitable(const VkPhysicalDevice& device);
@@ -132,6 +159,14 @@ namespace PB::Renderer
static void RecreateSwapChain(GLFWwindow* window);
static void CleanupSwapChain();
static VkResult RecordCommandBuffer(uint32_t imageIndex);
static uint32_t FindMemoryType(uint32_t typeFilter, VkMemoryPropertyFlags properties);
static void CreateBuffer(VkBuffer& buffer, VkDeviceMemory& memory, const BufferCreationInfo& info);
// === Custom resources === //
static std::vector<RenderObject> s_RenderObjects;
// === Vulkan resources === //