CrystalSpace

Public API Reference

csRenderBuffer Class Reference
[Graphics]

Render buffer - basic container for mesh geometry data. More...

#include <csgfx/renderbuffer.h>

Inheritance diagram for csRenderBuffer:

Inheritance graph
[legend]
List of all members.

Public Member Functions

virtual ~csRenderBuffer ()
 Destructor.
iRenderBuffer implementation
virtual void CopyInto (const void *data, size_t elementCount, size_t elemOffset=0)
 Copy data to the render buffer.
virtual csRenderBufferType GetBufferType () const
 Get type of buffer (static/dynamic).
virtual int GetComponentCount () const
 Gets the number of components per element.
virtual csRenderBufferComponentType GetComponentType () const
 Gets the component type (float, int, etc).
virtual size_t GetElementCount () const
 Number of elements in a buffer.
virtual size_t GetElementDistance () const
 Get the distance between two elements (in bytes, includes stride).
virtual iRenderBufferGetMasterBuffer () const
 Get the master buffer in case this is an interleaved buffer.
virtual size_t GetOffset () const
 Get the offset of the buffer (in bytes).
virtual size_t GetRangeEnd () const
 The highest index contained in this buffer, only valid for index buffers.
virtual size_t GetRangeStart () const
 The lowest index contained in this buffer, only valid for index buffers.
virtual size_t GetSize () const
 Get the size of the buffer (in bytes).
virtual size_t GetStride () const
 Get the stride of the buffer (in bytes).
virtual uint GetVersion ()
 Get version.
virtual bool IsIndexBuffer () const
 Whether the buffer is an index buffer.
virtual bool IsMasterBuffer ()
virtual void * Lock (csRenderBufferLockType lockType)
 Lock the buffer to allow writing and return a pointer to the first element.
virtual void Release ()
 Releases the buffer.
void SetRenderBufferProperties (size_t elementCount, csRenderBufferType type, csRenderBufferComponentType componentType, uint componentCount, bool copy=true)
 Change properties of a render buffer after creation (DANGEROUS).

Static Public Member Functions

Render buffer creation
static csRef< csRenderBufferCreateIndexRenderBuffer (size_t elementCount, csRenderBufferType type, csRenderBufferComponentType componentType, size_t rangeStart, size_t rangeEnd, bool copy=true)
 Create an index buffer.
static csRef< csRenderBufferCreateInterleavedRenderBuffers (size_t elementCount, csRenderBufferType type, uint count, const csInterleavedSubBufferOptions *elements, csRef< iRenderBuffer > *buffers)
 Create an interleaved renderbuffer (You would use this then set stride to determine offset and stride of the interleaved buffer.
static csRef< csRenderBufferCreateRenderBuffer (size_t elementCount, csRenderBufferType type, csRenderBufferComponentType componentType, uint componentCount, bool copy=true)
 Create a render buffer.
"Friendly" name utilities
static csRenderBufferName GetBufferNameFromDescr (const char *name)
 Retrieve the buffer name for a "friendly" buffer description.
static const char * GetDescrFromBufferName (csRenderBufferName bufferName)
 Utility to retrieve the "friendly" string name of a buffer description, e.g.

Protected Member Functions

 csRenderBuffer (size_t size, csRenderBufferType type, csRenderBufferComponentType componentType, uint componentCount, size_t rangeStart, size_t rangeEnd, bool copy)
 Constructor.

Protected Attributes

unsigned char * buffer
 buffer holding the data
size_t bufferSize
 Total size of the buffer.
csRef< iRenderBuffermasterBuffer
csRenderBuffer::Props props
 To scrape off a few bytes use bitfields; assumes values are in sane limits.
size_t rangeEnd
 range start for index-buffer
size_t rangeStart
 range start for index-buffer
unsigned int version
 modification number

Classes

struct  Props
 To scrape off a few bytes use bitfields; assumes values are in sane limits. More...

Detailed Description

Render buffer - basic container for mesh geometry data.

Definition at line 55 of file renderbuffer.h.


Constructor & Destructor Documentation

csRenderBuffer::csRenderBuffer ( size_t  size,
csRenderBufferType  type,
csRenderBufferComponentType  componentType,
uint  componentCount,
size_t  rangeStart,
size_t  rangeEnd,
bool  copy 
) [protected]

Constructor.

virtual csRenderBuffer::~csRenderBuffer (  )  [virtual]

Destructor.


Member Function Documentation

virtual void csRenderBuffer::CopyInto ( const void *  data,
size_t  elementCount,
size_t  elemOffset = 0 
) [virtual]

Copy data to the render buffer.

Remarks:
Does not work with interleaved buffer, copy to master buffer instead. A buffer may actually not make a copy of the data but only store a pointer to it. Whether this is the case depends on the actual implementation and/or parameters to the buffer creation.

Implements iRenderBuffer.

static csRef<csRenderBuffer> csRenderBuffer::CreateIndexRenderBuffer ( size_t  elementCount,
csRenderBufferType  type,
csRenderBufferComponentType  componentType,
size_t  rangeStart,
size_t  rangeEnd,
bool  copy = true 
) [static]

Create an index buffer.

Parameters:
elementCount Number of elements in the buffer.
type Type of buffer; CS_BUF_DYNAMIC, CS_BUF_STATIC or CS_BUF_STREAM.
componentType Components Types; usually CS_BUFCOMP_UNSIGNED_INT
rangeStart Minimum index value that is expected to be written to the created buffer.
rangeEnd Maximum index value that is expected to be written to the created buffer.
copy if true (default) then this buffer will make a copy of the data, else just save the buffer pointers provided by the caller. This has some implications: CopyInto() does not copy, merely update the internal buffer pointer. Lock() just returns that pointer. The pointer passed to CopyInto() must be valid over the lifetime of the render buffer.

static csRef<csRenderBuffer> csRenderBuffer::CreateInterleavedRenderBuffers ( size_t  elementCount,
csRenderBufferType  type,
uint  count,
const csInterleavedSubBufferOptions elements,
csRef< iRenderBuffer > *  buffers 
) [static]

Create an interleaved renderbuffer (You would use this then set stride to determine offset and stride of the interleaved buffer.

Parameters:
elementCount Number of elements in the buffer.
type Type of buffer; CS_BUF_DYNAMIC, CS_BUF_STATIC or CS_BUF_STREAM.
count number of render buffers you want
elements Array of csInterleavedSubBufferOptions describing the properties of the individual buffers to be interleaved.
buffers an array of render buffer references that can hold at least 'count' render buffers.
Example on creating an interleaved buffer consisting of one three and two component float buffer:
  static const csInterleavedSubBufferOptions interleavedElements[2] =
    {{CS_BUFCOMP_FLOAT, 3}, {CS_BUFCOMP_FLOAT, 2}};
  csRef<iRenderBuffer> buffers[2];
  csRenderBuffer::CreateInterleavedRenderBuffers (num_verts, CS_BUF_STATIC,
    2, interleavedElements, buffers);
  csRef<iRenderBuffer> vertex_buffer = buffers[0];
  csRef<iRenderBuffer> texel_buffer = buffers[1];

static csRef<csRenderBuffer> csRenderBuffer::CreateRenderBuffer ( size_t  elementCount,
csRenderBufferType  type,
csRenderBufferComponentType  componentType,
uint  componentCount,
bool  copy = true 
) [static]

Create a render buffer.

Parameters:
elementCount Number of elements in the buffer.
type Type of buffer; CS_BUF_DYNAMIC, CS_BUF_STATIC or CS_BUF_STREAM.
componentType Components Types; CS_BUFCOMP_FLOAT, CS_BUFCOMP_INT, etc
componentCount Number of components per element (e.g. 4 for RGBA)
copy if true (default) then this buffer will make a copy of the data, else just save the buffer pointers provided by the caller. This has some implications: CopyInto() does not copy, merely update the internal buffer pointer. Lock() just returns that pointer. The pointer passed to CopyInto() must be valid over the lifetime of the render buffer.

static csRenderBufferName csRenderBuffer::GetBufferNameFromDescr ( const char *  name  )  [static]

Retrieve the buffer name for a "friendly" buffer description.

Can be used to parse e.g. shader files.

virtual csRenderBufferType csRenderBuffer::GetBufferType (  )  const [inline, virtual]

Get type of buffer (static/dynamic).

Implements iRenderBuffer.

Definition at line 92 of file renderbuffer.h.

virtual int csRenderBuffer::GetComponentCount (  )  const [inline, virtual]

Gets the number of components per element.

Implements iRenderBuffer.

Definition at line 82 of file renderbuffer.h.

virtual csRenderBufferComponentType csRenderBuffer::GetComponentType (  )  const [inline, virtual]

Gets the component type (float, int, etc).

Implements iRenderBuffer.

Definition at line 87 of file renderbuffer.h.

static const char* csRenderBuffer::GetDescrFromBufferName ( csRenderBufferName  bufferName  )  [static]

Utility to retrieve the "friendly" string name of a buffer description, e.g.

"position" for CS_BUFFER_POSITION.

virtual size_t csRenderBuffer::GetElementCount (  )  const [virtual]

Number of elements in a buffer.

Implements iRenderBuffer.

virtual size_t csRenderBuffer::GetElementDistance (  )  const [inline, virtual]

Get the distance between two elements (in bytes, includes stride).

Implements iRenderBuffer.

Definition at line 107 of file renderbuffer.h.

References csRenderBufferComponentSizes.

virtual iRenderBuffer* csRenderBuffer::GetMasterBuffer (  )  const [inline, virtual]

Get the master buffer in case this is an interleaved buffer.

The master buffer is the buffer that actually holds the data; while it can be used to retrieve or set data, it must not be used for actual rendering. Use the interleaved buffers instead.

Implements iRenderBuffer.

Definition at line 127 of file renderbuffer.h.

virtual size_t csRenderBuffer::GetOffset (  )  const [inline, virtual]

Get the offset of the buffer (in bytes).

Implements iRenderBuffer.

Definition at line 113 of file renderbuffer.h.

virtual size_t csRenderBuffer::GetRangeEnd (  )  const [inline, virtual]

The highest index contained in this buffer, only valid for index buffers.

Implements iRenderBuffer.

Definition at line 137 of file renderbuffer.h.

virtual size_t csRenderBuffer::GetRangeStart (  )  const [inline, virtual]

The lowest index contained in this buffer, only valid for index buffers.

Implements iRenderBuffer.

Definition at line 135 of file renderbuffer.h.

virtual size_t csRenderBuffer::GetSize (  )  const [inline, virtual]

Get the size of the buffer (in bytes).

Implements iRenderBuffer.

Definition at line 97 of file renderbuffer.h.

virtual size_t csRenderBuffer::GetStride (  )  const [inline, virtual]

Get the stride of the buffer (in bytes).

Implements iRenderBuffer.

Definition at line 102 of file renderbuffer.h.

virtual uint csRenderBuffer::GetVersion (  )  [inline, virtual]

Get version.

Implements iRenderBuffer.

Definition at line 117 of file renderbuffer.h.

virtual bool csRenderBuffer::IsIndexBuffer (  )  const [inline, virtual]

Whether the buffer is an index buffer.

Implements iRenderBuffer.

Definition at line 132 of file renderbuffer.h.

virtual void* csRenderBuffer::Lock ( csRenderBufferLockType  lockType  )  [virtual]

Lock the buffer to allow writing and return a pointer to the first element.

The pointer will be (void*)-1 if there was some error.

Parameters:
lockType The type of lock desired.

Implements iRenderBuffer.

virtual void csRenderBuffer::Release (  )  [virtual]

Releases the buffer.

After this all access to the buffer pointer is illegal.

Implements iRenderBuffer.

void csRenderBuffer::SetRenderBufferProperties ( size_t  elementCount,
csRenderBufferType  type,
csRenderBufferComponentType  componentType,
uint  componentCount,
bool  copy = true 
)

Change properties of a render buffer after creation (DANGEROUS).

Warning:
If the buffer was already passed around and is thus probably used somewhere, changing properties with this methiod is a sure-fire way to wreak havoc. This function is useful in very very specific scenarios; only use it if you really know what you're doing.


Member Data Documentation

unsigned char* csRenderBuffer::buffer [protected]

buffer holding the data

Definition at line 296 of file renderbuffer.h.

size_t csRenderBuffer::bufferSize [protected]

Total size of the buffer.

Definition at line 245 of file renderbuffer.h.

To scrape off a few bytes use bitfields; assumes values are in sane limits.

size_t csRenderBuffer::rangeEnd [protected]

range start for index-buffer

Definition at line 290 of file renderbuffer.h.

size_t csRenderBuffer::rangeStart [protected]

range start for index-buffer

Definition at line 288 of file renderbuffer.h.

unsigned int csRenderBuffer::version [protected]

modification number

Definition at line 293 of file renderbuffer.h.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.4.7