Changeset 06d959f in opengl-game
- Timestamp:
- Nov 27, 2019, 5:19:23 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- e1308e8
- Parents:
- 0cf1a23
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
graphics-pipeline_vulkan.hpp
r0cf1a23 r06d959f 11 11 12 12 #include "vulkan-utils.hpp" 13 14 using namespace std;15 13 16 14 // TODO: Maybe change the name of this struct so I can call the list something other than descriptorInfoList … … 57 55 58 56 const vector<SceneObject<VertexType>>& getObjects(); 59 booladdObject(const vector<VertexType>& vertices, vector<uint16_t> indices, VkCommandPool commandPool,57 void addObject(const vector<VertexType>& vertices, vector<uint16_t> indices, VkCommandPool commandPool, 60 58 VkQueue graphicsQueue); 61 59 … … 413 411 414 412 template<class VertexType> 415 boolGraphicsPipeline_Vulkan<VertexType>::addObject(const vector<VertexType>& vertices, vector<uint16_t> indices,413 void GraphicsPipeline_Vulkan<VertexType>::addObject(const vector<VertexType>& vertices, vector<uint16_t> indices, 416 414 VkCommandPool commandPool, VkQueue graphicsQueue) { 417 415 … … 426 424 idx += numVertices; 427 425 } 428 objects.push_back({ vertices, indices });426 objects.push_back({ vertices, indices }); 429 427 430 428 VulkanUtils::copyDataToBuffer(device, physicalDevice, commandPool, vertices, vertexBuffer, numVertices, … … 435 433 graphicsQueue); 436 434 numIndices += indices.size(); 437 438 return true;439 435 } 440 436 -
vulkan-game.hpp
r0cf1a23 r06d959f 32 32 vec3 pos; 33 33 vec3 color; 34 vec3 normal; 34 35 }; 35 36 … … 158 159 void createSyncObjects(); 159 160 161 template<class VertexType> 162 vector<VertexType> addVertexNormals(vector<VertexType> vertices); 163 160 164 template<class UniformType> 161 165 void createUniformBuffers(vector<VkBuffer>& buffers, vector<VkDeviceMemory>& buffersMemory, … … 191 195 } 192 196 197 template<class VertexType> 198 vector<VertexType> VulkanGame::addVertexNormals(vector<VertexType> vertices) { 199 for (unsigned int i = 0; i < vertices.size(); i += 3) { 200 vec3 p1 = vertices[i].pos; 201 vec3 p2 = vertices[i+1].pos; 202 vec3 p3 = vertices[i+2].pos; 203 204 vec3 normal = normalize(cross(p2 - p1, p3 - p1)); 205 normal.z = -normal.z; 206 207 // Add the same normal for all 3 vertices 208 vertices[i].normal = normal; 209 vertices[i+1].normal = normal; 210 vertices[i+2].normal = normal; 211 } 212 213 return vertices; 214 } 215 193 216 #endif // _VULKAN_GAME_H
Note:
See TracChangeset
for help on using the changeset viewer.