Changeset 52a02e6 in opengl-game


Ignore:
Timestamp:
Apr 26, 2020, 6:08:05 PM (4 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
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)
Message:

Add a primitive topology parameter to the GraphicsPipeline_Vulkan constructor

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • gl-shaders/explosion.vert

    r73a10ca r52a02e6  
    3636   }
    3737
    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;
    4143
    4244   gl_Position = proj * view * model_mats[ubo_index] * vec4(p, 1.0);
  • graphics-pipeline_vulkan.hpp

    r73a10ca r52a02e6  
    4949      // if it will never change, just pass it in the constructor and save it
    5050      // If it does change, I could add an updateSwapchainImageCount() function
    51       GraphicsPipeline_Vulkan(VkPhysicalDevice physicalDevice, VkDevice device, VkRenderPass renderPass,
    52          Viewport viewport, vector<VkImage>& swapChainImages,
     51      GraphicsPipeline_Vulkan(VkPrimitiveTopology topology, VkPhysicalDevice physicalDevice, VkDevice device,
     52         VkRenderPass renderPass, Viewport viewport, vector<VkImage>& swapChainImages,
    5353         size_t vertexCapacity, size_t indexCapacity, size_t objectCapacity);
    5454      ~GraphicsPipeline_Vulkan();
     
    8686   
    8787   private:
     88      VkPrimitiveTopology topology;
    8889      VkPhysicalDevice physicalDevice;
    8990      VkDevice device;
     
    136137template<class VertexType, class SSBOType>
    137138GraphicsPipeline_Vulkan<VertexType, SSBOType>::GraphicsPipeline_Vulkan(
    138       VkPhysicalDevice physicalDevice, VkDevice device,
     139      VkPrimitiveTopology topology, VkPhysicalDevice physicalDevice, VkDevice device,
    139140      VkRenderPass renderPass, Viewport viewport, vector<VkImage>& swapChainImages,
    140141      size_t vertexCapacity, size_t indexCapacity, size_t objectCapacity) {
     142   this->topology = topology;
    141143   this->physicalDevice = physicalDevice;
    142144   this->device = device;
     
    274276   VkPipelineInputAssemblyStateCreateInfo inputAssembly = {};
    275277   inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
    276    inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
     278   inputAssembly.topology = this->topology;
    277279   inputAssembly.primitiveRestartEnable = VK_FALSE;
    278280
  • vulkan-game.cpp

    r73a10ca r52a02e6  
    519519      }, false);
    520520
     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
    521526   shipPipeline.createDescriptorSetLayout();
    522527   shipPipeline.createPipeline("shaders/ship-vert.spv", "shaders/ship-frag.spv");
     
    564569
    565570   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;
    571571}
    572572
    573573void 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,
    575576      { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 4, 6, 0);
    576577
    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,
    578580      { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 16, 24, 10);
    579581
    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,
    581584      { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 138, 138, 10);
    582585
    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,
    584588      { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 24, 36, 10);
    585589
    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,
    587592      { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 8, 18, 2);
    588593}
     
    15711576}
    15721577
    1573 void VulkanGame::addLaser( vec3 start, vec3 end, vec3 color, float width) {
     1578void VulkanGame::addLaser(vec3 start, vec3 end, vec3 color, float width) {
    15741579   vec3 ray = end - start;
    15751580   float length = glm::length(ray);
  • vulkan-game.hpp

    r73a10ca r52a02e6  
    5757};
    5858
    59 struct UBO_VP_mats {
    60    alignas(16) mat4 view;
    61    alignas(16) mat4 proj;
    62 };
    63 
    6459struct SSBO_ModelObject {
    6560   alignas(16) mat4 model;
     
    7671   alignas(4) vec3 color;
    7772   alignas(4) unsigned int deleted;
     73};
     74
     75struct UBO_VP_mats {
     76   alignas(16) mat4 view;
     77   alignas(16) mat4 proj;
    7878};
    7979
     
    175175
    176176   private:
     177      // TODO: Make these consts static
     178
    177179      const int MAX_FRAMES_IN_FLIGHT;
    178180
     
    334336      void createSyncObjects();
    335337
    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 
    342338      // TODO: Since addObject() returns a reference to the new object now,
    343339      // stop using objects.back() to access the object that was just created
     
    365361      template<class VertexType, class SSBOType>
    366362      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);
    367369
    368370      void createBufferSet(VkDeviceSize bufferSize, VkBufferUsageFlags flags,
Note: See TracChangeset for help on using the changeset viewer.