Changeset e3bef3a in opengl-game for vulkan-game.cpp


Ignore:
Timestamp:
Nov 12, 2019, 6:55:07 AM (5 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
cd487fb
Parents:
5a23277
Message:

Finish the rewrite of the original vulkangame project

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.cpp

    r5a23277 re3bef3a  
    254254
    255255   cout << "Created " << graphicsPipelines.size() << " graphics pipelines" << endl;
     256
     257   numPlanes = 2;
    256258
    257259   createCommandBuffers();
     
    281283               framebufferResized = true;
    282284               break;
    283             case UI_EVENT_KEY:
     285            case UI_EVENT_KEYDOWN:
    284286               if (e.key.keycode == SDL_SCANCODE_ESCAPE) {
    285287                  quit = true;
     288               } else if (e.key.keycode == SDL_SCANCODE_SPACE) {
     289                  cout << "Adding a plane" << endl;
     290                  float zOffset = -0.5f + (0.5f * numPlanes);
     291                  vector<Vertex> vertices = {
     292                     {{-0.5f, -0.5f,  zOffset}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}},
     293                     {{ 0.5f, -0.5f,  zOffset}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},
     294                     {{ 0.5f,  0.5f,  zOffset}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
     295                     {{-0.5f,  0.5f,  zOffset}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}}
     296                  };
     297                  vector<uint16_t> indices = {
     298                     0, 1, 2, 2, 3, 0
     299                  };
     300
     301                  if (graphicsPipelines[0].addObject(vertices, indices, commandPool, graphicsQueue)) {
     302                     vkFreeCommandBuffers(device, commandPool, static_cast<uint32_t>(commandBuffers.size()), commandBuffers.data());
     303                     createCommandBuffers();
     304
     305                     numPlanes++;
     306                  }
    286307               } else {
    287308                  cout << "Key event detected" << endl;
     
    943964}
    944965
     966// TODO: Fix the crash that happens when alt-tabbing
    945967void VulkanGame::recreateSwapChain() {
    946968   cout << "Recreating swap chain" << endl;
Note: See TracChangeset for help on using the changeset viewer.