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
|
|
|
}
|
|
|
|
|
|
|
|
namespace GS {
|
2018-01-18 04:01:54 +00:00
|
|
|
class VertexBuffer {
|
2017-09-17 19:55:16 +00:00
|
|
|
public:
|
2018-01-19 01:59:55 +00:00
|
|
|
#pragma region Constructor & Destructor
|
|
|
|
virtual ~VertexBuffer();
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
VertexBuffer(uint32_t maximumVertices);
|
|
|
|
|
|
|
|
/*!
|
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-01-19 01:59:55 +00:00
|
|
|
VertexBuffer() : VertexBuffer(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-01-19 01:59:55 +00:00
|
|
|
VertexBuffer(gs_vertbuffer_t* other);
|
|
|
|
|
|
|
|
#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-01-19 01:59:55 +00:00
|
|
|
VertexBuffer(VertexBuffer const& other);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Copy Assignment
|
|
|
|
* Unsafe operation and as such marked as deleted.
|
|
|
|
*
|
|
|
|
* \param other
|
|
|
|
*/
|
|
|
|
void operator=(VertexBuffer const& other) = delete;
|
|
|
|
|
|
|
|
// Move Constructor & Assignments
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Move Constructor
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* \param other
|
|
|
|
*/
|
|
|
|
VertexBuffer(VertexBuffer const&& other);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Move Assignment
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* \param other
|
|
|
|
*/
|
|
|
|
void operator=(VertexBuffer const&& other);
|
|
|
|
#pragma endregion Copy/Move Constructors
|
2018-01-18 04:01:54 +00:00
|
|
|
|
2017-09-17 19:55:16 +00:00
|
|
|
|
|
|
|
|
2018-01-19 01:59:55 +00:00
|
|
|
void Resize(uint32_t new_size);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-01-19 01:59:55 +00:00
|
|
|
uint32_t Size();
|
2018-01-18 04:01:54 +00:00
|
|
|
|
2018-01-19 01:59:55 +00:00
|
|
|
bool Empty();
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-01-19 01:59:55 +00:00
|
|
|
const GS::Vertex At(uint32_t idx);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-01-19 01:59:55 +00:00
|
|
|
const GS::Vertex operator[](uint32_t const pos);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-01-19 01:59:55 +00:00
|
|
|
void SetUVLayers(uint32_t layers);
|
2017-09-17 19:55:16 +00:00
|
|
|
|
2018-01-19 01:59:55 +00:00
|
|
|
uint32_t GetUVLayers();
|
|
|
|
|
|
|
|
#pragma region Update / Grab GS object
|
|
|
|
gs_vertbuffer_t* Update();
|
|
|
|
|
|
|
|
gs_vertbuffer_t* Update(bool refreshGPU);
|
|
|
|
#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
|
|
|
};
|
|
|
|
}
|