编写完顶点渲染程序,先保存一下

This commit is contained in:
xsl
2025-10-19 19:49:27 +08:00
parent 572c53c0f4
commit 3c63027bf5
32 changed files with 2714 additions and 6225 deletions
+38 -5
View File
@@ -2,7 +2,8 @@
#define __FaceApp_H__
#include "Application.h"
#include "vma/include/vk_mem_alloc.h"
#include <map>
struct TextureLoadingVertexStructure
@@ -24,16 +25,48 @@ public:
void initVulkan() override;
void render(VkCommandBuffer commandBuffer) override;
static FaceApp* Get() { return faceIns; }
void update_face_vertex_buffer(float* pos, int pointCount);
private:
void generate_quad();
static FaceApp* faceIns;
VmaAllocator allocator = nullptr;
bool LoadOBJ(const std::string& filename,
std::vector<TextureLoadingVertexStructure>& vertices,
std::vector<uint32_t>& indices);
void createVertexBuffer();
void uploadVertexData();
void copyBuffer(VkBuffer srcBuffer, VkBuffer dstBuffer, VkDeviceSize size);
VkCommandBuffer beginSingleTimeCommands();
void endSingleTimeCommands(VkCommandBuffer commandBuffer);
// 顶点缓冲区相关
VkBuffer m_vertexBuffer = VK_NULL_HANDLE;
VmaAllocation m_vertexBufferAllocation = VK_NULL_HANDLE;
VkBuffer m_stagingBuffer = VK_NULL_HANDLE;
VmaAllocation m_stagingBufferAllocation = VK_NULL_HANDLE;
// 索引缓冲区相关
VkBuffer m_indexBuffer = VK_NULL_HANDLE;
VmaAllocation m_indexBufferAllocation = VK_NULL_HANDLE;
// 渲染管线和描述符
VkPipeline m_graphicsPipeline = VK_NULL_HANDLE;
VkPipelineLayout m_pipelineLayout = VK_NULL_HANDLE;
VkDescriptorSetLayout m_descriptorSetLayout = VK_NULL_HANDLE;
std::unique_ptr<vkb::core::BufferC> vertex_buffer;
std::unique_ptr<vkb::core::BufferC> index_buffer;
uint32_t index_count;
std::vector<TextureLoadingVertexStructure> obj_vertices;
std::vector<uint32_t> obj_indices;
std::map<int, int> obj_vertices_map;
std::map<int, int> vertices_map_3dmax;
std::mutex mtx_point;
long long last_update_time;
};
#endif