Changeset 8dcbf62 in opengl-game for vulkan-buffer.hpp
- Timestamp:
- Jun 8, 2021, 11:19:16 PM (3 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- 6bac215
- Parents:
- 8aa4888
- git-author:
- Dmitry Portnoy <dportnoy@…> (06/08/21 20:38:16)
- git-committer:
- Dmitry Portnoy <dportnoy@…> (06/08/21 23:19:16)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-buffer.hpp
r8aa4888 r8dcbf62 1 1 #ifndef _VULKAN_BUFFER_H 2 2 #define _VULKAN_BUFFER_H 3 4 #include <iostream>5 #include <vector>6 7 using namespace std;8 3 9 4 /* … … 16 11 public: 17 12 18 size_t alignment; 13 // TODO: Make these private (maybe make a getter for numObjects) 14 // Externally, they are only used in resizeBufferSet 19 15 size_t capacity; 20 16 size_t numObjects; … … 22 18 VulkanBuffer(); 23 19 VulkanBuffer(size_t capacity, size_t minOffsetAlignment); 24 VulkanBuffer(vector<T>* vData, size_t capacity);25 20 ~VulkanBuffer(); 26 21 27 22 VulkanBuffer<T>& operator=(const VulkanBuffer<T>& other); 28 23 29 T* data(); 30 void* mappedData(); // TODO: Maybe rename this to just mapped() 24 void add(T obj); 31 25 32 26 // TODO: Add a resize function 33 27 34 28 private: 29 30 size_t alignment; 35 31 36 32 T* srcData; // TODO: Rename this to something else probably and rename rawData to data … … 81 77 82 78 template<class T> 83 VulkanBuffer<T>::VulkanBuffer(vector<T>* vData, size_t capacity)84 : alignment(sizeof(T))85 , capacity(capacity)86 , numObjects(0)87 , srcData(nullptr)88 , rawData(nullptr)89 , vData(vData) {90 // TODO: Allocate initial capacity in vector91 }92 93 template<class T>94 79 VulkanBuffer<T>::~VulkanBuffer() { 95 80 if (srcData != nullptr) { … … 132 117 133 118 template<class T> 134 T* VulkanBuffer<T>::data() { 135 if (srcData != nullptr) { 136 return srcData; 137 } else { 138 return vData->data(); 139 } 140 } 141 142 template<class T> 143 void* VulkanBuffer<T>::mappedData() { 144 return rawData; 119 void VulkanBuffer<T>::add(T obj) { 120 numObjects++; 145 121 } 146 122
Note:
See TracChangeset
for help on using the changeset viewer.