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

Abstract renderer index buffer (IBO) resource. More...

#include <IndexBuffer.h>

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

List of all members.

Public Types

enum  EType { UInt = 0, UShort = 1, UByte = 2 }
 Vertex index types. More...

Public Member Functions

virtual PLRENDERER_API ~IndexBuffer ()
 Destructor.
EType GetElementType () const
 Returns the type of the buffer elements.
bool SetElementType (EType nType=UShort)
 Sets the type of the buffer elements.
bool SetElementTypeByMaximumIndex (PLCore::uint32 nMaximumIndex)
 Sets the type of the buffer elements automatically by using a given maximum vertex index.
PLRENDERER_API IndexBufferoperator= (const IndexBuffer &cSource)
 Copy operator.
PLRENDERER_API PLCore::uint32 GetData (PLCore::uint32 nIndex)
 Returns the data of the index buffer.
PLRENDERER_API bool SetData (PLCore::uint32 nIndex, PLCore::uint32 nData)
 Sets the data of the index buffer.
virtual PLRENDERER_API void * GetData () override
 Returns the buffer data.

Static Public Attributes

static const PLCore::uint32 MaxVertexIndexUShort = 65535
static const PLCore::uint32 MaxVertexIndexUByte = 255

Protected Member Functions

PLRENDERER_API IndexBuffer (Renderer &cRenderer)
 Constructor.

Protected Attributes

EType m_nElementType

Detailed Description

Abstract renderer index buffer (IBO) resource.


Member Enumeration Documentation

Vertex index types.

Enumerator:
UInt 

Unsigned int (may not be supported by each API)

UShort 

Unsigned short (default)

UByte 

Unsigned byte (may not be supported by each API)

Reimplemented from PLRenderer::Resource.


Constructor & Destructor Documentation

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

Destructor.

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

Constructor.

Parameters:
[in]cRendererOwner renderer

Member Function Documentation

Returns the type of the buffer elements.

Returns:
The type of the buffer elements

Sets the type of the buffer elements.

Parameters:
[in]nTypeThe type of the buffer elements
Returns:
'true' if all went fine, else 'false' (maybe the buffer is already allocated)
Note:
  • It's only possible to change the element type if the buffer isn't allocated
  • Try to avoid UInt whenever possible for more performance and better compatibility to for example mobile graphics API's
bool PLRenderer::IndexBuffer::SetElementTypeByMaximumIndex ( PLCore::uint32  nMaximumIndex) [inline]

Sets the type of the buffer elements automatically by using a given maximum vertex index.

Parameters:
[in]nMaximumIndexMaximum vertex index
Returns:
'true' if all went fine, else 'false' (maybe the buffer is already allocated)
Remarks:
If the given maximum vertex index is <= 'MaxVertexIndexUByte' the type 'EByte' is chosen. If the given maximum vertex index is <= 'MaxVertexIndexUShort' the type 'EShort' is chosen, else 'UInt'. Please don't oversight the '='. If you have n vertices, the last one has the index n-1 because we start counting at zero.
See also:
PLRENDERER_API IndexBuffer& PLRenderer::IndexBuffer::operator= ( const IndexBuffer cSource)

Copy operator.

Parameters:
[in]cSourceSource to copy from
Returns:
Reference to this object
PLRENDERER_API PLCore::uint32 PLRenderer::IndexBuffer::GetData ( PLCore::uint32  nIndex)

Returns the data of the index buffer.

Parameters:
[in]nIndexIndex index
Returns:
Index data
Note:
  • This function will give you the correct data of the requested index, therefore you should always use this function to be not forced to worry about the internal index data type. (see EType)
See also:
PLRENDERER_API bool PLRenderer::IndexBuffer::SetData ( PLCore::uint32  nIndex,
PLCore::uint32  nData 
)

Sets the data of the index buffer.

Parameters:
[in]nIndexIndex index
[in]nDataData to set
Returns:
'true' if all went fine, else 'false'
See also:
virtual PLRENDERER_API void* PLRenderer::IndexBuffer::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::uint32 PLRenderer::IndexBuffer::MaxVertexIndexUShort = 65535 [static]

Maximum vertex index which can be used if UShort is used as index buffer type

const PLCore::uint32 PLRenderer::IndexBuffer::MaxVertexIndexUByte = 255 [static]

Maximum vertex index which can be used if UByte is used as index buffer type

Element type


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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:38
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported