Changeset 8dcbf62 in opengl-game for vulkan-buffer.hpp


Ignore:
Timestamp:
Jun 8, 2021, 11:19:16 PM (3 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
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)
Message:

Add some functionality to VulkanBuffer, and modify VulkanGame::addObject() to call VulkanBuffer::add()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-buffer.hpp

    r8aa4888 r8dcbf62  
    11#ifndef _VULKAN_BUFFER_H
    22#define _VULKAN_BUFFER_H
    3 
    4 #include <iostream>
    5 #include <vector>
    6 
    7 using namespace std;
    83
    94/*
     
    1611   public:
    1712
    18       size_t alignment;
     13      // TODO: Make these private (maybe make a getter for numObjects)
     14      // Externally, they are only used in resizeBufferSet
    1915      size_t capacity;
    2016      size_t numObjects;
     
    2218      VulkanBuffer();
    2319      VulkanBuffer(size_t capacity, size_t minOffsetAlignment);
    24       VulkanBuffer(vector<T>* vData, size_t capacity);
    2520      ~VulkanBuffer();
    2621
    2722      VulkanBuffer<T>& operator=(const VulkanBuffer<T>& other);
    2823
    29       T* data();
    30       void* mappedData(); // TODO: Maybe rename this to just mapped()
     24      void add(T obj);
    3125
    3226      // TODO: Add a resize function
    3327
    3428   private:
     29
     30      size_t alignment;
    3531
    3632      T* srcData; // TODO: Rename this to something else probably and rename rawData to data
     
    8177
    8278template<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 vector
    91 }
    92 
    93 template<class T>
    9479VulkanBuffer<T>::~VulkanBuffer() {
    9580   if (srcData != nullptr) {
     
    132117
    133118template<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;
     119void VulkanBuffer<T>::add(T obj) {
     120   numObjects++;
    145121}
    146122
Note: See TracChangeset for help on using the changeset viewer.