Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

PolygonBuffer Class Reference

#include <polygonbuffer.h>

Inheritance diagram for PolygonBuffer:

Inheritance graph
[legend]
Collaboration diagram for PolygonBuffer:

Collaboration graph
[legend]
List of all members.

Detailed Description

Buffer for storing polygons (triangles) A polygon buffer holds data for a number of polygons (triangles) and optionally a strip, material and vertex buffer. Polygon buffers are managed and reference counted.

Author:
Mattias Jansson (mattias@realityrift.com)


Public Types

enum  BUFFERTYPE {
  DYNAMIC = 0x00000000, STATIC = 0x00000001, READPRIORITIZED = 0x00000002, WRITEPRIORITIZED = 0x00000004,
  NOREADWRITE = 0x00000008, NORENDER = 0x00000010, NORMAL = ( DYNAMIC | READPRIORITIZED | WRITEPRIORITIZED )
}
 Buffer type identifiers. Any combination of the flags is valid. More...

enum  BUFFERUPLOADPOLICY { ONUNLOCK, ONRENDER, ONFLUSH }
 Upload policy identifiers. More...

enum  BUFFERLOCK { READ = 1, WRITE = 2, NOUPLOAD = 4, FORCEUPLOAD = 8 }
 Lock type identifiers. More...


Public Member Functions

 PolygonBuffer (unsigned int uiType, unsigned int uiNumPolygons, const Polygon *pkData=0, bool bStripify=false)
virtual ~PolygonBuffer ()
virtual void AllocatePolygons (unsigned int iNumPolygons, const Polygon *pkData=0, bool bStripify=false)
void LoadPolygonData (const Polygon *pkPolygons, bool bStripify=false)
void Stripify ()
bool IsStripped () const
void CalculateNormals (VertexBufferPtr pkVertexBuffer=0, bool bNormalize=true)
void CalculateEdges (VertexBufferPtr pkVertexBuffer=0)
Vector3dGetNormals ()
EdgeGetEdges ()
PolygonStripBufferPtr & GetStrip ()
PolygonGetPolygon (unsigned int uiElement=0)
virtual const void * GetRenderData () const
Polygonoperator[] (unsigned int uiElement)
bool Lock (unsigned int uiLockType)
void Unlock ()
virtual void Upload ()
bool IsLocked () const
bool IsDirty () const
unsigned int GetType () const
unsigned int GetNumAllocated () const
unsigned int GetNumElements () const
void SetNumElements (unsigned int uiNumElements)
void IncRef ()
void DecRef ()
int GetRefCount () const

Static Public Member Functions

std::string GetTypeAsString (unsigned int uiType)
unsigned int GetTypeFromString (std::string const &strType)

Public Attributes

PolygonStripBufferPtr m_pkStrip
VertexBufferPtr m_pkVertexBuffer
MaterialPtr m_pkMaterial

Static Public Attributes

BUFFERUPLOADPOLICY s_eUploadPolicy

Protected Member Functions

void ExtendStrip (unsigned int uiPolygon, unsigned int uiEdge, AdjacencyData *pkAdj, unsigned int *puiStrip, unsigned int *puiStripLen, unsigned char *pucAdded)
virtual bool AcquireLock ()
virtual void ReleaseLock ()

Protected Attributes

Polygonm_pkBuffer
Polygonm_pkPolygons
Vector3dm_pkNormals
Edgem_pkEdges
unsigned int m_uiType
unsigned int m_uiLock
bool m_bDirty
unsigned int m_uiNumAllocated
unsigned int m_uiNumCurrent


Member Enumeration Documentation

enum BUFFERTYPE [inherited]
 

Buffer type identifiers. Any combination of the flags is valid.

Enumeration values:
DYNAMIC  Dynamic buffer with system RAM backing store
STATIC  AGP or VRAM storage if possible
READPRIORITIZED  Prioritize read access
WRITEPRIORITIZED  Prioritize write accesss
NOREADWRITE  Buffer that can never be read from or written to, must pass data pointer to ctor
NORENDER  Buffer that must never be sent for rendering, guaranteed to not use video RAM resources
NORMAL  Default type

enum BUFFERUPLOADPOLICY [inherited]
 

Upload policy identifiers.

Enumeration values:
ONUNLOCK  Upload after WRITE lock released
ONRENDER  Upload when used in render primitive queued for render
ONFLUSH  Upload when used in render pipeline flush

enum BUFFERLOCK [inherited]
 

Lock type identifiers.

Enumeration values:
READ  Read access
WRITE  Write access (implies read access)
NOUPLOAD  No upload on unlock, will cause upload-on-render
FORCEUPLOAD  Force upload on unlock


Constructor & Destructor Documentation

PolygonBuffer unsigned int  uiType,
unsigned int  uiNumPolygons,
const Polygon pkData = 0,
bool  bStripify = false
[inline]
 

Parameters:
uiType Buffer type
uiNumPolygons Number of polygons
pkData Source data
bStripify Stripify polygon buffer if true

virtual ~PolygonBuffer  )  [virtual]
 

Deallocate memory (normal and edge buffers)


Member Function Documentation

void ExtendStrip unsigned int  uiPolygon,
unsigned int  uiEdge,
AdjacencyData pkAdj,
unsigned int *  puiStrip,
unsigned int *  puiStripLen,
unsigned char *  pucAdded
[protected]
 

Helper method in stripify process

Parameters:
uiPolygon Start polygon
uiEdge Start edge
pkAdj Adjacency data buffer
puiStrip Destination polygon index strip buffer
puiStripLen Pointer to int with strip length
pucAdded Flag buffer for added triangles

virtual bool AcquireLock  )  [inline, protected, virtual]
 

Acquire lock

Returns:
true if lock successful, false if not

Implements Buffer.

virtual void ReleaseLock  )  [inline, protected, virtual]
 

Release lock

Implements Buffer.

virtual void AllocatePolygons unsigned int  iNumPolygons,
const Polygon pkData = 0,
bool  bStripify = false
[virtual]
 

Allocate memory. There must be no lock held on buffer when calling this method

Parameters:
iNumPolygons Number of polygons to allocate memory for
pkData Source data
bStripify Stripify buffer

void LoadPolygonData const Polygon pkPolygons,
bool  bStripify = false
[inline]
 

Load data, must hold active WRITE lock

Parameters:
pkPolygons Polygon data (m_uiNumPolygons of them)
bStripify If true create triangle strip cache of data, clear any existing strips if false

void Stripify  ) 
 

Stripify buffer. Buffer must not be locked. Will replace the current strip

bool IsStripped  )  const [inline]
 

Returns:
true if buffer has been successfully cached in triangle strips

void CalculateNormals VertexBufferPtr  pkVertexBuffer = 0,
bool  bNormalize = true
 

Force recalucation of polygon normals. Buffer must not be locked.

Parameters:
pkVertexBuffer Optional vertex buffer to use if no buffer set in m_pkVertexBuffer. Vertex buffer should be unlocked.
bNormalize If true, normalize normals. If false, just use cross product of edges

void CalculateEdges VertexBufferPtr  pkVertexBuffer = 0  ) 
 

Force recalculation of edges. Buffer must not be locked.

Parameters:
pkVertexBuffer Optional vertex buffer to use if no buffer set in m_pkVertexBuffer. Vertex buffer should be unlocked.

Vector3d* GetNormals  )  [inline]
 

Returns:
Pointer to normal array

Edge* GetEdges  )  [inline]
 

Returns:
Pointer to edge array

PolygonStripBufferPtr& GetStrip  )  [inline]
 

Returns:
Strip buffer object

Polygon* GetPolygon unsigned int  uiElement = 0  )  [inline]
 

Parameters:
uiElement Element to access
Returns:
Polygon object

virtual const void* GetRenderData  )  const [inline, virtual]
 

Get pointer to render data. Used by derived buffer classes in device with AGP/video RAM storage to return pointer to data used for rendering.

Returns:
Render data pointer

Polygon& operator[] unsigned int  uiElement  )  [inline]
 

Array access

Parameters:
uiElement Element to access

bool Lock unsigned int  uiLockType  )  [inline, inherited]
 

Lock buffer for read/write operation

Parameters:
uiLockType Lock type
Returns:
true if lock acquired, false if failed (already locked)

void Unlock  )  [inline, inherited]
 

Unlock buffer

virtual void Upload  )  [inline, virtual, inherited]
 

Upload data to backing store, reset dirty flag

bool IsLocked  )  const [inline, inherited]
 

Returns:
true if buffer is locked, false if not

bool IsDirty  )  const [inline, inherited]
 

Returns:
true if buffer is dirty, false if not

unsigned int GetType  )  const [inline, inherited]
 

Returns:
Buffer type

unsigned int GetNumAllocated  )  const [inline, inherited]
 

Returns:
Number of allocated elements

unsigned int GetNumElements  )  const [inline, inherited]
 

Returns:
Number of currently used elements

void SetNumElements unsigned int  uiNumElements  )  [inline, inherited]
 

Set new count of currently used elements

Parameters:
uiNumElements Number of elements currently used, will be clamped to [0,numallocated] range

std::string GetTypeAsString unsigned int  uiType  )  [static, inherited]
 

Get buffer type as string

Parameters:
uiType Type identifier
Returns:
Type as string

unsigned int GetTypeFromString std::string const &  strType  )  [static, inherited]
 

Get buffer type from string

Parameters:
strType String type identifier
Returns:
Type id

void IncRef  )  [inline, inherited]
 

Increase reference count

void DecRef  )  [inline, inherited]
 

Decrease reference count and garbage collect if 0

int GetRefCount  )  const [inline, inherited]
 

Returns:
Current reference count


Member Data Documentation

Polygon* m_pkBuffer [protected]
 

Real buffer

Polygon* m_pkPolygons [protected]
 

Buffer

Vector3d* m_pkNormals [protected]
 

Normals

Edge* m_pkEdges [protected]
 

Edges

PolygonStripBufferPtr m_pkStrip
 

Triangle strip

VertexBufferPtr m_pkVertexBuffer
 

Vertex buffer we use (optional). Will not be deallocated by dtor

MaterialPtr m_pkMaterial
 

Material we use (optional)

unsigned int m_uiType [protected, inherited]
 

Buffer type

unsigned int m_uiLock [protected, inherited]
 

Current lock type held

bool m_bDirty [protected, inherited]
 

Dirty flag

unsigned int m_uiNumAllocated [protected, inherited]
 

Number of allocated elements

unsigned int m_uiNumCurrent [protected, inherited]
 

Number of currently used elements

BUFFERUPLOADPOLICY s_eUploadPolicy [static, inherited]
 

Buffer upload policy


The documentation for this class was generated from the following file:
Generated on Wed Jan 21 14:21:13 2004 for NeoEngine by doxygen 1.3.5