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
|
2018-09-27 00:49:00 +00:00
|
|
|
#include <cinttypes>
|
2019-01-14 10:23:21 +00:00
|
|
|
#include "gs-limits.hpp"
|
|
|
|
#include "gs-vertex.hpp"
|
2020-01-14 00:11:08 +00:00
|
|
|
#include "utility.hpp"
|
2018-09-27 00:49:00 +00:00
|
|
|
|
2019-01-14 10:23:21 +00:00
|
|
|
// OBS
|
2019-01-14 22:21:29 +00:00
|
|
|
#ifdef _MSC_VER
|
2018-09-27 00:49:00 +00:00
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(disable : 4201)
|
2019-01-14 22:21:29 +00:00
|
|
|
#endif
|
2018-04-23 15:53:27 +00:00
|
|
|
#include <graphics/graphics.h>
|
2019-01-14 22:21:29 +00:00
|
|
|
#ifdef _MSC_VER
|
2018-09-27 00:49:00 +00:00
|
|
|
#pragma warning(pop)
|
2019-01-14 22:21:29 +00:00
|
|
|
#endif
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
namespace gs {
|
|
|
|
class vertex_buffer {
|
2019-08-04 14:20:26 +00:00
|
|
|
uint32_t _size;
|
|
|
|
uint32_t _capacity;
|
|
|
|
uint32_t _layers;
|
|
|
|
|
|
|
|
// Memory Storage
|
|
|
|
vec3* _positions;
|
|
|
|
vec3* _normals;
|
|
|
|
vec3* _tangents;
|
|
|
|
uint32_t* _colors;
|
|
|
|
vec4* _uvs[MAXIMUM_UVW_LAYERS];
|
|
|
|
|
|
|
|
// OBS GS Data
|
|
|
|
gs_vb_data* _data;
|
|
|
|
gs_vertbuffer_t* _buffer;
|
|
|
|
gs_tvertarray* _layer_data;
|
|
|
|
|
2019-10-13 04:20:58 +00:00
|
|
|
void initialize(size_t capacity, size_t layers);
|
|
|
|
|
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
|
|
|
*/
|
2018-09-27 00:49:00 +00:00
|
|
|
vertex_buffer();
|
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
|
|
|
*/
|
2018-09-27 00:57:53 +00:00
|
|
|
vertex_buffer(uint32_t vertices);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \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.
|
|
|
|
*/
|
|
|
|
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
|
|
|
|
*/
|
2018-03-20 11:43:37 +00:00
|
|
|
void operator=(vertex_buffer const& other) = delete;
|
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
|
|
|
|
*/
|
2019-10-13 04:20:58 +00:00
|
|
|
void operator=(vertex_buffer const&& other) noexcept;
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
void resize(uint32_t new_size);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
uint32_t size();
|
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
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
const gs::vertex at(uint32_t idx);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
const gs::vertex operator[](uint32_t const pos);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
void set_uv_layers(uint32_t layers);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
uint32_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.
|
|
|
|
*/
|
2018-03-20 11:43:37 +00:00
|
|
|
vec4* get_uv_layer(size_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
|