Changeset 0fe8433 in opengl-game for vulkan-game.hpp
- Timestamp:
- Dec 24, 2019, 2:57:03 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 3e8cc8b
- Parents:
- cd1cb0f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.hpp
rcd1cb0f r0fe8433 40 40 }; 41 41 42 // TODO: Change the index type to uint32_t and check the Vulkan Tutorial loading model section as a reference 43 // TODO: Create a typedef for index type so I can easily change uin16_t to something else later 44 template<class VertexType> 45 struct SceneObject { 46 vector<VertexType> vertices; 47 vector<uint16_t> indices; 48 49 mat4 model_base; 50 mat4 model_transform; 51 }; 52 42 53 struct UBO_VP_mats { 43 54 alignas(16) mat4 view; … … 65 76 vec3 cam_pos; 66 77 67 UBO_VP_mats object_VP_mats;68 SBO_SceneObject so_Object;69 70 UBO_VP_mats ship_VP_mats;71 SBO_SceneObject so_Ship;72 73 78 GameGui* gui; 74 75 GraphicsPipeline_Vulkan<ModelVertex> modelPipeline;76 GraphicsPipeline_Vulkan<OverlayVertex> overlayPipeline;77 GraphicsPipeline_Vulkan<ShipVertex> shipPipeline;78 79 79 80 SDL_version sdlVersion; … … 107 108 VkSampler textureSampler; 108 109 109 // TODO: I should probably rename the uniformBuffer* and storageBuffer*110 // variables to better reflect the data they hold111 112 vector<VkBuffer> uniformBuffers_scenePipeline;113 vector<VkDeviceMemory> uniformBuffersMemory_scenePipeline;114 115 vector<VkDescriptorBufferInfo> uniformBufferInfoList_scenePipeline;116 117 vector<VkBuffer> storageBuffers_scenePipeline;118 vector<VkDeviceMemory> storageBuffersMemory_scenePipeline;119 120 vector<VkDescriptorBufferInfo> storageBufferInfoList_scenePipeline;121 122 vector<VkBuffer> uniformBuffers_shipPipeline;123 vector<VkDeviceMemory> uniformBuffersMemory_shipPipeline;124 125 vector<VkDescriptorBufferInfo> uniformBufferInfoList_shipPipeline;126 127 vector<VkBuffer> storageBuffers_shipPipeline;128 vector<VkDeviceMemory> storageBuffersMemory_shipPipeline;129 130 vector<VkDescriptorBufferInfo> storageBufferInfoList_shipPipeline;131 132 110 VulkanImage floorTextureImage; 133 111 VkDescriptorImageInfo floorTextureImageDescriptor; … … 148 126 149 127 bool framebufferResized; 128 129 // TODO: I should probably rename the uniformBuffer* and storageBuffer* 130 // variables to better reflect the data they hold 131 132 GraphicsPipeline_Vulkan<OverlayVertex> overlayPipeline; 133 134 vector<SceneObject<OverlayVertex>> overlayObjects; 135 136 // TODO: Rename all the variables related to modelPipeline to use the same pipelie name 137 138 GraphicsPipeline_Vulkan<ModelVertex> modelPipeline; 139 140 vector<SceneObject<ModelVertex>> modelObjects; 141 142 vector<VkBuffer> uniformBuffers_scenePipeline; 143 vector<VkDeviceMemory> uniformBuffersMemory_scenePipeline; 144 145 vector<VkDescriptorBufferInfo> uniformBufferInfoList_scenePipeline; 146 147 vector<VkBuffer> storageBuffers_scenePipeline; 148 vector<VkDeviceMemory> storageBuffersMemory_scenePipeline; 149 150 vector<VkDescriptorBufferInfo> storageBufferInfoList_scenePipeline; 151 152 UBO_VP_mats object_VP_mats; 153 SBO_SceneObject so_Object; 154 155 GraphicsPipeline_Vulkan<ShipVertex> shipPipeline; 156 157 vector<SceneObject<ShipVertex>> shipObjects; 158 159 vector<VkBuffer> uniformBuffers_shipPipeline; 160 vector<VkDeviceMemory> uniformBuffersMemory_shipPipeline; 161 162 vector<VkDescriptorBufferInfo> uniformBufferInfoList_shipPipeline; 163 164 vector<VkBuffer> storageBuffers_shipPipeline; 165 vector<VkDeviceMemory> storageBuffersMemory_shipPipeline; 166 167 vector<VkDescriptorBufferInfo> storageBufferInfoList_shipPipeline; 168 169 UBO_VP_mats ship_VP_mats; 170 SBO_SceneObject so_Ship; 150 171 151 172 bool initWindow(int width, int height, unsigned char guiFlags); … … 181 202 182 203 template<class VertexType> 204 void addObject(vector<SceneObject<VertexType>>& objects, GraphicsPipeline_Vulkan<VertexType>& pipeline, 205 const vector<VertexType>& vertices, vector<uint16_t> indices); 206 207 template<class VertexType> 183 208 vector<VertexType> addVertexNormals(vector<VertexType> vertices); 184 209 … … 205 230 void* pUserData); 206 231 }; 232 233 template<class VertexType> 234 void VulkanGame::addObject(vector<SceneObject<VertexType>>& objects, GraphicsPipeline_Vulkan<VertexType>& pipeline, 235 const vector<VertexType>& vertices, vector<uint16_t> indices) { 236 size_t numVertices = pipeline.getNumVertices(); 237 238 for (uint16_t& idx : indices) { 239 idx += numVertices; 240 } 241 242 objects.push_back({ vertices, indices, mat4(1.0f), mat4(1.0f) }); 243 244 pipeline.addVertices(vertices, indices, commandPool, graphicsQueue); 245 } 207 246 208 247 template<class VertexType>
Note:
See TracChangeset
for help on using the changeset viewer.