Changeset 2da64ef in opengl-game for vulkan-game.hpp


Ignore:
Timestamp:
Feb 19, 2020, 4:47:41 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
3b84bb6
Parents:
860a0da
Message:

In VulkanGame, move the logic of updating per-object data in the SSBO into GraphicsPipeline_Vulkan and remove the SSBO properties from VulkanGame

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.hpp

    r860a0da r2da64ef  
    7575};
    7676
     77// Have to figure out how to include an optional ssbo parameter for each object
     78// Could probably use the same approach to make indices optional
     79
    7780class VulkanGame {
    7881   public:
     
    158161
    159162      UBO_VP_mats object_VP_mats;
    160       SSBO_ModelObject so_Object;
    161163
    162164      GraphicsPipeline_Vulkan<ShipVertex, SSBO_ModelObject> shipPipeline;
     
    168170
    169171      UBO_VP_mats ship_VP_mats;
    170       SSBO_ModelObject so_Ship;
    171172
    172173      GraphicsPipeline_Vulkan<AsteroidVertex, SSBO_Asteroid> asteroidPipeline;
     
    178179
    179180      UBO_VP_mats asteroid_VP_mats;
    180       SSBO_Asteroid so_Asteroid;
    181181
    182182      Uint64 curTime, prevTime;
     
    219219         const vector<VertexType>& vertices, vector<uint16_t> indices, SSBOType ssbo);
    220220
     221      template<class VertexType, class SSBOType>
     222      void updateObject(vector<SceneObject<VertexType, SSBOType>>& objects,
     223         GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline, size_t index);
     224
    221225      template<class VertexType>
    222226      vector<VertexType> addVertexNormals(vector<VertexType> vertices);
     
    227231      template<class VertexType>
    228232      vector<VertexType> centerObject(vector<VertexType> vertices);
    229 
    230       template<class VertexType, class SSBOType>
    231       void transformObject(SceneObject<VertexType, SSBOType>& obj, mat4 mat);
    232233
    233234      void createBufferSet(VkDeviceSize bufferSize, VkBufferUsageFlags flags,
     
    258259
    259260   pipeline.addVertices(vertices, indices, commandPool, graphicsQueue);
     261}
     262
     263template<class VertexType, class SSBOType>
     264void VulkanGame::updateObject(vector<SceneObject<VertexType, SSBOType>>& objects,
     265      GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline, size_t index) {
     266   SceneObject<VertexType, SSBOType>& obj = objects[index];
     267
     268   obj.ssbo.model = obj.model_transform * obj.model_base;
     269
     270   // could probably re-calculate the object center here based on model
     271   // I think the center should be calculated by using model * vec3(0, 0, 0)
     272   // model_base is currently only used to set the original location of the ship and asteroids
     273
     274   pipeline.updateObject(index, obj.ssbo);
    260275}
    261276
     
    326341}
    327342
    328 template<class VertexType, class SSBOType>
    329 void VulkanGame::transformObject(SceneObject<VertexType, SSBOType>& obj, mat4 mat) {
    330    obj.model_transform = mat * obj.model_transform;
    331 }
    332 
    333343#endif // _VULKAN_GAME_H
Note: See TracChangeset for help on using the changeset viewer.