Changeset 2d87297 in opengl-game for vulkan-game.hpp
- Timestamp:
- Feb 16, 2020, 8:22:40 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- d25381b
- Parents:
- 5a1ace0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.hpp
r5a1ace0 r2d87297 50 50 // TODO: Change the index type to uint32_t and check the Vulkan Tutorial loading model section as a reference 51 51 // TODO: Create a typedef for index type so I can easily change uin16_t to something else later 52 template<class VertexType >52 template<class VertexType, class SSBOType> 53 53 struct SceneObject { 54 54 vector<VertexType> vertices; 55 55 vector<uint16_t> indices; 56 SSBOType ssbo; 56 57 57 58 mat4 model_base; … … 64 65 }; 65 66 66 struct S BO_SceneObject {67 struct SSBO_ModelObject { 67 68 alignas(16) mat4 model; 68 69 }; 69 70 70 struct S BO_Asteroid {71 struct SSBO_Asteroid { 71 72 alignas(16) mat4 model; 72 73 alignas(4) float hp; … … 146 147 // TODO: Create a struct that holds the buffers, memory, and info objects (Probably in VulkanUtils) 147 148 148 GraphicsPipeline_Vulkan<OverlayVertex > overlayPipeline;149 150 vector<SceneObject<OverlayVertex >> overlayObjects;149 GraphicsPipeline_Vulkan<OverlayVertex, void*> overlayPipeline; 150 151 vector<SceneObject<OverlayVertex, void*>> overlayObjects; 151 152 152 153 // TODO: Rename all the variables related to modelPipeline to use the same pipelie name 153 154 154 GraphicsPipeline_Vulkan<ModelVertex > modelPipeline;155 156 vector<SceneObject<ModelVertex >> modelObjects;155 GraphicsPipeline_Vulkan<ModelVertex, SSBO_ModelObject> modelPipeline; 156 157 vector<SceneObject<ModelVertex, SSBO_ModelObject>> modelObjects; 157 158 158 159 vector<VkBuffer> uniformBuffers_scenePipeline; … … 165 166 166 167 UBO_VP_mats object_VP_mats; 167 S BO_SceneObject so_Object;168 169 GraphicsPipeline_Vulkan<ShipVertex > shipPipeline;170 171 vector<SceneObject<ShipVertex >> shipObjects;168 SSBO_ModelObject so_Object; 169 170 GraphicsPipeline_Vulkan<ShipVertex, SSBO_ModelObject> shipPipeline; 171 172 vector<SceneObject<ShipVertex, SSBO_ModelObject>> shipObjects; 172 173 173 174 vector<VkBuffer> uniformBuffers_shipPipeline; … … 180 181 181 182 UBO_VP_mats ship_VP_mats; 182 S BO_SceneObject so_Ship;183 184 GraphicsPipeline_Vulkan<AsteroidVertex > asteroidPipeline;185 186 vector<SceneObject<AsteroidVertex >> asteroidObjects;183 SSBO_ModelObject so_Ship; 184 185 GraphicsPipeline_Vulkan<AsteroidVertex, SSBO_Asteroid> asteroidPipeline; 186 187 vector<SceneObject<AsteroidVertex, SSBO_Asteroid>> asteroidObjects; 187 188 188 189 vector<VkBuffer> uniformBuffers_asteroidPipeline; … … 195 196 196 197 UBO_VP_mats asteroid_VP_mats; 197 S BO_Asteroid so_Asteroid;198 SSBO_Asteroid so_Asteroid; 198 199 199 200 Uint64 curTime, prevTime; … … 231 232 void createSyncObjects(); 232 233 233 template<class VertexType> 234 void addObject(vector<SceneObject<VertexType>>& objects, GraphicsPipeline_Vulkan<VertexType>& pipeline, 235 const vector<VertexType>& vertices, vector<uint16_t> indices); 234 template<class VertexType, class SSBOType> 235 void addObject(vector<SceneObject<VertexType, SSBOType>>& objects, 236 GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline, 237 const vector<VertexType>& vertices, vector<uint16_t> indices, SSBOType ssbo); 236 238 237 239 template<class VertexType> … … 244 246 vector<VertexType> centerObject(vector<VertexType> vertices); 245 247 246 template<class VertexType >247 void transformObject(SceneObject<VertexType >& obj, mat4 mat);248 template<class VertexType, class SSBOType> 249 void transformObject(SceneObject<VertexType, SSBOType>& obj, mat4 mat); 248 250 249 251 void createBufferSet(VkDeviceSize bufferSize, VkBufferUsageFlags flags, … … 261 263 }; 262 264 263 template<class VertexType> 264 void VulkanGame::addObject(vector<SceneObject<VertexType>>& objects, GraphicsPipeline_Vulkan<VertexType>& pipeline, 265 const vector<VertexType>& vertices, vector<uint16_t> indices) { 265 template<class VertexType, class SSBOType> 266 void VulkanGame::addObject(vector<SceneObject<VertexType, SSBOType>>& objects, 267 GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline, 268 const vector<VertexType>& vertices, vector<uint16_t> indices, SSBOType ssbo) { 266 269 size_t numVertices = pipeline.getNumVertices(); 267 270 … … 270 273 } 271 274 272 objects.push_back({ vertices, indices, mat4(1.0f), mat4(1.0f) });275 objects.push_back({ vertices, indices, ssbo, mat4(1.0f), mat4(1.0f) }); 273 276 274 277 pipeline.addVertices(vertices, indices, commandPool, graphicsQueue); … … 341 344 } 342 345 343 template<class VertexType >344 void VulkanGame::transformObject(SceneObject<VertexType >& obj, mat4 mat) {346 template<class VertexType, class SSBOType> 347 void VulkanGame::transformObject(SceneObject<VertexType, SSBOType>& obj, mat4 mat) { 345 348 obj.model_transform = mat * obj.model_transform; 346 349 }
Note:
See TracChangeset
for help on using the changeset viewer.