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-01-18 04:01:54 +00:00
|
|
|
#include "gs-limits.h"
|
2017-09-17 19:55:16 +00:00
|
|
|
#include "gs-vertex.h"
|
2018-01-08 18:08:49 +00:00
|
|
|
#include "util-math.h"
|
|
|
|
#include "util-memory.h"
|
2017-09-17 19:55:16 +00:00
|
|
|
#include <inttypes.h>
|
|
|
|
extern "C" {
|
2018-01-19 01:59:55 +00:00
|
|
|
#pragma warning( push )
|
|
|
|
#pragma warning( disable: 4201 )
|
|
|
|
#include <libobs/graphics/graphics.h>
|
|
|
|
#pragma warning( pop )
|
2017-09-17 19:55:16 +00:00
|
|
|
}
|
|
|
|
|
2018-03-20 11:43:37 +00:00
|
|
|
namespace gs {
|
|
|
|
class vertex_buffer {
|
2017-09-17 19:55:16 +00:00
|
|
|
public:
|
2018-01-19 01:59:55 +00:00
|
|
|
#pragma region Constructor & Destructor
|
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-01-19 01:59:55 +00:00
|
|
|
* \brief Create a Vertex Buffer with a specific number of Vertices.
|
2017-09-17 19:55:16 +00:00
|
|
|
*
|
|
|
|
* \param maximumVertices Maximum amount of vertices to store.
|
|
|
|
*/
|
2018-03-20 11:43:37 +00:00
|
|
|
vertex_buffer(uint32_t maximumVertices);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
|
|
|
/*!
|
2018-01-19 01:59:55 +00:00
|
|
|
* \brief Create a Vertex Buffer with the maximum number of Vertices.
|
2017-09-17 19:55:16 +00:00
|
|
|
*
|
2018-01-19 01:59:55 +00:00
|
|
|
* \param maximumVertices Maximum amount of vertices to store.
|
2017-09-17 19:55:16 +00:00
|
|
|
*/
|
2018-03-20 11:43:37 +00:00
|
|
|
vertex_buffer() : vertex_buffer(MAXIMUM_VERTICES) {};
|
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
|
|
|
|
|
|
|
#pragma endregion Constructor & Destructor
|
|
|
|
|
|
|
|
#pragma region Copy/Move Constructors
|
|
|
|
// 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
|
|
|
|
*/
|
2018-03-20 11:43:37 +00:00
|
|
|
vertex_buffer(vertex_buffer const&& other);
|
2018-01-19 01:59:55 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Move Assignment
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* \param other
|
|
|
|
*/
|
2018-03-20 11:43:37 +00:00
|
|
|
void operator=(vertex_buffer const&& other);
|
2018-01-19 01:59:55 +00:00
|
|
|
#pragma endregion Copy/Move Constructors
|
2018-01-18 04:01:54 +00:00
|
|
|
|
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-01-19 01:59:55 +00:00
|
|
|
#pragma region Update / Grab GS object
|
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);
|
2018-01-19 01:59:55 +00:00
|
|
|
#pragma endregion Update / Grab GS object
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-01-18 04:01:54 +00:00
|
|
|
private:
|
|
|
|
uint32_t m_size;
|
|
|
|
uint32_t m_capacity;
|
|
|
|
uint32_t m_layers;
|
|
|
|
|
|
|
|
// Memory Storage
|
|
|
|
vec3 *m_positions;
|
|
|
|
vec3 *m_normals;
|
|
|
|
vec3 *m_tangents;
|
|
|
|
uint32_t *m_colors;
|
|
|
|
vec4 *m_uvs[MAXIMUM_UVW_LAYERS];
|
|
|
|
|
|
|
|
// OBS GS Data
|
2017-12-14 01:59:50 +00:00
|
|
|
gs_vb_data* m_vertexbufferdata;
|
2017-09-17 19:55:16 +00:00
|
|
|
gs_vertbuffer_t* m_vertexbuffer;
|
2018-01-18 04:01:54 +00:00
|
|
|
gs_tvertarray* m_layerdata;
|
2017-09-17 19:55:16 +00:00
|
|
|
};
|
|
|
|
}
|