2017-09-17 19:55:16 +00:00
|
|
|
/*
|
|
|
|
* Modern effects for a modern Streamer
|
|
|
|
* Copyright (C) 2017 Michael Fabian Dirks
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-04-02 15:02:01 +00:00
|
|
|
#include "common.hpp"
|
2019-01-14 10:23:21 +00:00
|
|
|
#include "gs-limits.hpp"
|
|
|
|
#include "gs-vertex.hpp"
|
2018-09-27 00:49:00 +00:00
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
namespace gs {
|
|
|
|
class vertex_buffer {
|
2020-07-27 00:19:19 +00:00
|
|
|
uint32_t _capacity;
|
|
|
|
uint32_t _size;
|
|
|
|
uint8_t _layers;
|
|
|
|
|
|
|
|
// OBS GS Data
|
|
|
|
std::shared_ptr<gs_vertbuffer_t> _buffer;
|
|
|
|
std::shared_ptr<gs_vb_data> _data;
|
2019-08-04 14:20:26 +00:00
|
|
|
|
|
|
|
// Memory Storage
|
2020-07-27 00:19:19 +00:00
|
|
|
vec3* _positions;
|
|
|
|
vec3* _normals;
|
|
|
|
vec3* _tangents;
|
|
|
|
uint32_t* _colors;
|
|
|
|
gs_tvertarray* _uv_layers;
|
|
|
|
vec4* _uvs[MAXIMUM_UVW_LAYERS];
|
2019-08-04 14:20:26 +00:00
|
|
|
|
2020-07-27 00:19:19 +00:00
|
|
|
// OBS compatability
|
|
|
|
gs_vb_data* _obs_data;
|
2019-08-04 14:20:26 +00:00
|
|
|
|
2020-07-27 00:19:19 +00:00
|
|
|
void initialize(uint32_t capacity, uint8_t layers);
|
|
|
|
void finalize();
|
2019-10-13 04:20:58 +00:00
|
|
|
|
2017-09-17 19:55:16 +00:00
|
|
|
public:
|
2018-03-20 11:43:37 +00:00
|
|
|
virtual ~vertex_buffer();
|
2018-01-19 01:59:55 +00:00
|
|
|
|
2017-09-17 19:55:16 +00:00
|
|
|
/*!
|
2018-09-27 00:49:00 +00:00
|
|
|
* \brief Create a Vertex Buffer with the default number of Vertices.
|
2017-09-17 19:55:16 +00:00
|
|
|
*/
|
2020-07-27 00:19:19 +00:00
|
|
|
vertex_buffer() : vertex_buffer(MAXIMUM_VERTICES, MAXIMUM_UVW_LAYERS) {}
|
2017-09-17 19:55:16 +00:00
|
|
|
|
|
|
|
/*!
|
2018-09-27 00:49:00 +00:00
|
|
|
* \brief Create a Vertex Buffer with a specific number of Vertices.
|
2017-09-17 19:55:16 +00:00
|
|
|
*
|
2018-09-27 00:57:53 +00:00
|
|
|
* \param vertices Number of vertices to store.
|
2017-09-17 19:55:16 +00:00
|
|
|
*/
|
2020-07-27 00:19:19 +00:00
|
|
|
vertex_buffer(uint32_t vertices) : vertex_buffer(vertices, MAXIMUM_UVW_LAYERS) {}
|
2018-09-27 00:57:53 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Create a Vertex Buffer with a specific number of Vertices and uv layers.
|
|
|
|
*
|
|
|
|
* \param vertices Number of vertices to store.
|
|
|
|
* \param layers Number of uv layers to store.
|
|
|
|
*/
|
2020-07-27 00:19:19 +00:00
|
|
|
vertex_buffer(uint32_t vertices, uint8_t layers);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
|
|
|
/*!
|
2018-01-18 04:01:54 +00:00
|
|
|
* \brief Create a copy of a Vertex Buffer
|
|
|
|
* Full Description below
|
|
|
|
*
|
|
|
|
* \param other The Vertex Buffer to copy
|
|
|
|
*/
|
2018-03-20 11:43:37 +00:00
|
|
|
vertex_buffer(gs_vertbuffer_t* other);
|
2018-01-19 01:59:55 +00:00
|
|
|
|
|
|
|
// Copy Constructor & Assignments
|
2017-09-17 19:55:16 +00:00
|
|
|
|
|
|
|
/*!
|
2018-01-19 01:59:55 +00:00
|
|
|
* \brief Copy Constructor
|
|
|
|
*
|
2017-09-17 19:55:16 +00:00
|
|
|
*
|
2018-01-19 01:59:55 +00:00
|
|
|
* \param other
|
2017-09-17 19:55:16 +00:00
|
|
|
*/
|
2018-03-20 11:43:37 +00:00
|
|
|
vertex_buffer(vertex_buffer const& other);
|
2018-01-19 01:59:55 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Copy Assignment
|
|
|
|
* Unsafe operation and as such marked as deleted.
|
|
|
|
*
|
|
|
|
* \param other
|
|
|
|
*/
|
2020-07-27 00:19:19 +00:00
|
|
|
void operator=(vertex_buffer const& other);
|
2018-01-19 01:59:55 +00:00
|
|
|
|
|
|
|
// Move Constructor & Assignments
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Move Constructor
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* \param other
|
|
|
|
*/
|
2019-10-13 04:20:58 +00:00
|
|
|
vertex_buffer(vertex_buffer const&& other) noexcept;
|
2018-01-19 01:59:55 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Move Assignment
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* \param other
|
|
|
|
*/
|
2020-07-27 00:19:19 +00:00
|
|
|
void operator=(vertex_buffer const&& other);
|
|
|
|
|
|
|
|
void resize(uint32_t new_size);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2020-07-27 00:19:19 +00:00
|
|
|
uint32_t size();
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2020-07-27 00:19:19 +00:00
|
|
|
uint32_t capacity();
|
2018-01-18 04:01:54 +00:00
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
bool empty();
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2020-07-27 00:19:19 +00:00
|
|
|
const gs::vertex at(uint32_t idx);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2020-07-27 00:19:19 +00:00
|
|
|
const gs::vertex operator[](uint32_t const pos);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2020-07-27 00:19:19 +00:00
|
|
|
void set_uv_layers(uint8_t layers);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2020-07-27 00:19:19 +00:00
|
|
|
uint8_t get_uv_layers();
|
2018-01-19 01:59:55 +00:00
|
|
|
|
2018-01-19 01:59:55 +00:00
|
|
|
/*!
|
|
|
|
* \brief Directly access the positions buffer
|
|
|
|
* Returns the internal memory that is assigned to hold all vertex positions.
|
|
|
|
*
|
|
|
|
* \return A <vec3*> that points at the first vertex's position.
|
|
|
|
*/
|
2018-03-20 11:43:37 +00:00
|
|
|
vec3* get_positions();
|
2018-01-19 01:59:55 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Directly access the normals buffer
|
|
|
|
* Returns the internal memory that is assigned to hold all vertex normals.
|
|
|
|
*
|
|
|
|
* \return A <vec3*> that points at the first vertex's normal.
|
|
|
|
*/
|
2018-03-20 11:43:37 +00:00
|
|
|
vec3* get_normals();
|
2018-01-19 01:59:55 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Directly access the tangents buffer
|
|
|
|
* Returns the internal memory that is assigned to hold all vertex tangents.
|
|
|
|
*
|
|
|
|
* \return A <vec3*> that points at the first vertex's tangent.
|
|
|
|
*/
|
2018-03-20 11:43:37 +00:00
|
|
|
vec3* get_tangents();
|
2018-01-19 01:59:55 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Directly access the colors buffer
|
|
|
|
* Returns the internal memory that is assigned to hold all vertex colors.
|
|
|
|
*
|
|
|
|
* \return A <uint32_t*> that points at the first vertex's color.
|
|
|
|
*/
|
2018-03-20 11:43:37 +00:00
|
|
|
uint32_t* get_colors();
|
2018-01-19 01:59:55 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Directly access the uv buffer
|
|
|
|
* Returns the internal memory that is assigned to hold all vertex uvs.
|
|
|
|
*
|
|
|
|
* \return A <vec4*> that points at the first vertex's uv.
|
|
|
|
*/
|
2020-07-27 00:19:19 +00:00
|
|
|
vec4* get_uv_layer(uint8_t idx);
|
2018-01-19 01:59:55 +00:00
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
gs_vertbuffer_t* update();
|
2018-01-19 01:59:55 +00:00
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
gs_vertbuffer_t* update(bool refreshGPU);
|
2017-09-17 19:55:16 +00:00
|
|
|
};
|
2018-09-27 00:49:00 +00:00
|
|
|
} // namespace gs
|