Add RenderEngineSDK
This commit is contained in:
@@ -12,13 +12,6 @@
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include <assert.h>
|
||||
#define VK_CHECK(res) assert(res == VK_SUCCESS)
|
||||
#else
|
||||
#define VK_CHECK(res) if ((res) != VK_SUCCESS) throw std::runtime_error("Vulkan error: " + std::to_string(res))
|
||||
#endif
|
||||
|
||||
class UwURenderEngine : public RenderEngineBase
|
||||
{
|
||||
struct QueueFamilyIndices
|
||||
@@ -33,20 +26,13 @@ class UwURenderEngine : public RenderEngineBase
|
||||
std::vector<VkSurfaceFormatKHR> formats;
|
||||
std::vector<VkPresentModeKHR> present_modes;
|
||||
};
|
||||
struct Vertex
|
||||
{
|
||||
glm::vec3 pos;
|
||||
glm::vec3 color;
|
||||
static VkVertexInputBindingDescription get_binding_description();
|
||||
static std::array<VkVertexInputAttributeDescription, 2> get_vertex_attribute_descriptions();
|
||||
};
|
||||
struct UniformBufferObject {
|
||||
glm::mat4 model;
|
||||
glm::mat4 view;
|
||||
glm::mat4 proj;
|
||||
};
|
||||
|
||||
const std::vector<Vertex> vertices_ = {
|
||||
const std::vector<ModelManager::Vertex> vertices_ = {
|
||||
{{-0.5f, -0.5f, 0.5f}, {1.0f, 0.0f, 0.0f}},
|
||||
{{0.5f, -0.5f, 0.5f}, {0.0f, 1.0f, 0.0f}},
|
||||
{{0.5f, 0.5f, 0.5f}, {0.0f, 0.0f, 1.0f}},
|
||||
@@ -117,13 +103,8 @@ class UwURenderEngine : public RenderEngineBase
|
||||
static QueueFamilyIndices find_queue_family_indices(VkPhysicalDevice physical_device, VkSurfaceKHR surface);
|
||||
static VkSurfaceFormatKHR choose_surface_format(const std::vector<VkSurfaceFormatKHR>& surface_formats);
|
||||
static VkPresentModeKHR choose_present_mode(const std::vector<VkPresentModeKHR>& present_modes, VkPresentModeKHR desired_present_mode);
|
||||
static VkExtent2D choose_extent(const VkSurfaceCapabilitiesKHR& capabilities, GLFWwindow* window);
|
||||
VkShaderModule create_shader_module(const std::string& code) const;
|
||||
void create_buffer(VkDeviceSize size, VkBufferUsageFlags usage,
|
||||
VkBuffer* buffer, const std::vector<uint32_t>& queue_families);
|
||||
void allocate_memory(VkBuffer buffer, VkMemoryPropertyFlags property, VkDeviceMemory* device_memory);
|
||||
uint32_t find_memory_type(uint32_t typeFilter, VkMemoryPropertyFlags properties) const;
|
||||
std::vector<uint32_t> get_unique_family_indices(const QueueFamilyIndices& indices);
|
||||
static std::vector<uint32_t> get_unique_family_indices(const QueueFamilyIndices& indices);
|
||||
|
||||
void create_instance();
|
||||
void create_surface();
|
||||
@@ -144,7 +125,6 @@ class UwURenderEngine : public RenderEngineBase
|
||||
void allocate_vertex_buffer();
|
||||
void allocate_index_buffer();
|
||||
|
||||
void copy_memory(VkBuffer src, VkBuffer dst, VkDeviceSize size);
|
||||
void record_command_buffer(VkCommandBuffer command_buffer, uint32_t image_index) const;
|
||||
void update_uniform_buffer(uint32_t current_frame);
|
||||
void draw_frame();
|
||||
|
||||
Reference in New Issue
Block a user