Changeset 5a0242e in opengl-game for vulkan-game.cpp
- Timestamp:
- Nov 17, 2019, 6:56:16 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 5ab1b20
- Parents:
- b8777b7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
rb8777b7 r5a0242e 194 194 createUniformBuffers(); 195 195 196 vector<ModelVertex> sceneVertices = {197 {{-0.5f, -0.5f, -2.0f}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}},198 {{ 0.5f, -0.5f, -2.0f}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},199 {{ 0.5f, 0.5f, -2.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},200 {{-0.5f, 0.5f, -2.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}},201 202 {{-0.5f, -0.5f, -1.5f}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}},203 {{ 0.5f, -0.5f, -1.5f}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},204 {{ 0.5f, 0.5f, -1.5f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},205 {{-0.5f, 0.5f, -1.5f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}}206 };207 vector<uint16_t> sceneIndices = {208 0, 1, 2, 2, 3, 0,209 4, 5, 6, 6, 7, 4210 };211 212 196 modelPipeline = GraphicsPipeline_Vulkan<ModelVertex>(physicalDevice, device, renderPass, 213 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, sizeof(ModelVertex)); 214 215 modelPipeline.bindData(sceneVertices, sceneIndices, commandPool, graphicsQueue); 197 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, 16, 24); 198 199 modelPipeline.addObject({ 200 {{-0.5f, -0.5f, -2.0f}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}}, 201 {{ 0.5f, -0.5f, -2.0f}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}}, 202 {{ 0.5f, 0.5f, -2.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}}, 203 {{-0.5f, 0.5f, -2.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}} 204 }, { 205 0, 1, 2, 2, 3, 0 206 }, commandPool, graphicsQueue); 207 208 modelPipeline.addObject({ 209 {{-0.5f, -0.5f, -1.5f}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}}, 210 {{ 0.5f, -0.5f, -1.5f}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}}, 211 {{ 0.5f, 0.5f, -1.5f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}}, 212 {{-0.5f, 0.5f, -1.5f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}} 213 }, { 214 0, 1, 2, 2, 3, 0 215 }, commandPool, graphicsQueue); 216 216 217 217 modelPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&ModelVertex::pos)); … … 229 229 modelPipeline.createDescriptorSets(swapChainImages); 230 230 231 vector<OverlayVertex> overlayVertices = {232 {{-1.0f, 1.0f, 0.0f}, {0.0f, 1.0f}},233 {{ 1.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},234 {{ 1.0f, -1.0f, 0.0f}, {1.0f, 0.0f}},235 {{-1.0f, -1.0f, 0.0f}, {0.0f, 0.0f}}236 };237 vector<uint16_t> overlayIndices = {238 0, 1, 2, 2, 3, 0239 };240 241 231 overlayPipeline = GraphicsPipeline_Vulkan<OverlayVertex>(physicalDevice, device, renderPass, 242 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, sizeof(OverlayVertex)); 243 244 overlayPipeline.bindData(overlayVertices, overlayIndices, commandPool, graphicsQueue); 232 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, 4, 6); 233 234 overlayPipeline.addObject({ 235 {{-1.0f, 1.0f, 0.0f}, {0.0f, 1.0f}}, 236 {{ 1.0f, 1.0f, 0.0f}, {1.0f, 1.0f}}, 237 {{ 1.0f, -1.0f, 0.0f}, {1.0f, 0.0f}}, 238 {{-1.0f, -1.0f, 0.0f}, {0.0f, 0.0f}} 239 }, { 240 0, 1, 2, 2, 3, 0 241 }, commandPool, graphicsQueue); 245 242 246 243 overlayPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&OverlayVertex::pos)); … … 291 288 cout << "Adding a plane" << endl; 292 289 float zOffset = -2.0f + (0.5f * numPlanes); 293 vector<ModelVertex> vertices = { 290 291 vkDeviceWaitIdle(device); 292 vkFreeCommandBuffers(device, commandPool, static_cast<uint32_t>(commandBuffers.size()), commandBuffers.data()); 293 294 modelPipeline.addObject({ 294 295 {{-0.5f, -0.5f, zOffset}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}}, 295 296 {{ 0.5f, -0.5f, zOffset}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}}, 296 297 {{ 0.5f, 0.5f, zOffset}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}}, 297 298 {{-0.5f, 0.5f, zOffset}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}} 298 }; 299 vector<uint16_t> indices = { 299 }, { 300 300 0, 1, 2, 2, 3, 0 301 }; 302 303 // TODO: Encapsulate these lines into an addObject() function in vulkan-game 304 305 vkDeviceWaitIdle(device); 306 vkFreeCommandBuffers(device, commandPool, static_cast<uint32_t>(commandBuffers.size()), commandBuffers.data()); 307 308 modelPipeline.addObject(vertices, indices, commandPool, graphicsQueue); 301 }, commandPool, graphicsQueue); 309 302 310 303 createCommandBuffers(); … … 314 307 cout << "Key event detected" << endl; 315 308 } 309 break; 310 case UI_EVENT_KEYUP: 316 311 break; 317 312 case UI_EVENT_MOUSEBUTTONDOWN:
Note:
See TracChangeset
for help on using the changeset viewer.