Saga3D API Documentation  1.0-RC4
saga::scene::CGPUMeshBuffer Class Reference

Implementation of the CPU IMeshBuffer interface. More...

#include <CGPUMeshBuffer.h>

Inheritance diagram for saga::scene::CGPUMeshBuffer:
saga::scene::IMeshBuffer

Public Member Functions

 CGPUMeshBuffer ()
 Default constructor for empty meshbuffer. More...
 
virtual bool isGPUBuffer () const override
 
virtual ~CGPUMeshBuffer ()
 
virtual std::uint64_t getID () const override
 Returns internal ID to identify mesh buffer. More...
 
virtual void buildBuffer (video::IVideoDriver &driver, const video::PipelineHandle pipeline) override
 Generate GPU-compatible data. More...
 
virtual void * getVertices () override
 Get pointer to vertices. More...
 
virtual const void * getData (const video::PipelineHandle pipeline) const override
 Get pointer to GPU staging buffer. More...
 
virtual std::size_t getSize (const video::PipelineHandle pipeline) const override
 Get size of GPU staging buffer. More...
 
void setVertexBuffer (const video::ShaderBufferHandle buffer)
 Set a shader buffer as MeshBuffer. More...
 
auto getVertexBuffer () const
 Get GPU mesh buffer. More...
 
virtual void setVertexCount (const size_t count) override
 Set number of vertices. More...
 
virtual std::size_t getVertexCount () const override
 Get number of vertices. More...
 
void setIndexBuffer (const video::ShaderBufferHandle buffer)
 Set a shader buffer as vertex buffer. More...
 
auto getIndexBuffer () const
 Get GPU index buffer. More...
 
virtual void setIndexCount (const std::uint32_t count)
 Set number of indices. More...
 
virtual const std::uint32_t * getIndices () const override
 Get pointer to indices. More...
 
virtual std::uint32_t * getIndices () override
 Get pointer to indices. More...
 
virtual std::uint32_t getIndex (std::size_t offset) const override
 returns vertex index at this offset More...
 
virtual std::uint32_t getIndexCount () const override
 Get number of indices. More...
 
virtual const core::aabbox3d< float > & getBoundingBox () const override
 Get the axis aligned bounding box. More...
 
virtual void setBoundingBox (const core::aabbox3df &box) override
 Set the axis aligned bounding box. More...
 
virtual void recalculateBoundingBox () override
 Recalculate the bounding box. More...
 
virtual const glm::vec3 & getPosition (std::uint32_t i) const override
 returns position of vertex i More...
 
virtual const glm::vec3 & getNormal (std::uint32_t i) const override
 returns normal of vertex i More...
 
virtual const glm::vec2 & getTCoords (std::uint32_t i) const override
 returns texture coord of vertex i More...
 
virtual const glm::vec3 & getTangent (std::uint32_t i) const override
 returns tangent of vertex i More...
 
virtual const glm::vec3 & getBiTangent (std::uint32_t i) const override
 returns bi-tangent of vertex i More...
 
virtual void append (std::vector< S3DVertex > &&vertices, std::vector< uint32_t > &&indices) override
 Append the vertices and indices to the current buffer. More...
 
virtual void appendAttribute (const char *buffer, const size_t size, const size_t stride) override
 Append the custom attribute buffer to the current mesh buffer. More...
 
virtual void append (const IMeshBuffer *const other) override
 Append the meshbuffer to the current buffer. More...
 
- Public Member Functions inherited from saga::scene::IMeshBuffer
virtual ~IMeshBuffer ()
 
void setPrimitiveType (scene::E_PRIMITIVE_TYPE type)
 Describe what kind of primitive geometry is used by the meshbuffer. More...
 
scene::E_PRIMITIVE_TYPE getPrimitiveType () const
 Get the kind of primitive geometry which is used by the meshbuffer. More...
 
E_INDEX_TYPE getIndexType () const
 Get index type. More...
 
void setIndexType (const E_INDEX_TYPE type)
 Set index type. More...
 
void setInstanceCount (const size_t count)
 Set buffer binding location. More...
 
std::size_t getInstanceCount () const
 Get buffer binding location. More...
 
void setBindingLocation (const int binding)
 Set buffer binding location. More...
 
int getBindingLocation () const
 Get buffer binding location. More...
 
void isNull (const bool null)
 
bool isNull () const
 
virtual std::uint32_t getPrimitiveCount () const
 Calculate how many geometric primitives are used by this meshbuffer. More...
 
bool useIndirectDraw () const
 
auto indirectDrawBuffer () const
 
void setIndirectDrawBuffer (const video::IndirectBufferHandle buffer)
 
bool useIndexedIndirectDraw () const
 
auto indexedIndirectDrawBuffer () const
 
void setIndexedIndirectDrawBuffer (const video::IndexedIndirectBufferHandle buffer)
 

Public Attributes

const std::uint64_t ID
 
video::ShaderBufferHandle VertexBuffer = video::NULL_GPU_RESOURCE_HANDLE
 
std::size_t VertexCount = 0
 
video::ShaderBufferHandle IndexBuffer = video::NULL_GPU_RESOURCE_HANDLE
 
std::uint32_t IndexCount = 0
 

Additional Inherited Members

- Protected Attributes inherited from saga::scene::IMeshBuffer
scene::E_PRIMITIVE_TYPE PrimitiveType = E_PRIMITIVE_TYPE::TRIANGLES
 Primitive type used for rendering (triangles, lines, ...) More...
 
std::size_t InstanceCount = 1
 Instance count for rendering multiple objects with this buffer. More...
 
int Binding = 0
 Binding location. More...
 
bool IsNull = false
 Is a null buffer? More...
 
video::IndirectBufferHandle IndirectDrawBuffer = video::NULL_GPU_RESOURCE_HANDLE
 Indirect draw command buffer for this mesh buffer. More...
 
video::IndexedIndirectBufferHandle IndexedIndirectDrawBuffer = video::NULL_GPU_RESOURCE_HANDLE
 Indexed indirect draw command buffer for this mesh buffer. More...
 
E_INDEX_TYPE IndexType = E_INDEX_TYPE::UINT32
 
- Static Protected Attributes inherited from saga::scene::IMeshBuffer
static MeshBufferID RootID
 To set ID for mesh buffer when created. More...
 

Detailed Description

Implementation of the CPU IMeshBuffer interface.

Definition at line 12 of file CGPUMeshBuffer.h.

Constructor & Destructor Documentation

◆ CGPUMeshBuffer()

saga::scene::CGPUMeshBuffer::CGPUMeshBuffer ( )
inline

Default constructor for empty meshbuffer.

Definition at line 16 of file CGPUMeshBuffer.h.

◆ ~CGPUMeshBuffer()

virtual saga::scene::CGPUMeshBuffer::~CGPUMeshBuffer ( )
inlinevirtual

Definition at line 24 of file CGPUMeshBuffer.h.

Member Function Documentation

◆ append() [1/2]

virtual void saga::scene::CGPUMeshBuffer::append ( const IMeshBuffer *const  other)
inlineoverridevirtual

Append the meshbuffer to the current buffer.

Only works for compatible types, i.e. either the same type or the main buffer is of standard type. Otherwise, behavior is undefined.

Parameters
otherMeshbuffer to be appended to this one.

Implements saga::scene::IMeshBuffer.

Definition at line 131 of file CGPUMeshBuffer.h.

◆ append() [2/2]

virtual void saga::scene::CGPUMeshBuffer::append ( std::vector< S3DVertex > &&  vertices,
std::vector< uint32_t > &&  indices 
)
inlineoverridevirtual

Append the vertices and indices to the current buffer.

Only works for compatible types, i.e. either the same type or the main buffer is of standard type. Otherwise, behavior is undefined.

Implements saga::scene::IMeshBuffer.

Definition at line 116 of file CGPUMeshBuffer.h.

◆ appendAttribute()

virtual void saga::scene::CGPUMeshBuffer::appendAttribute ( const char *  buffer,
const size_t  size,
const size_t  stride 
)
inlineoverridevirtual

Append the custom attribute buffer to the current mesh buffer.

Parameters
bufferPointer to the buffer containing data
sizeTotal size of buffer (bytes)
strideThe custom data size of each vertex (bytes)

Implements saga::scene::IMeshBuffer.

Definition at line 123 of file CGPUMeshBuffer.h.

◆ buildBuffer()

virtual void saga::scene::CGPUMeshBuffer::buildBuffer ( video::IVideoDriver driver,
const video::PipelineHandle  pipeline 
)
inlineoverridevirtual

Generate GPU-compatible data.

Depending on render pass's pipeline layout, this function generates vertex data for that pass

Implements saga::scene::IMeshBuffer.

Definition at line 28 of file CGPUMeshBuffer.h.

◆ getBiTangent()

virtual const glm::vec3& saga::scene::CGPUMeshBuffer::getBiTangent ( std::uint32_t  i) const
inlineoverridevirtual

returns bi-tangent of vertex i

Implements saga::scene::IMeshBuffer.

Definition at line 109 of file CGPUMeshBuffer.h.

◆ getBoundingBox()

virtual const core::aabbox3d<float>& saga::scene::CGPUMeshBuffer::getBoundingBox ( ) const
inlineoverridevirtual

Get the axis aligned bounding box.

Returns
Axis aligned bounding box of this buffer.

Implements saga::scene::IMeshBuffer.

Definition at line 85 of file CGPUMeshBuffer.h.

◆ getData()

virtual const void* saga::scene::CGPUMeshBuffer::getData ( const video::PipelineHandle  pipeline) const
inlineoverridevirtual

Get pointer to GPU staging buffer.

Returns
Pointer to staging buffer.

Implements saga::scene::IMeshBuffer.

Definition at line 36 of file CGPUMeshBuffer.h.

◆ getID()

virtual std::uint64_t saga::scene::CGPUMeshBuffer::getID ( ) const
inlineoverridevirtual

Returns internal ID to identify mesh buffer.

Each mesh buffer will be assigned an unique ID in its creation

Implements saga::scene::IMeshBuffer.

Definition at line 26 of file CGPUMeshBuffer.h.

◆ getIndex()

virtual std::uint32_t saga::scene::CGPUMeshBuffer::getIndex ( std::size_t  offset) const
inlineoverridevirtual

returns vertex index at this offset

Implements saga::scene::IMeshBuffer.

Definition at line 77 of file CGPUMeshBuffer.h.

◆ getIndexBuffer()

auto saga::scene::CGPUMeshBuffer::getIndexBuffer ( ) const
inline

Get GPU index buffer.

Return GPU index buffer handle (ie: bind for rendering)

Definition at line 63 of file CGPUMeshBuffer.h.

◆ getIndexCount()

virtual std::uint32_t saga::scene::CGPUMeshBuffer::getIndexCount ( ) const
inlineoverridevirtual

Get number of indices.

Returns
Number of indices.

Implements saga::scene::IMeshBuffer.

Definition at line 81 of file CGPUMeshBuffer.h.

◆ getIndices() [1/2]

virtual const std::uint32_t* saga::scene::CGPUMeshBuffer::getIndices ( ) const
inlineoverridevirtual

Get pointer to indices.

Returns
Pointer to indices.

Implements saga::scene::IMeshBuffer.

Definition at line 70 of file CGPUMeshBuffer.h.

◆ getIndices() [2/2]

virtual std::uint32_t* saga::scene::CGPUMeshBuffer::getIndices ( )
inlineoverridevirtual

Get pointer to indices.

Returns
Pointer to indices.

Implements saga::scene::IMeshBuffer.

Definition at line 74 of file CGPUMeshBuffer.h.

◆ getNormal()

virtual const glm::vec3& saga::scene::CGPUMeshBuffer::getNormal ( std::uint32_t  i) const
inlineoverridevirtual

returns normal of vertex i

Implements saga::scene::IMeshBuffer.

Definition at line 100 of file CGPUMeshBuffer.h.

◆ getPosition()

virtual const glm::vec3& saga::scene::CGPUMeshBuffer::getPosition ( std::uint32_t  i) const
inlineoverridevirtual

returns position of vertex i

Implements saga::scene::IMeshBuffer.

Definition at line 97 of file CGPUMeshBuffer.h.

◆ getSize()

virtual std::size_t saga::scene::CGPUMeshBuffer::getSize ( const video::PipelineHandle  pipeline) const
inlineoverridevirtual

Get size of GPU staging buffer.

Returns
Size of staging buffer.

Implements saga::scene::IMeshBuffer.

Definition at line 40 of file CGPUMeshBuffer.h.

◆ getTangent()

virtual const glm::vec3& saga::scene::CGPUMeshBuffer::getTangent ( std::uint32_t  i) const
inlineoverridevirtual

returns tangent of vertex i

Implements saga::scene::IMeshBuffer.

Definition at line 106 of file CGPUMeshBuffer.h.

◆ getTCoords()

virtual const glm::vec2& saga::scene::CGPUMeshBuffer::getTCoords ( std::uint32_t  i) const
inlineoverridevirtual

returns texture coord of vertex i

Implements saga::scene::IMeshBuffer.

Definition at line 103 of file CGPUMeshBuffer.h.

◆ getVertexBuffer()

auto saga::scene::CGPUMeshBuffer::getVertexBuffer ( ) const
inline

Get GPU mesh buffer.

Return GPU mesh buffer handle (ie: bind for rendering)

Definition at line 48 of file CGPUMeshBuffer.h.

◆ getVertexCount()

virtual std::size_t saga::scene::CGPUMeshBuffer::getVertexCount ( ) const
inlineoverridevirtual

Get number of vertices.

Returns
Number of vertices.

Implements saga::scene::IMeshBuffer.

Definition at line 55 of file CGPUMeshBuffer.h.

◆ getVertices()

virtual void* saga::scene::CGPUMeshBuffer::getVertices ( )
inlineoverridevirtual

Get pointer to vertices.

Returns
Pointer to vertices.

Implements saga::scene::IMeshBuffer.

Definition at line 32 of file CGPUMeshBuffer.h.

◆ isGPUBuffer()

virtual bool saga::scene::CGPUMeshBuffer::isGPUBuffer ( ) const
inlineoverridevirtual

Implements saga::scene::IMeshBuffer.

Definition at line 22 of file CGPUMeshBuffer.h.

◆ recalculateBoundingBox()

virtual void saga::scene::CGPUMeshBuffer::recalculateBoundingBox ( )
inlineoverridevirtual

Recalculate the bounding box.

should be called if the mesh changed.

Implements saga::scene::IMeshBuffer.

Definition at line 94 of file CGPUMeshBuffer.h.

◆ setBoundingBox()

virtual void saga::scene::CGPUMeshBuffer::setBoundingBox ( const core::aabbox3df box)
inlineoverridevirtual

Set the axis aligned bounding box.

Parameters
boxNew axis aligned bounding box for this buffer. set user axis aligned bounding box

Implements saga::scene::IMeshBuffer.

Definition at line 90 of file CGPUMeshBuffer.h.

◆ setIndexBuffer()

void saga::scene::CGPUMeshBuffer::setIndexBuffer ( const video::ShaderBufferHandle  buffer)
inline

Set a shader buffer as vertex buffer.

For rendering from a buffer manipulated by shaders

Definition at line 59 of file CGPUMeshBuffer.h.

◆ setIndexCount()

virtual void saga::scene::CGPUMeshBuffer::setIndexCount ( const std::uint32_t  count)
inlinevirtual

Set number of indices.

Implements saga::scene::IMeshBuffer.

Definition at line 66 of file CGPUMeshBuffer.h.

◆ setVertexBuffer()

void saga::scene::CGPUMeshBuffer::setVertexBuffer ( const video::ShaderBufferHandle  buffer)
inline

Set a shader buffer as MeshBuffer.

For rendering from a buffer manipulated by shaders

Definition at line 44 of file CGPUMeshBuffer.h.

◆ setVertexCount()

virtual void saga::scene::CGPUMeshBuffer::setVertexCount ( const size_t  count)
inlineoverridevirtual

Set number of vertices.

Implements saga::scene::IMeshBuffer.

Definition at line 51 of file CGPUMeshBuffer.h.

Member Data Documentation

◆ ID

const std::uint64_t saga::scene::CGPUMeshBuffer::ID

Definition at line 133 of file CGPUMeshBuffer.h.

◆ IndexBuffer

video::ShaderBufferHandle saga::scene::CGPUMeshBuffer::IndexBuffer = video::NULL_GPU_RESOURCE_HANDLE

Definition at line 138 of file CGPUMeshBuffer.h.

◆ IndexCount

std::uint32_t saga::scene::CGPUMeshBuffer::IndexCount = 0

Definition at line 139 of file CGPUMeshBuffer.h.

◆ VertexBuffer

video::ShaderBufferHandle saga::scene::CGPUMeshBuffer::VertexBuffer = video::NULL_GPU_RESOURCE_HANDLE

Definition at line 135 of file CGPUMeshBuffer.h.

◆ VertexCount

std::size_t saga::scene::CGPUMeshBuffer::VertexCount = 0

Definition at line 136 of file CGPUMeshBuffer.h.


The documentation for this class was generated from the following file: