Changeset e3bef3a in opengl-game for graphics-pipeline_vulkan.hpp
- Timestamp:
- Nov 12, 2019, 6:55:07 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- cd487fb
- Parents:
- 5a23277
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
graphics-pipeline_vulkan.hpp
r5a23277 re3bef3a 4 4 #include "graphics-pipeline.hpp" 5 5 6 #include <iostream> 6 7 #include <vector> 7 8 8 9 #include <vulkan/vulkan.h> 10 11 #include "vulkan-utils.hpp" 12 13 using namespace std; 14 15 // TODO: Remove any instances of cout and instead throw exceptions 9 16 10 17 // TODO: Maybe change the name of this struct so I can call the list something other than descriptorInfoList … … 26 33 void updateRenderPass(VkRenderPass renderPass); 27 34 28 template<class VertexType , class IndexType>29 void bindData(const vector<VertexType>& vertices, const vector< IndexType>& indices,35 template<class VertexType> 36 void bindData(const vector<VertexType>& vertices, const vector<uint16_t>& indices, 30 37 VkCommandPool commandPool, VkQueue graphicsQueue); 31 38 … … 48 55 49 56 void createRenderCommands(VkCommandBuffer& commandBuffer, uint32_t currentImage); 57 58 template<class VertexType> 59 bool addObject(const vector<VertexType>& vertices, vector<uint16_t>& indices, VkCommandPool commandPool, 60 VkQueue graphicsQueue); 50 61 51 62 void cleanup(); … … 83 94 }; 84 95 85 // TODO: Probably better to template the whole class and to also combine this function 86 // and the constructor since I call this right after the constructor anyway 87 template<class VertexType, class IndexType> 88 void GraphicsPipeline_Vulkan::bindData(const vector<VertexType>& vertices, const vector<IndexType>& indices, 96 // TODO: Probably better to template the whole class 97 // TODO: Change the index type to uint32_t and check the Vulkan Tutorial loading model section as a reference 98 99 // TODO: combine this function and the constructor since I call this right after the constructor anyway 100 template<class VertexType> 101 void GraphicsPipeline_Vulkan::bindData(const vector<VertexType>& vertices, const vector<uint16_t>& indices, 89 102 VkCommandPool commandPool, VkQueue graphicsQueue) { 90 103 numVertices = vertices.size(); … … 94 107 numIndices = indices.size(); 95 108 indexCapacity = numIndices * 2; 96 createIndexBuffer(indices.data(), sizeof(IndexType), commandPool, graphicsQueue); 109 createIndexBuffer(indices.data(), sizeof(uint16_t), commandPool, graphicsQueue); 110 } 111 112 template<class VertexType> 113 bool GraphicsPipeline_Vulkan::addObject(const vector<VertexType>& vertices, vector<uint16_t>& indices, 114 VkCommandPool commandPool, VkQueue graphicsQueue) { 115 cout << "Adding object to pipeline..." << endl; 116 117 if (numVertices + vertices.size() > vertexCapacity) { 118 cout << "ERROR: Need to resize vertex buffers" << endl; 119 } else if (numIndices + indices.size() > indexCapacity) { 120 cout << "ERROR: Need to resize index buffers" << endl; 121 } else { 122 cout << "Added object to scene" << endl; 123 124 for (uint16_t& idx : indices) { 125 idx += numVertices; 126 } 127 128 VulkanUtils::copyDataToBuffer(device, physicalDevice, commandPool, vertices, vertexBuffer, numVertices, 129 graphicsQueue); 130 numVertices += vertices.size(); 131 132 VulkanUtils::copyDataToBuffer(device, physicalDevice, commandPool, indices, indexBuffer, numIndices, 133 graphicsQueue); 134 numIndices += indices.size(); 135 136 return true; 137 } 138 139 return false; 97 140 } 98 141
Note:
See TracChangeset
for help on using the changeset viewer.