Changeset 0fe8433 in opengl-game for graphics-pipeline_vulkan.hpp


Ignore:
Timestamp:
Dec 24, 2019, 2:57:03 AM (5 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
3e8cc8b
Parents:
cd1cb0f
Message:

Create an addObject() method in VulkanGame (which wraps the old addObject() method in GraphicsPipeline_Vulkan), and move the list of objects and other code to manage objects from the pipeline to the VulkanGame class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • graphics-pipeline_vulkan.hpp

    rcd1cb0f r0fe8433  
    2929   vector<VkDescriptorBufferInfo>* bufferDataList;
    3030   VkDescriptorImageInfo* imageData;
    31 };
    32 
    33 // TODO: Change the index type to uint32_t and check the Vulkan Tutorial loading model section as a reference
    34 // TODO: Create a typedef for index type so I can easily change uin16_t to something else later
    35 template<class VertexType>
    36 struct SceneObject {
    37    vector<VertexType> vertices;
    38    vector<uint16_t> indices;
    39 
    40    mat4 model_base;
    41    mat4 model_transform;
    4231};
    4332
     
    5039      ~GraphicsPipeline_Vulkan();
    5140
     41      size_t getNumVertices();
     42
    5243      void updateRenderPass(VkRenderPass renderPass);
    5344
     
    6657      void createRenderCommands(VkCommandBuffer& commandBuffer, uint32_t currentImage);
    6758
    68       vector<SceneObject<VertexType>>& getObjects();
    69       void addObject(const vector<VertexType>& vertices, vector<uint16_t> indices, VkCommandPool commandPool,
     59      void addVertices(const vector<VertexType>& vertices, vector<uint16_t> indices, VkCommandPool commandPool,
    7060         VkQueue graphicsQueue);
    7161
     
    10090      VkDeviceMemory indexBufferMemory;
    10191
    102       // TODO: The objects vector isn't used at all in this class, except in the method that returns
    103       // the number of objects. Move this vector and the SceneObject declaration into VulkanGame, esp.
    104       // since I'll be adding other object-specific fields such as transforms to SceneObject later
    105       vector<SceneObject<VertexType>> objects;
    106 
    10792      VkShaderModule createShaderModule(const vector<char>& code);
    10893      vector<char> readFile(const string& filename);
     
    151136template<class VertexType>
    152137GraphicsPipeline_Vulkan<VertexType>::~GraphicsPipeline_Vulkan() {
     138}
     139
     140template<class VertexType>
     141size_t GraphicsPipeline_Vulkan<VertexType>::getNumVertices() {
     142   return numVertices;
    153143}
    154144
     
    422412
    423413template<class VertexType>
    424 vector<SceneObject<VertexType>>& GraphicsPipeline_Vulkan<VertexType>::getObjects() {
    425    return objects;
    426 }
    427 
    428 template<class VertexType>
    429 void GraphicsPipeline_Vulkan<VertexType>::addObject(const vector<VertexType>& vertices, vector<uint16_t> indices,
     414void GraphicsPipeline_Vulkan<VertexType>::addVertices(const vector<VertexType>& vertices, vector<uint16_t> indices,
    430415      VkCommandPool commandPool, VkQueue graphicsQueue) {
    431416
     
    436421      resizeIndexBuffer(commandPool, graphicsQueue);
    437422   }
    438 
    439    for (uint16_t& idx : indices) {
    440       idx += numVertices;
    441    }
    442    objects.push_back({ vertices, indices, mat4(1.0f), mat4(1.0f) });
    443423
    444424   VulkanUtils::copyDataToBuffer(device, physicalDevice, commandPool, vertices, vertexBuffer, numVertices,
Note: See TracChangeset for help on using the changeset viewer.