PixelLightAPI  .
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
PLRenderer::VertexBuffer Class Reference

Renderer vertex buffer (VBO) resource. More...

#include <VertexBuffer.h>

Inheritance diagram for PLRenderer::VertexBuffer:
Inheritance graph
[legend]

List of all members.

Classes

struct  Attribute
 Defines input vertex attribute to the pipeline. More...

Public Types

enum  ESemantic {
  Position = 0, BlendWeight = 1, Normal = 2, Color = 3,
  FogCoord = 4, PointSize = 5, BlendIndices = 6, TexCoord = 7,
  Tangent = 8, Binormal = 9
}
 Vertex attribute semantic. More...
enum  EType {
  RGBA = 0, Float1 = 1, Float2 = 2, Float3 = 3,
  Float4 = 4, Short2 = 5, Short4 = 6
}
 Vertex attribute types. More...

Public Member Functions

virtual PLRENDERER_API ~VertexBuffer ()
 Destructor.
PLCore::uint32 GetNumOfVertexAttributes () const
 Returns the number of vertex attributes.
PLRENDERER_API bool ClearVertexAttributes ()
 Clears the vertex attributes.
PLRENDERER_API bool AddVertexAttribute (ESemantic nSemantic, PLCore::uint32 nChannel, EType nType)
 Adds vertex attribute.
const AttributeGetVertexAttribute (PLCore::uint32 nIndex=0) const
 Returns a vertex attribute.
PLRENDERER_API const AttributeGetVertexAttribute (ESemantic nSemantic, PLCore::uint32 nChannel=0) const
 Returns the first found vertex attribute with the requested semantic.
PLCore::uint32 GetVertexSize () const
 Returns the vertex size (in bytes)
PLRENDERER_API VertexBufferoperator= (const VertexBuffer &cSource)
 Copy operator.
PLRENDERER_API void CalculateBoundingBox (PLMath::Vector3 &vMinPos, PLMath::Vector3 &vMaxPos, PLRenderer::IndexBuffer *pIndexBuffer=nullptr)
 Returns the vertex buffer bounding box.
PLRENDERER_API void CalculateBoundingSphere (PLMath::Vector3 &vPos, float &fRadius, PLRenderer::IndexBuffer *pIndexBuffer=nullptr)
 Returns the vertex buffer bounding sphere.
virtual void * GetData (PLCore::uint32 nIndex, PLCore::uint32 nSemantic, PLCore::uint32 nChannel=0)=0
 Returns the data of a vertex buffer attribute.
virtual PLGraphics::Color4 GetColor (PLCore::uint32 nIndex, PLCore::uint32 nChannel=0)=0
 Returns the RGBA color of a vertex.
virtual bool SetColor (PLCore::uint32 nIndex, const PLGraphics::Color4 &cColor, PLCore::uint32 nChannel=0)=0
 Set the RGBA color of a vertex.
virtual PLRENDERER_API void * GetData () override
 Returns the buffer data.

Static Public Attributes

static const PLCore::uint8 NumOfSemantics = 10
static const PLCore::uint8 MaxPipelineChannels = 16

Protected Member Functions

PLRENDERER_API VertexBuffer (Renderer &cRenderer)
 Constructor.

Protected Attributes

PLCore::Array< Attribute * > m_lstVertexAttributes
PLCore::uint32 m_nVertexSize

Detailed Description

Renderer vertex buffer (VBO) resource.

Note:
  • If for instance fog coordinates (Capabilities::bVertexBufferFogCoord) are not supported by the GPU, this data is ignored for rendering but can still be used inside your vertex buffer

Member Enumeration Documentation

Vertex attribute semantic.

Note:
  • Defines input vertex data to the pipeline, on legacy hardware, this should be defined in this order (performance)
Enumerator:
Position 

Position data (1 channel)

BlendWeight 

Blend weight data (1 channel)

Normal 

Normal data (1 channel, only Float3 allowed!)

Color 

Color data (2 channels, only RGBA allowed, second channel requires Capabilities::bVertexBufferSecondaryColor)

FogCoord 

Fog coordinate data (1 channel, only Float1 allowed, requires FixedFunctions::Capabilities::bVertexBufferFogCoord)

PointSize 

Point sprite size data (1 channel, only Float1 allowed! Known as "PSize", but this name may conflict with OS definitions)

BlendIndices 

Blend indices data (1 channel)

TexCoord 

Texture coordinate data (n channels)

Tangent 

Tangent data (1 channel, only Float3 allowed!)

Binormal 

Binormal (also referred to as bitangent) data (1 channel, only Float3 allowed!)

Vertex attribute types.

Enumerator:
RGBA 

Color (API dependent storage, do always use GetColor() and SetColor()!)

Float1 

Float 1

Float2 

Float 2

Float3 

Float 3

Float4 

Float 4

Short2 

Short 2

Short4 

Short 4

Reimplemented from PLRenderer::Resource.


Constructor & Destructor Documentation

virtual PLRENDERER_API PLRenderer::VertexBuffer::~VertexBuffer ( ) [virtual]

Destructor.

PLRENDERER_API PLRenderer::VertexBuffer::VertexBuffer ( Renderer cRenderer) [protected]

Constructor.

Parameters:
[in]cRendererOwner renderer

Member Function Documentation

PLCore::uint32 PLRenderer::VertexBuffer::GetNumOfVertexAttributes ( ) const [inline]

Returns the number of vertex attributes.

Returns:
Number of vertex attributes

Clears the vertex attributes.

Returns:
'true' if all went fine, else 'false'
Note:
  • This is only possible if the vertex buffer is not allocated (see Allocate())
  • The virtual buffer function Clear() only clears the buffer itself, ClearVertexAttributes() clears the vertex attributes definition
PLRENDERER_API bool PLRenderer::VertexBuffer::AddVertexAttribute ( ESemantic  nSemantic,
PLCore::uint32  nChannel,
EType  nType 
)

Adds vertex attribute.

Parameters:
[in]nSemanticAny member of the vertex attribute semantic enumeration type
[in]nChannelPipeline channel (see ESemantic, maximum see MaxPipelineChannels)
[in]nTypeAny member of the EType enumeration type
Returns:
'true' if all went fine, else 'false' (maybe this vertex attribute is already there)
Note:
  • You shouldn't change the vertex attribute after the vertex buffer was allocated using the Allocate()-function! (performance!)
  • It the buffer is still locked, it's forced to be unlocked immediately if all went fine
const VertexBuffer::Attribute * PLRenderer::VertexBuffer::GetVertexAttribute ( PLCore::uint32  nIndex = 0) const [inline]

Returns a vertex attribute.

Parameters:
[in]nIndexIndex of the vertex attribute which should be returned
Returns:
The requested vertex attribute, a null pointer on error
PLRENDERER_API const Attribute* PLRenderer::VertexBuffer::GetVertexAttribute ( ESemantic  nSemantic,
PLCore::uint32  nChannel = 0 
) const

Returns the first found vertex attribute with the requested semantic.

Parameters:
[in]nSemanticVertex attribute semantic
[in]nChannelPipeline channel (see ESemantic, maximum see MaxPipelineChannels)
Returns:
The first found vertex attribute with the requested semantic, a null pointer on error
PLCore::uint32 PLRenderer::VertexBuffer::GetVertexSize ( ) const [inline]

Returns the vertex size (in bytes)

Returns the vertex size in bytes.

Returns:
Vertex size (in bytes)
PLRENDERER_API VertexBuffer& PLRenderer::VertexBuffer::operator= ( const VertexBuffer cSource)

Copy operator.

Parameters:
[in]cSourceSource to copy from
Returns:
Reference to this object
PLRENDERER_API void PLRenderer::VertexBuffer::CalculateBoundingBox ( PLMath::Vector3 vMinPos,
PLMath::Vector3 vMaxPos,
PLRenderer::IndexBuffer pIndexBuffer = nullptr 
)

Returns the vertex buffer bounding box.

Parameters:
[out]vMinPosWill receive the minimum bounding box position
[out]vMaxPosWill receive the maximum bounding box position
[in]pIndexBufferOptional index buffer to take only a set of vertices into account, set to a null pointer if not used
PLRENDERER_API void PLRenderer::VertexBuffer::CalculateBoundingSphere ( PLMath::Vector3 vPos,
float &  fRadius,
PLRenderer::IndexBuffer pIndexBuffer = nullptr 
)

Returns the vertex buffer bounding sphere.

Parameters:
[out]vPosWill receive the bounding sphere position
[out]fRadiusWill receive the bounding sphere radius
[in]pIndexBufferOptional index buffer to take only a set of vertices into account, set to a null pointer if not used
virtual void* PLRenderer::VertexBuffer::GetData ( PLCore::uint32  nIndex,
PLCore::uint32  nSemantic,
PLCore::uint32  nChannel = 0 
) [pure virtual]

Returns the data of a vertex buffer attribute.

Parameters:
[in]nIndexVertex index
[in]nSemanticAny member of the vertex attribute semantic enumeration type
[in]nChannelPipeline channel (see ESemantic)
Returns:
The data of the locked vertex buffer, a null pointer on error
Note:
  • See GetData() in Buffer
  • This function will give you the correct offset of the requested vertex attribute
  • When manipulating color data you should use GetColor() and SetColor()!
virtual PLGraphics::Color4 PLRenderer::VertexBuffer::GetColor ( PLCore::uint32  nIndex,
PLCore::uint32  nChannel = 0 
) [pure virtual]

Returns the RGBA color of a vertex.

Parameters:
[in]nIndexVertex index
[in]nChannelPipeline channel (see ESemantic)
Returns:
The RGBA color of a vertex
Note:
  • Because the different APIs will store the colors in different formats you should always use this offered color functions which are API independent!
virtual bool PLRenderer::VertexBuffer::SetColor ( PLCore::uint32  nIndex,
const PLGraphics::Color4 cColor,
PLCore::uint32  nChannel = 0 
) [pure virtual]

Set the RGBA color of a vertex.

Parameters:
[in]nIndexVertex index
[in]cColorColor to set
[in]nChannelPipeline channel (see ESemantic)
Returns:
'true' if all went fine, else 'false'
See also:
virtual PLRENDERER_API void* PLRenderer::VertexBuffer::GetData ( ) [override, virtual]

Returns the buffer data.

Returns:
The data of the locked buffer, a null pointer on error (Maybe the buffer isn't locked?)
Note:
  • This function will only work if the buffer is locked (see Lock())
  • Note that the vertex element type size depends on the used API. For instance color, OpenGL will use 4*float to save the color value, but Direct3D will handle colors as PLCore::uint32! Therefore you should use this function carefully! We recommend to use the special functions provided by the vertex buffer interface to manipulate the vertex buffer data.
  • Do NOT delete the returned data!

Implements PLRenderer::Buffer.


Member Data Documentation

const PLCore::uint8 PLRenderer::VertexBuffer::NumOfSemantics = 10 [static]

Number of vertex attribute semantics

const PLCore::uint8 PLRenderer::VertexBuffer::MaxPipelineChannels = 16 [static]

Maximum possible number of channels

The vertex attributes

PLCore::uint32 PLRenderer::VertexBuffer::m_nVertexSize [protected]

Size in bytes of the vertex buffer (in bytes)


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


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:51:24
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported