Changeset 52a02e6 in opengl-game
- Timestamp:
- Apr 26, 2020, 6:08:05 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master
- Children:
- 4a9416a
- Parents:
- 73a10ca
- git-author:
- Dmitry Portnoy <dmitry.portnoy@…> (04/26/20 17:55:49)
- git-committer:
- Dmitry Portnoy <dmitry.portnoy@…> (04/26/20 18:08:05)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
gl-shaders/explosion.vert
r73a10ca r52a02e6 36 36 } 37 37 38 vec3 p = vec3(0.0, 0.0, 0.0); // this is the center of the explosion 39 vec3 a = vec3(0.0, 0.1, 0.0); 40 p += normalize(v_i) * mod(t, duration) / duration * 0.3; // allow time to loop around so particle emitter keeps going 38 // this is the center of the explosion 39 vec3 p = vec3(0.0, 0.0, 0.0); 40 41 // allow time to loop around so particle emitter keeps going 42 p += normalize(v_i) * mod(t, duration) / duration * 0.3; 41 43 42 44 gl_Position = proj * view * model_mats[ubo_index] * vec4(p, 1.0); -
graphics-pipeline_vulkan.hpp
r73a10ca r52a02e6 49 49 // if it will never change, just pass it in the constructor and save it 50 50 // If it does change, I could add an updateSwapchainImageCount() function 51 GraphicsPipeline_Vulkan(VkP hysicalDevice physicalDevice, VkDevice device, VkRenderPass renderPass,52 V iewport viewport, vector<VkImage>& swapChainImages,51 GraphicsPipeline_Vulkan(VkPrimitiveTopology topology, VkPhysicalDevice physicalDevice, VkDevice device, 52 VkRenderPass renderPass, Viewport viewport, vector<VkImage>& swapChainImages, 53 53 size_t vertexCapacity, size_t indexCapacity, size_t objectCapacity); 54 54 ~GraphicsPipeline_Vulkan(); … … 86 86 87 87 private: 88 VkPrimitiveTopology topology; 88 89 VkPhysicalDevice physicalDevice; 89 90 VkDevice device; … … 136 137 template<class VertexType, class SSBOType> 137 138 GraphicsPipeline_Vulkan<VertexType, SSBOType>::GraphicsPipeline_Vulkan( 138 VkP hysicalDevice physicalDevice, VkDevice device,139 VkPrimitiveTopology topology, VkPhysicalDevice physicalDevice, VkDevice device, 139 140 VkRenderPass renderPass, Viewport viewport, vector<VkImage>& swapChainImages, 140 141 size_t vertexCapacity, size_t indexCapacity, size_t objectCapacity) { 142 this->topology = topology; 141 143 this->physicalDevice = physicalDevice; 142 144 this->device = device; … … 274 276 VkPipelineInputAssemblyStateCreateInfo inputAssembly = {}; 275 277 inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; 276 inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;278 inputAssembly.topology = this->topology; 277 279 inputAssembly.primitiveRestartEnable = VK_FALSE; 278 280 -
vulkan-game.cpp
r73a10ca r52a02e6 519 519 }, false); 520 520 521 ship.model_base = 522 translate(mat4(1.0f), vec3(0.0f, -1.2f, 1.65f)) * 523 scale(mat4(1.0f), vec3(0.1f, 0.1f, 0.1f)); 524 ship.modified = true; 525 521 526 shipPipeline.createDescriptorSetLayout(); 522 527 shipPipeline.createPipeline("shaders/ship-vert.spv", "shaders/ship-frag.spv"); … … 564 569 565 570 createSyncObjects(); 566 567 ship.model_base =568 translate(mat4(1.0f), vec3(0.0f, -1.2f, 1.65f)) *569 scale(mat4(1.0f), vec3(0.1f, 0.1f, 0.1f));570 ship.modified = true;571 571 } 572 572 573 573 void VulkanGame::initGraphicsPipelines() { 574 overlayPipeline = GraphicsPipeline_Vulkan<OverlayVertex, void*>(physicalDevice, device, renderPass, 574 overlayPipeline = GraphicsPipeline_Vulkan<OverlayVertex, void*>( 575 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, physicalDevice, device, renderPass, 575 576 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 4, 6, 0); 576 577 577 modelPipeline = GraphicsPipeline_Vulkan<ModelVertex, SSBO_ModelObject>(physicalDevice, device, renderPass, 578 modelPipeline = GraphicsPipeline_Vulkan<ModelVertex, SSBO_ModelObject>( 579 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, physicalDevice, device, renderPass, 578 580 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 16, 24, 10); 579 581 580 shipPipeline = GraphicsPipeline_Vulkan<ShipVertex, SSBO_ModelObject>(physicalDevice, device, renderPass, 582 shipPipeline = GraphicsPipeline_Vulkan<ShipVertex, SSBO_ModelObject>( 583 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, physicalDevice, device, renderPass, 581 584 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 138, 138, 10); 582 585 583 asteroidPipeline = GraphicsPipeline_Vulkan<AsteroidVertex, SSBO_Asteroid>(physicalDevice, device, renderPass, 586 asteroidPipeline = GraphicsPipeline_Vulkan<AsteroidVertex, SSBO_Asteroid>( 587 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, physicalDevice, device, renderPass, 584 588 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 24, 36, 10); 585 589 586 laserPipeline = GraphicsPipeline_Vulkan<LaserVertex, SSBO_Laser>(physicalDevice, device, renderPass, 590 laserPipeline = GraphicsPipeline_Vulkan<LaserVertex, SSBO_Laser>( 591 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, physicalDevice, device, renderPass, 587 592 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 8, 18, 2); 588 593 } … … 1571 1576 } 1572 1577 1573 void VulkanGame::addLaser( 1578 void VulkanGame::addLaser(vec3 start, vec3 end, vec3 color, float width) { 1574 1579 vec3 ray = end - start; 1575 1580 float length = glm::length(ray); -
vulkan-game.hpp
r73a10ca r52a02e6 57 57 }; 58 58 59 struct UBO_VP_mats {60 alignas(16) mat4 view;61 alignas(16) mat4 proj;62 };63 64 59 struct SSBO_ModelObject { 65 60 alignas(16) mat4 model; … … 76 71 alignas(4) vec3 color; 77 72 alignas(4) unsigned int deleted; 73 }; 74 75 struct UBO_VP_mats { 76 alignas(16) mat4 view; 77 alignas(16) mat4 proj; 78 78 }; 79 79 … … 175 175 176 176 private: 177 // TODO: Make these consts static 178 177 179 const int MAX_FRAMES_IN_FLIGHT; 178 180 … … 334 336 void createSyncObjects(); 335 337 336 void addLaser(vec3 start, vec3 end, vec3 color, float width);337 void translateLaser(size_t index, const vec3& translation);338 void updateLaserTarget(size_t index);339 bool getLaserAndAsteroidIntersection(SceneObject<AsteroidVertex, SSBO_Asteroid>& asteroid,340 vec3& start, vec3& end, vec3& intersection);341 342 338 // TODO: Since addObject() returns a reference to the new object now, 343 339 // stop using objects.back() to access the object that was just created … … 365 361 template<class VertexType, class SSBOType> 366 362 void centerObject(SceneObject<VertexType, SSBOType>& object); 363 364 void addLaser(vec3 start, vec3 end, vec3 color, float width); 365 void translateLaser(size_t index, const vec3& translation); 366 void updateLaserTarget(size_t index); 367 bool getLaserAndAsteroidIntersection(SceneObject<AsteroidVertex, SSBO_Asteroid>& asteroid, 368 vec3& start, vec3& end, vec3& intersection); 367 369 368 370 void createBufferSet(VkDeviceSize bufferSize, VkBufferUsageFlags flags,
Note:
See TracChangeset
for help on using the changeset viewer.