PixelLightAPI  .
Public Member Functions | Protected Member Functions | Protected Attributes
PLRenderer::Buffer Class Reference

Abstract renderer buffer resource base class. More...

#include <Buffer.h>

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

List of all members.

Public Member Functions

virtual PLRENDERER_API ~Buffer ()
 Destructor.
PLCore::uint32 GetNumOfElements () const
 Returns the number of buffer elements.
PLCore::uint32 GetSize () const
 Returns the buffer size (in bytes)
Usage::Enum GetUsage () const
 Returns the usage flag.
bool IsManaged () const
 Returns whether the buffer is managed or not.
PLCore::uint16 GetLockCount () const
 Returns the lock count.
virtual bool IsAllocated () const =0
 Returns whether the buffer is allocated or not.
virtual bool Allocate (PLCore::uint32 nElements, Usage::Enum nUsage=Usage::Dynamic, bool bManaged=true, bool bKeepData=false)=0
 Allocates the buffer.
virtual bool Clear ()=0
 Clears the buffer.
virtual void * Lock (PLCore::uint32 nFlag=Lock::ReadWrite)=0
 Locks the buffer.
virtual void * GetData ()=0
 Returns the buffer data.
virtual bool Unlock ()=0
 Unlocks the buffer.

Protected Member Functions

PLRENDERER_API Buffer (Renderer &cRenderer, EType nType)
 Constructor.
bool ForceUnlock ()
 Forces immediately buffer unlock.

Protected Attributes

PLCore::uint32 m_nElements
PLCore::uint32 m_nSize
Usage::Enum m_nUsage
bool m_bManaged
PLCore::uint16 m_nLockCount
PLCore::uint64 m_nLockStartTime

Detailed Description

Abstract renderer buffer resource base class.


Constructor & Destructor Documentation

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

Destructor.

PLRENDERER_API PLRenderer::Buffer::Buffer ( Renderer cRenderer,
EType  nType 
) [protected]

Constructor.

Parameters:
[in]cRendererOwner renderer
[in]nTypeResource type

Member Function Documentation

PLCore::uint32 PLRenderer::Buffer::GetNumOfElements ( ) const [inline]

Returns the number of buffer elements.

Returns:
Number of buffer elements
PLCore::uint32 PLRenderer::Buffer::GetSize ( ) const [inline]

Returns the buffer size (in bytes)

Returns the buffer size.

Returns:
Buffer size (in bytes)

Returns the usage flag.

Returns:
Usage flag
bool PLRenderer::Buffer::IsManaged ( ) const [inline]

Returns whether the buffer is managed or not.

Returns:
'true' if the buffer is managed, else 'false'
See also:
PLCore::uint16 PLRenderer::Buffer::GetLockCount ( ) const [inline]

Returns the lock count.

Returns:
0 if the buffer is currently unlocked, else the lock count is returned
virtual bool PLRenderer::Buffer::IsAllocated ( ) const [pure virtual]

Returns whether the buffer is allocated or not.

Returns:
'true' if the buffer is allocated, else 'false'
virtual bool PLRenderer::Buffer::Allocate ( PLCore::uint32  nElements,
Usage::Enum  nUsage = Usage::Dynamic,
bool  bManaged = true,
bool  bKeepData = false 
) [pure virtual]

Allocates the buffer.

Parameters:
[in]nElementsNumber of elements
[in]nUsageUsage flag indicating the expected application usage pattern of the data store
[in]bManagedIf the render buffer is managed, for instance shadow buffers (system memory copies that allow for faster reads) are used internally.
[in]bKeepDataShould the current buffer content be restored after the buffer was reallocated?
Returns:
'true' if all went fine, else 'false'
Note:
  • If the buffer is already allocated, it is reallocated if required
  • When allocating a vertex buffer, you first have to define the vertex attributes before allocating the vertex buffer
  • After an index buffer is allocated, you can't edit the index element type
  • nUsage is useful for drivers because it enables them to decide where to place the buffer. In general, static buffers are placed in video memory and dynamic buffers are placed in accelerated graphics port (AGP) memory.
  • If the usage is 'Usage::Software', 'bManaged' will have no effect because the data is only hold within the system memory
  • It the buffer is still locked, it's forced to be unlocked immediately if all went fine
virtual bool PLRenderer::Buffer::Clear ( ) [pure virtual]

Clears the buffer.

Returns:
'true' if all went fine, else 'false'
Note:
  • It the buffer is still locked, it's forced to be unlocked immediately if all went fine
virtual void* PLRenderer::Buffer::Lock ( PLCore::uint32  nFlag = Lock::ReadWrite) [pure virtual]

Locks the buffer.

Parameters:
[in]nFlagAccess flag which describes the operations which should be performed on the locked buffer. This can be any member of the lock enumeration type.
Returns:
The data of the locked buffer, a null pointer on error (Maybe the buffer isn't allocated?)
Note:
  • Each time you lock a buffer, you have to unlock it after you finished your work, too!
  • If the buffer is currently locked, do not call functions like Clear(), Allocate() etc., such functions will force the buffer to be unlocked and your pointers will become invalid!
  • Do NOT delete the returned data!
virtual void* PLRenderer::Buffer::GetData ( ) [pure 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!

Implemented in PLRenderer::VertexBuffer, PLRenderer::IndexBuffer, and PLRenderer::UniformBuffer.

virtual bool PLRenderer::Buffer::Unlock ( ) [pure virtual]

Unlocks the buffer.

Returns:
'true' if all went fine, else 'false' (Maybe the buffer isn't locked?)
See also:
bool PLRenderer::Buffer::ForceUnlock ( ) [inline, protected]

Forces immediately buffer unlock.

Forces immediately vertex buffer unlock.

Returns:
'true' if all went fine, else 'false' (Maybe the buffer isn't locked?)

Member Data Documentation

PLCore::uint32 PLRenderer::Buffer::m_nElements [protected]

Number of buffer elements

PLCore::uint32 PLRenderer::Buffer::m_nSize [protected]

Buffer size (in bytes)

Usage flag

Is the buffer managed?

PLCore::uint16 PLRenderer::Buffer::m_nLockCount [protected]

Lock count

PLCore::uint64 PLRenderer::Buffer::m_nLockStartTime [protected]

Time where the buffer was locked


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:22
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported