Changeset 4994692 in opengl-game for vulkan-game.hpp
- Timestamp:
- Apr 19, 2020, 1:23:02 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 5ba732a
- Parents:
- 6385d0f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.hpp
r6385d0f r4994692 51 51 }; 52 52 53 struct UBO_VP_mats { 54 alignas(16) mat4 view; 55 alignas(16) mat4 proj; 56 }; 57 58 struct SSBO_ModelObject { 59 alignas(16) mat4 model; 60 }; 61 62 struct SSBO_Asteroid { 63 alignas(16) mat4 model; 64 alignas(4) float hp; 65 alignas(4) unsigned int deleted; 66 }; 67 53 68 // TODO: Change the index type to uint32_t and check the Vulkan Tutorial loading model section as a reference 54 69 // TODO: Create a typedef for index type so I can easily change uin16_t to something else later 70 // TODO: Maybe create a typedef for each of the templated SceneObject types 55 71 template<class VertexType, class SSBOType> 56 72 struct SceneObject { … … 61 77 mat4 model_base; 62 78 mat4 model_transform; 79 80 // TODO: Figure out if I should make child classes that have these fields instead of putting them in the 81 // parent class 63 82 vec3 center; // currently only matters for asteroids 64 83 float radius; // currently only matters for asteroids 65 84 }; 66 85 67 struct UBO_VP_mats { 68 alignas(16) mat4 view; 69 alignas(16) mat4 proj; 70 }; 71 72 struct SSBO_ModelObject { 73 alignas(16) mat4 model; 74 }; 75 76 struct SSBO_Asteroid { 77 alignas(16) mat4 model; 78 alignas(4) float hp; 79 alignas(4) unsigned int deleted; 80 }; 81 82 // Have to figure out how to include an optional ssbo parameter for each object 86 // TODO: Have to figure out how to include an optional ssbo parameter for each object 83 87 // Could probably use the same approach to make indices optional 88 // Figure out if there are sufficient use cases to make either of these optional or is it fine to make 89 // them mamdatory 84 90 85 91 class VulkanGame { … … 131 137 VkSampler textureSampler; 132 138 139 VulkanImage sdlOverlayImage; 140 VkDescriptorImageInfo sdlOverlayImageDescriptor; 141 133 142 VulkanImage floorTextureImage; 134 143 VkDescriptorImageInfo floorTextureImageDescriptor; 135 136 VulkanImage sdlOverlayImage;137 VkDescriptorImageInfo sdlOverlayImageDescriptor;138 144 139 145 TTF_Font* font; … … 230 236 void createSyncObjects(); 231 237 238 // TODO: Since addObject() returns a reference to the new object now, 239 // stop using objects.back() to access the object that was just created 232 240 template<class VertexType, class SSBOType> 233 void addObject(vector<SceneObject<VertexType, SSBOType>>& objects, 234 GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline, 235 const vector<VertexType>& vertices, vector<uint16_t> indices, SSBOType ssbo, 236 bool pipelinesCreated); 241 SceneObject<VertexType, SSBOType>& addObject( 242 vector<SceneObject<VertexType, SSBOType>>& objects, 243 GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline, 244 const vector<VertexType>& vertices, vector<uint16_t> indices, SSBOType ssbo, 245 bool pipelinesCreated); 237 246 238 247 template<class VertexType, class SSBOType> 239 248 void updateObject(vector<SceneObject<VertexType, SSBOType>>& objects, 240 GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline, size_t index);249 GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline, size_t index); 241 250 242 251 template<class VertexType> … … 250 259 251 260 void createBufferSet(VkDeviceSize bufferSize, VkBufferUsageFlags flags, 252 vector<VkBuffer>& buffers, vector<VkDeviceMemory>& buffersMemory, vector<VkDescriptorBufferInfo>& bufferInfoList); 261 vector<VkBuffer>& buffers, vector<VkDeviceMemory>& buffersMemory, 262 vector<VkDescriptorBufferInfo>& bufferInfoList); 253 263 254 264 void recreateSwapChain(); … … 272 282 // to account for scaling 273 283 template<class VertexType, class SSBOType> 274 void VulkanGame::addObject(vector<SceneObject<VertexType, SSBOType>>& objects, 284 SceneObject<VertexType, SSBOType>& VulkanGame::addObject( 285 vector<SceneObject<VertexType, SSBOType>>& objects, 275 286 GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline, 276 287 const vector<VertexType>& vertices, vector<uint16_t> indices, SSBOType ssbo, … … 289 300 centerObject(obj); 290 301 291 bool storageBufferResized = pipeline.addObject(obj.vertices, obj.indices, obj.ssbo, commandPool, graphicsQueue); 302 bool storageBufferResized = pipeline.addObject(obj.vertices, obj.indices, obj.ssbo, 303 this->commandPool, this->graphicsQueue); 292 304 293 305 if (pipelinesCreated) { … … 307 319 createCommandBuffers(); 308 320 } 321 322 return obj; 309 323 } 310 324
Note:
See TracChangeset
for help on using the changeset viewer.