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:

List of all members.

Classes

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

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.
bool IsMasterBuffer ()
virtual void * Lock (csRenderBufferLockType lockType)
 Lock the buffer to allow reading or writing to it directly.
virtual void Release ()
 Releases the buffer.
virtual void SetCallback (iRenderBufferCallback *cb)
 Set callback object to use.
virtual void SetData (const void *data)
 Set the buffer data.



void SetIndexBufferProperties (size_t elementCount, csRenderBufferType type, csRenderBufferComponentType componentType, size_t rangeStart, size_t rangeEnd, bool copy=true)
 Change properties of a render buffer after creation (DANGEROUS).
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)
 Create an index buffer.
static csRef< csRenderBufferCreateIndexRenderBuffer (size_t elementCount, csRenderBufferType type, csRenderBufferComponentType componentType, size_t rangeStart, size_t rangeEnd)
 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)
 Create an index buffer.
static csRef< csRenderBufferCreateRenderBuffer (size_t elementCount, csRenderBufferType type, csRenderBufferComponentType componentType, uint componentCount)
 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=true)
 Constructor.

Protected Attributes

unsigned char * buffer
 buffer holding the data
size_t bufferSize
 Total size of the buffer.
struct 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

Detailed Description

Render buffer - basic container for mesh geometry data.

Definition at line 58 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 = true 
) [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:
Do not call on a locked buffer. Does not work with interleaved buffer, copy to master buffer instead.

Implements iRenderBuffer.

static csRef<csRenderBuffer> csRenderBuffer::CreateIndexRenderBuffer ( size_t  elementCount,
csRenderBufferType  type,
csRenderBufferComponentType  componentType,
size_t  rangeStart,
size_t  rangeEnd,
bool  copy 
) [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::CreateIndexRenderBuffer ( size_t  elementCount,
csRenderBufferType  type,
csRenderBufferComponentType  componentType,
size_t  rangeStart,
size_t  rangeEnd 
) [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 
) [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::CreateRenderBuffer ( size_t  elementCount,
csRenderBufferType  type,
csRenderBufferComponentType  componentType,
uint  componentCount 
) [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 95 of file renderbuffer.h.

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

Gets the number of components per element.

Implements iRenderBuffer.

Definition at line 85 of file renderbuffer.h.

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

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

Implements iRenderBuffer.

Definition at line 90 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 110 of file renderbuffer.h.

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 129 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 116 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 139 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 137 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 100 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 105 of file renderbuffer.h.

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

Get version.

Implements iRenderBuffer.

Definition at line 119 of file renderbuffer.h.

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

Whether the buffer is an index buffer.

Implements iRenderBuffer.

Definition at line 134 of file renderbuffer.h.

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

Lock the buffer to allow reading or writing to it directly.

Parameters:
lockType The type of lock desired.
Returns:
A pointer to the first element or (void*)-1 if there was some error.
Remarks:
After the data was used as desired Release() must be called.

Implements iRenderBuffer.

virtual void csRenderBuffer::Release (  )  [virtual]

Releases the buffer.

After this all access to the buffer pointer is illegal.

Implements iRenderBuffer.

virtual void csRenderBuffer::SetCallback ( iRenderBufferCallback cb  )  [inline, virtual]

Set callback object to use.

Implements iRenderBuffer.

Definition at line 144 of file renderbuffer.h.

virtual void csRenderBuffer::SetData ( const void *  data  )  [virtual]

Set the buffer data.

This changes the internal pointer to the buffer data to buffer instead. It will also be returned by Lock(). It is the responsibility of the caller to ensure that the memory pointed to by data is valid for as long as the render buffer is used.

Remarks:
Do not call on a locked buffer. Does not work with interleaved buffer, set data on master buffer instead.

Implements iRenderBuffer.

void csRenderBuffer::SetIndexBufferProperties ( size_t  elementCount,
csRenderBufferType  type,
csRenderBufferComponentType  componentType,
size_t  rangeStart,
size_t  rangeEnd,
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.
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 324 of file renderbuffer.h.

size_t csRenderBuffer::bufferSize [protected]

Total size of the buffer.

Definition at line 267 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 318 of file renderbuffer.h.

size_t csRenderBuffer::rangeStart [protected]

range start for index-buffer

Definition at line 316 of file renderbuffer.h.

unsigned int csRenderBuffer::version [protected]

modification number

Definition at line 321 of file renderbuffer.h.


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

Generated for Crystal Space 2.0 by doxygen 1.6.1