gs-vertexbuffer: Functions to directly access internal buffers

Skips the previously necessary step to call At(0) and use the pointers stored in GS::Vertex to directly write to the buffers.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2018-01-19 02:59:55 +01:00
parent fe3186220c
commit 5e0b387dc1
2 changed files with 62 additions and 0 deletions

View file

@ -265,6 +265,28 @@ uint32_t GS::VertexBuffer::GetUVLayers() {
return m_layers; return m_layers;
} }
vec3* GS::VertexBuffer::GetPositions() {
return m_positions;
}
vec3* GS::VertexBuffer::GetNormals() {
return m_normals;
}
vec3* GS::VertexBuffer::GetTangents() {
return m_tangents;
}
uint32_t* GS::VertexBuffer::GetColors() {
return m_colors;
}
vec4* GS::VertexBuffer::GetUVLayer(size_t idx) {
if ((idx < 0) || (idx >= m_layers)) {
throw std::out_of_range("idx out of range");
}
return m_uvs[idx];
}
gs_vertbuffer_t* GS::VertexBuffer::Update(bool refreshGPU) { gs_vertbuffer_t* GS::VertexBuffer::Update(bool refreshGPU) {
if (!refreshGPU) if (!refreshGPU)

View file

@ -114,6 +114,46 @@ namespace GS {
uint32_t GetUVLayers(); uint32_t GetUVLayers();
/*!
* \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.
*/
vec3* GetPositions();
/*!
* \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.
*/
vec3* GetNormals();
/*!
* \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.
*/
vec3* GetTangents();
/*!
* \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.
*/
uint32_t* GetColors();
/*!
* \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.
*/
vec4* GetUVLayer(size_t idx);
#pragma region Update / Grab GS object #pragma region Update / Grab GS object
gs_vertbuffer_t* Update(); gs_vertbuffer_t* Update();