Changeset 1abebc1 in opengl-game for sdl-game.hpp
- Timestamp:
- May 19, 2021, 4:49:43 PM (4 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- c163d81
- Parents:
- a3cefaa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sdl-game.hpp
ra3cefaa r1abebc1 79 79 // has a VkBuffer, VkDeviceMemory, and VkDescriptorBufferInfo 80 80 // TODO: Maybe change the structure here since VkDescriptorBufferInfo already stores a reference to the VkBuffer 81 struct StorageBufferSet {81 struct BufferSet { 82 82 vector<VkBuffer> buffers; 83 83 vector<VkDeviceMemory> memory; … … 220 220 GraphicsPipeline_Vulkan<ModelVertex> modelPipeline; 221 221 222 StorageBufferSet storageBuffers_modelPipeline;222 BufferSet storageBuffers_modelPipeline; 223 223 VulkanBuffer<SSBO_ModelObject> objects_modelPipeline; 224 224 … … 299 299 // TODO: Remove the need for templating, which is only there so a GraphicsPupeline_Vulkan can be passed in 300 300 template<class VertexType, class SSBOType> 301 void resize StorageBufferSet(StorageBufferSet& set, VulkanBuffer<SSBOType>& buffer,302 GraphicsPipeline_Vulkan<VertexType>& pipeline,303 VkCommandPool commandPool,VkQueue graphicsQueue);301 void resizeBufferSet(BufferSet& set, VulkanBuffer<SSBOType>& buffer, 302 GraphicsPipeline_Vulkan<VertexType>& pipeline, VkCommandPool commandPool, 303 VkQueue graphicsQueue); 304 304 305 305 template<class SSBOType> 306 void update StorageBuffer(StorageBufferSet& storageBufferSet, size_t objIndex, SSBOType& ssbo);306 void updateBufferSet(BufferSet& set, size_t objIndex, SSBOType& ssbo); 307 307 308 308 // TODO: Since addObject() returns a reference to the new object now, … … 312 312 GraphicsPipeline_Vulkan<VertexType>& pipeline, 313 313 const vector<VertexType>& vertices, vector<uint16_t> indices, 314 SSBOType ssbo , StorageBufferSet& storageBuffers);314 SSBOType ssbo); 315 315 316 316 template<class VertexType> … … 324 324 325 325 template<class VertexType, class SSBOType> 326 void updateObject(vector<SceneObject<VertexType, SSBOType>>& objects, 327 GraphicsPipeline_Vulkan<VertexType>& pipeline, size_t index); 326 void updateObject(SceneObject<VertexType, SSBOType>& obj); 328 327 329 328 void renderFrame(ImDrawData* draw_data); … … 347 346 348 347 template<class VertexType, class SSBOType> 349 void VulkanGame::resize StorageBufferSet(StorageBufferSet& set, VulkanBuffer<SSBOType>& buffer,350 GraphicsPipeline_Vulkan<VertexType>& pipeline,351 VkCommandPool commandPool,VkQueue graphicsQueue) {348 void VulkanGame::resizeBufferSet(BufferSet& set, VulkanBuffer<SSBOType>& buffer, 349 GraphicsPipeline_Vulkan<VertexType>& pipeline, VkCommandPool commandPool, 350 VkQueue graphicsQueue) { 352 351 size_t numObjects = buffer.numObjects < buffer.capacity ? buffer.numObjects : buffer.capacity; 353 352 … … 388 387 // TODO: See if it makes sense to pass in the current swapchain index instead of updating all of them 389 388 template<class SSBOType> 390 void VulkanGame::update StorageBuffer(StorageBufferSet& storageBufferSet, size_t objIndex, SSBOType& ssbo) {391 for (size_t i = 0; i < s torageBufferSet.memory.size(); i++) {392 VulkanUtils::copyDataToMemory(device, ssbo, s torageBufferSet.memory[i], objIndex * sizeof(SSBOType));389 void VulkanGame::updateBufferSet(BufferSet& set, size_t objIndex, SSBOType& ssbo) { 390 for (size_t i = 0; i < set.memory.size(); i++) { 391 VulkanUtils::copyDataToMemory(device, ssbo, set.memory[i], objIndex * sizeof(SSBOType)); 393 392 } 394 393 } … … 401 400 GraphicsPipeline_Vulkan<VertexType>& pipeline, 402 401 const vector<VertexType>& vertices, vector<uint16_t> indices, 403 SSBOType ssbo , StorageBufferSet& storageBuffers) {402 SSBOType ssbo) { 404 403 // TODO: Use the model field of ssbo to set the object's model_base 405 404 // currently, the passed in model is useless since it gets overridden in updateObject() anyway … … 504 503 // TODO: Just pass in the single object instead of a list of all of them 505 504 template<class VertexType, class SSBOType> 506 void VulkanGame::updateObject(vector<SceneObject<VertexType, SSBOType>>& objects, 507 GraphicsPipeline_Vulkan<VertexType>& pipeline, size_t index) { 508 SceneObject<VertexType, SSBOType>& obj = objects[index]; 509 505 void VulkanGame::updateObject(SceneObject<VertexType, SSBOType>& obj) { 510 506 obj.ssbo.model = obj.model_transform * obj.model_base; 511 507 obj.center = vec3(obj.ssbo.model * vec4(0.0f, 0.0f, 0.0f, 1.0f));
Note:
See TracChangeset
for help on using the changeset viewer.