NL3D::CVertexBuffer Class Reference

A vertex buffer to work with the driver. More...

#include <vertex_buffer.h>

Inherits NLMISC::CRefCount.

List of all members.

Public Types

enum  TPreferredMemory {
  RAMPreferred = 0, AGPPreferred, StaticPreferred, RAMVolatile,
  AGPVolatile, PreferredCount
}
 

Type of preferred memory.

More...
enum  TLocation {
  RAMResident = 0, AGPResident, VRAMResident, NotResident,
  LocationCount
}
 

Type of buffer location.

More...
enum  TValue {
  Position = 0, Normal = 1, TexCoord0 = 2, TexCoord1 = 3,
  TexCoord2 = 4, TexCoord3 = 5, TexCoord4 = 6, TexCoord5 = 7,
  TexCoord6 = 8, TexCoord7 = 9, PrimaryColor = 10, SecondaryColor = 11,
  Weight = 12, PaletteSkin = 13, Fog = 14, Empty = 15,
  NumValue = 16
}
 

Value ID, there is 16 value id.

More...
enum  { FirstTexCoordValue = TexCoord0, LastTexCoordValue = TexCoord7 }
 

Misc infos.

More...
enum  {
  PositionFlag = 1<<Position, NormalFlag = 1<<Normal, TexCoord0Flag = 1<<TexCoord0, TexCoord1Flag = 1<<TexCoord1,
  TexCoord2Flag = 1<<TexCoord2, TexCoord3Flag = 1<<TexCoord3, TexCoord4Flag = 1<<TexCoord4, TexCoord5Flag = 1<<TexCoord5,
  TexCoord6Flag = 1<<TexCoord6, TexCoord7Flag = 1<<TexCoord7, PrimaryColorFlag = 1<<PrimaryColor, SecondaryColorFlag = 1<<SecondaryColor,
  WeightFlag = 1<<Weight, PaletteSkinFlag = (1<<PaletteSkin)|(1<<Weight), FogFlag = 1<<Fog, EmptyFlag = 1<<Empty
}
 

Value flags.

More...
enum  TType {
  Double1 = 0, Float1, Short1, Double2,
  Float2, Short2, Double3, Float3,
  Short3, Double4, Float4, Short4,
  UChar4, NumType
}
 

Value type, there is 13 kind of value type as in DirectX8 and gl_vertex_program used in exteneded mode.

More...
enum  { MaxStage = 8, MaxWeight = 4 }
 

Some constants.

More...
enum  TVertexColorType { TRGBA = 0, TBGRA = 1 }
 

Vertex color format.

More...
enum  { TouchedVertexFormat = 1, TouchedNumVertices = 2, TouchedReserve = 4, TouchedAll = 0xFFFF }
 

Internal flags.

More...

Public Member Functions

 CVertexBuffer (void)
 Default constructor.
 CVertexBuffer (const char *name)
 Named vertex buffer.
 CVertexBuffer (const CVertexBuffer &vb)
 Copy constructor.
 ~CVertexBuffer (void)
 Destructor.
CVertexBufferoperator= (const CVertexBuffer &vb)
 Copy operator.
void copyVertices (CVertexBuffer &dest) const
 Copy a vertex buffer, including vertices data.
void setPreferredMemory (TPreferredMemory preferredMemory, bool keepLocalMemory)
 Set the buffer preferred memory.
TPreferredMemory getPreferredMemory () const
 Get the vertex buffer preferred memory.
bool getKeepLocalMemory () const
 Get the keep local memory flag.
TLocation getLocation () const
 Get the vertex buffer current location.
bool isResident () const
 Returns if the vertex buffer is driver resident or not.
void setNumVertices (uint32 n)
 Set the number of active vertices.
uint32 getNumVertices (void) const
 Get the number of active vertices.
void deleteAllVertices ()
 Reset all the vertices from memory (contReset()), so that capacity() == getNumVertices() == 0.
void reserve (uint32 nVerts)
 Reserve space for nVerts vertices.
uint32 capacity ()
 Return the number of vertices reserved.
uint16 getVertexSize (void) const
 Return the size of a vertex.
TType getValueType (uint value) const
 Return the type of a value.
const uint8getValueTypePointer () const
 Return the type array.
uint8 getNumWeight () const
 Return number of weight value in vertices.
void serial (NLMISC::IStream &f)
 If the buffer preferres AGP memory, the data are lost.
void lock (CVertexBufferReadWrite &accessor, uint first=0, uint last=0)
 Access vertices.
void lock (CVertexBufferRead &accessor, uint first=0, uint last=0) const
 Read only vertices access.
bool isLocked () const
Thoses methods manage the vertex buffer (position, normal, colors and uv) with standard value.



bool setVertexFormat (uint32 Flags)
 Setup the vertex format using standard values.
uint16 getVertexFormat (void) const
 Return the vertex format used by the vertex buffer.
uint getNumTexCoordUsed () const
 Returns the number of texture coordinate stages used by this vertex buffer.
sint getNormalOff () const
sint getTexCoordOff (uint8 stage=0) const
sint getColorOff () const
 See getColorPointer().
sint getSpecularOff () const
 See getColorPointer().
sint getWeightOff (sint wgt) const
 NB: it is ensured that WeightOff(i)==WeightOff(0)+i*sizeof(float).
sint getPaletteSkinOff () const
Lod VB serialisation.



void serialHeader (NLMISC::IStream &f)
 just read/write the VertexFormat of the VB, number of vertices .... If read, VB is resized to numVertices.
void serialSubset (NLMISC::IStream &f, uint vertexStart, uint vertexEnd)
 just read/write a subset of the vertex buffer.

Static Public Attributes

static const uint SizeType [NumType]
 Static array with the size in byte of each value type.
static const TType DefaultValueType [NumValue]
 Static array with the standard type of each value.
static const uint NumComponentsType [NumType]
 Static array with the number of component of each value type.

Friends

class CVertexBufferReadWrite
class CVertexBufferRead



CRefPtr< IVBDrvInfosDrvInfos
uint getTouchFlags () const
void setLocation (TLocation newLocation)
 Used by the driver implementation.
void fillBuffer ()
 Called by the driver implementation during the buffer activation.

UV Routing.



uint8 _Type [NumValue]
uint8 _VertexColorFormat
uint16 _VertexSize
uint16 _Flags
uint16 _InternalFlags
uint32 _NbVerts
uint32 _Capacity
std::vector< uint8_NonResidentVertices
uint8_LockedBuffer
uint16 _Offset [NumValue]
uint8 _UVRouting [MaxStage]
uint _LockCounter
TPreferredMemory _PreferredMemory
TLocation _Location
uint32 _ResidentSize
std::string _Name
bool _KeepLocalMemory
const uint8getUVRouting () const
void setUVRouting (uint8 uvChannel, uint newUVRouting)
bool setVertexColorFormat (TVertexColorType format)
 Set the vertex color format.
TVertexColorType getVertexColorFormat () const
 Get the vertex color format.
void dumpFormat () const
void setName (const std::string &name)
const std::string & getName () const
void construct ()
bool checkLockedBuffer () const
void unlock (uint first, uint last)
 Unlock the vertex buffer.
void unlock () const
 Unlock the vertex buffer.
void serialOldV1Minus (NLMISC::IStream &f, sint ver)
 Old version serialisation. V0 and V1.
uint16 remapV2Flags (uint32 oldFlags, uint &weightCount)
 Translate old flags.
void resetTouchFlags ()
void restaureNonResidentMemory ()

This is usable only with OpenGL vertex_program or DX8 vertex shaders.



void clearValueEx ()
 Clear all value in the vertex buffer.
void addValueEx (TValue valueId, TType type)
 Add a value in the vertex buffer.
bool hasValueEx (TValue valueId) const
 Test if the given value is present in the vertex buffer.
void initEx ()
 Init the vertex buffer in extended mode.
sint getValueOffEx (TValue valueId) const
 Get value offset.
static TValue getValueIdByNumberEx (uint valueNumber)
 get the corresponding TValue according to the number of vertex attribute wanted (v[0], v[1] .

Detailed Description

A vertex buffer to work with the driver.

Before the vertex buffer is resident (IDriver::activeVertexBuffer), it is in system memory. Once the vertex buffer is resident, the driver creates its proprietary vertex buffer and release the internal vertex buffer. At this moment the vertex buffer can be in VRAM, AGP or system memory.

The vertex buffers resident in AGP and VRAM are writeonly, i-e, you can't read them after a lock(). If you change the capacity of the format of a writeonly buffer, the content is lost.

Definition at line 98 of file vertex_buffer.h.


Member Enumeration Documentation

anonymous enum

Misc infos.

Enumerator:
FirstTexCoordValue 
LastTexCoordValue 

Definition at line 156 of file vertex_buffer.h.

anonymous enum

Value flags.

Enumerator:
PositionFlag 
NormalFlag 
TexCoord0Flag 
TexCoord1Flag 
TexCoord2Flag 
TexCoord3Flag 
TexCoord4Flag 
TexCoord5Flag 
TexCoord6Flag 
TexCoord7Flag 
PrimaryColorFlag 
SecondaryColorFlag 
WeightFlag 
PaletteSkinFlag 
FogFlag 
EmptyFlag 

Definition at line 165 of file vertex_buffer.h.

anonymous enum

Some constants.

Enumerator:
MaxStage 
MaxWeight 

Definition at line 211 of file vertex_buffer.h.

anonymous enum

Internal flags.

Enumerator:
TouchedVertexFormat 

Vertex format touched.

TouchedNumVertices 

Num vertices touched.

TouchedReserve 

Reserve touched.

TouchedAll 

All touhched.

Definition at line 247 of file vertex_buffer.h.

Type of buffer location.

Enumerator:
RAMResident 
AGPResident 
VRAMResident 
NotResident 
LocationCount 

Definition at line 120 of file vertex_buffer.h.

Type of preferred memory.

Enumerator:
RAMPreferred 
AGPPreferred 
StaticPreferred 
RAMVolatile 
AGPVolatile 
PreferredCount 

Definition at line 107 of file vertex_buffer.h.

Value type, there is 13 kind of value type as in DirectX8 and gl_vertex_program used in exteneded mode.

Enumerator:
Double1 
Float1 
Short1 
Double2 
Float2 
Short2 
Double3 
Float3 
Short3 
Double4 
Float4 
Short4 
UChar4 
NumType 

Definition at line 190 of file vertex_buffer.h.

Value ID, there is 16 value id.

Enumerator:
Position 
Normal 
TexCoord0 
TexCoord1 
TexCoord2 
TexCoord3 
TexCoord4 
TexCoord5 
TexCoord6 
TexCoord7 
PrimaryColor 
SecondaryColor 
Weight 
PaletteSkin 
Fog 
Empty 
NumValue 

Definition at line 132 of file vertex_buffer.h.

Vertex color format.

Enumerator:
TRGBA 
TBGRA 

Definition at line 223 of file vertex_buffer.h.


Constructor & Destructor Documentation

NL3D::CVertexBuffer::CVertexBuffer ( void   ) 

Default constructor.

Make an empty vertex buffer. No value, no vertex. Vertex color format is set to TRGBA.

Definition at line 126 of file vertex_buffer.cpp.

References construct().

NL3D::CVertexBuffer::CVertexBuffer ( const char *  name  ) 

Named vertex buffer.

Make an empty vertex buffer. No value, no vertex. Vertex color format is set to TRGBA.

Definition at line 131 of file vertex_buffer.cpp.

References _Name, and construct().

NL3D::CVertexBuffer::CVertexBuffer ( const CVertexBuffer vb  ) 

Copy constructor.

Do not copy DrvInfos, copy all infos and set IDRV_VF_TOUCHED_ALL.

Definition at line 140 of file vertex_buffer.cpp.

References _Capacity, _Flags, _KeepLocalMemory, _Location, _LockCounter, _LockedBuffer, _NbVerts, _PreferredMemory, _ResidentSize, _UVRouting, _VertexSize, MaxStage, NotResident, operator=(), and RAMPreferred.

NL3D::CVertexBuffer::~CVertexBuffer ( void   ) 

Destructor.

Definition at line 168 of file vertex_buffer.cpp.

References DrvInfos, and NLMISC::CRefPtr< T >::kill().


Member Function Documentation

void NL3D::CVertexBuffer::addValueEx ( TValue  valueId,
TType  type 
)

Add a value in the vertex buffer.

After this call, call initEx() to init the vertex buffer.

If the buffer preferres AGP memory, the data are lost. The vertex buffer is no more resident. The vertex buffer is invalidated. The vertex buffer must be unlocked before the call.

Parameters:
valueId is the value id to setup.
type is the type used for this value.

Definition at line 415 of file vertex_buffer.cpp.

References _Flags, _Type, Fog, isLocked(), nlassert, nlassertex, Normal, NumComponentsType, PaletteSkin, Position, PrimaryColor, SecondaryColor, and Weight.

Referenced by NL3D::CMeshGeom::build(), NL3D::CMRMBuilder::buildMeshBuildMrm(), NL3D::CWaterEnvMap::initFlattenVB(), NL3D::CWaterEnvMap::initTestVB(), serialHeader(), NL3D::CVegetableVBAllocator::setupVBFormat(), NL3D::CLandscapeVBAllocator::setupVBFormatAndVertexProgram(), and setVertexFormat().

uint32 NL3D::CVertexBuffer::capacity (  )  [inline]

Return the number of vertices reserved.

Definition at line 534 of file vertex_buffer.h.

References _Capacity.

Referenced by NL3D::CDriverD3D::activeVertexBuffer(), NL3D::CDriverGL::setupVertexBuffer(), and NL3D::CVegetableVBAllocator::updateDriver().

bool NL3D::CVertexBuffer::checkLockedBuffer (  )  const [inline, private]
void NL3D::CVertexBuffer::clearValueEx (  ) 

Clear all value in the vertex buffer.

After this call, call addValue for each value you want in your vertex buffer then call initEx() to init the vertex buffer.

If the buffer preferres AGP memory, the data are lost. The vertex buffer is no more resident. The vertex buffer is invalidated. The vertex buffer must be unlocked before the call.

Definition at line 346 of file vertex_buffer.cpp.

References _Flags, isLocked(), and nlassertex.

Referenced by NL3D::CMeshGeom::build(), NL3D::CMRMBuilder::buildMeshBuildMrm(), NL3D::CWaterEnvMap::initFlattenVB(), NL3D::CWaterEnvMap::initTestVB(), serialHeader(), NL3D::CVegetableVBAllocator::setupVBFormat(), NL3D::CLandscapeVBAllocator::setupVBFormatAndVertexProgram(), and setVertexFormat().

void NL3D::CVertexBuffer::construct (  )  [private]
void NL3D::CVertexBuffer::copyVertices ( CVertexBuffer dest  )  const

Copy a vertex buffer, including vertices data.

Destination vb is not resident. May be slow if there's agp / vram readback. Initial content of the destination vertex buffer is lost. Use this to retrieve content of a write-only buffer. Using lock with CVertexBufferRead won't work (used as a foolkeeper to prevent reading of a resident buffer that is not in ram) NB : will assert when used with volatile vb

Definition at line 223 of file vertex_buffer.cpp.

References _PreferredMemory, AGPVolatile, getLocation(), getNumVertices(), NL3D::CVertexBufferReadWrite::getVertexCoordPointer(), getVertexSize(), lock(), NLMISC::CFastMem::memcpy, nlassert, NotResident, and RAMVolatile.

Referenced by NL3D::CPSConstraintMesh::getMeshVB().

void NL3D::CVertexBuffer::deleteAllVertices (  ) 

Reset all the vertices from memory (contReset()), so that capacity() == getNumVertices() == 0.

If the buffer preferres AGP memory, the data are lost. The vertex buffer is no more resident. The vertex buffer is invalidated. The vertex buffer must be unlocked before the call.

Definition at line 513 of file vertex_buffer.cpp.

References _Capacity, _InternalFlags, _NbVerts, _NonResidentVertices, NLMISC::contReset(), DrvInfos, isLocked(), nlassert, restaureNonResidentMemory(), and TouchedNumVertices.

Referenced by NL3D::CVegetableVBAllocator::allocateVertexBufferAndFillVBHard(), NL3D::CVegetableVBAllocator::clear(), NL3D::CLandscapeVBAllocator::deleteVertexBuffer(), and NL3D::CVegetableVBAllocator::deleteVertexBufferHard().

void NL3D::CVertexBuffer::dumpFormat (  )  const
void NL3D::CVertexBuffer::fillBuffer (  ) 

Called by the driver implementation during the buffer activation.

Definition at line 1133 of file vertex_buffer.cpp.

References _KeepLocalMemory, _NbVerts, _NonResidentVertices, _VertexSize, DrvInfos, NLMISC::CFastMem::memcpy, and nlassert.

Referenced by NL3D::CDriverGL::activeVertexBuffer(), and NL3D::CDriverD3D::activeVertexBuffer().

sint NL3D::CVertexBuffer::getColorOff (  )  const [inline]
bool NL3D::CVertexBuffer::getKeepLocalMemory (  )  const [inline]

Get the keep local memory flag.

Definition at line 375 of file vertex_buffer.h.

References _KeepLocalMemory.

Referenced by NL3D::CDriverD3D::activeVertexBuffer().

TLocation NL3D::CVertexBuffer::getLocation (  )  const [inline]
const std::string& NL3D::CVertexBuffer::getName ( void   )  const [inline]
sint NL3D::CVertexBuffer::getNormalOff (  )  const [inline]
uint NL3D::CVertexBuffer::getNumTexCoordUsed (  )  const
uint32 NL3D::CVertexBuffer::getNumVertices ( void   )  const [inline]

Get the number of active vertices.

Definition at line 509 of file vertex_buffer.h.

References _NbVerts.

Referenced by NL3D::CVegetableVBAllocator::activate(), NL3D::CDriverGL::activeVertexBuffer(), NL3D::CDriverD3D::activeVertexBuffer(), NL3D::CVegetableManager::addInstance(), NL3D::CVegetableVBAllocator::allocateVertexBufferAndFillVBHard(), NL3D::CMeshMRMGeom::bkupOriginalSkinVertices(), NL3D::CMeshGeom::bkupOriginalSkinVertices(), NL3D::CMeshMRMGeom::bkupOriginalSkinVerticesSubset(), NL3D::CVegetableShape::build(), NL3D::CMeshMRMSkinnedGeom::CPackedVertexBuffer::build(), NL3D::CMeshMRMGeom::buildGeometryForLod(), NL3D::CPSConstraintMesh::CMeshDisplayShare::buildRdrPassSet(), NL3D::CMeshGeom::buildShadowSkin(), NL3D::CPSConstraintMesh::CMeshDisplayShare::buildVB(), NL3D::CMeshMRMGeom::compileRunTime(), NL3D::CPSConstraintMesh::computeColors(), NL3D::CMeshMRMGeom::computeMeshVBHeap(), NL3D::CMeshGeom::computeMeshVBHeap(), copyVertices(), NL3D::CVegetableVBAllocator::deleteVertexBufferHard(), NL3D::CPSConstraintMeshHelper::drawMeshs(), NL3D::CPSConstraintMeshHelper::drawPrerotatedMeshs(), NL3D::CVegetableVBAllocator::flushVertex(), NL3D::CMeshMRMGeom::getVBHeapInfo(), NL3D::CMeshGeom::getVBHeapInfo(), NL3D::CPSRibbon::getVBnPB(), NL3D::CMeshMultiLod::instanciateCoarseMeshSpace(), NL3D::CVertexBufferHardARB::invalidate(), NL3D::CVertexBufferHardGLMapObjectATI::invalidate(), NL3D::CVertexBufferHardARB::lock(), NL3D::CVertexBufferHardGLMapObjectATI::lock(), NL3D::CPSConstraintMesh::makePrerotatedVb(), NL3D::nlCheckVBA(), NL3D::nlCheckVBARange(), NL3D::nlCheckVertexBuffer(), NL3D::CDriverGL::profileVBHardAllocation(), NL3D::CSegRemanence::render(), NL3D::CNoise3d::render(), NL3D::CComputedString::render2D(), NL3D::CComputedString::render2DClip(), NL3D::CComputedString::render2DUnProjected(), NL3D::CNoise3d::render2passes(), NL3D::CComputedString::render3D(), NL3D::CMeshMultiLod::renderCoarseMesh(), NL3D::CNoise3d::renderGrid(), NL3D::CNoise3d::renderGrid2passes(), NL3D::CVegetableManager::reserveIgAddInstances(), NL3D::CMeshMRMGeom::restoreOriginalSkinVertices(), NL3D::CMeshGeom::restoreOriginalSkinVertices(), NL3D::CMeshGeom::retrieveVertices(), NL3D::CVegetableShape::serial(), NL3D::CMeshMultiLodInstance::setPosCoarseMesh(), NL3D::setTri(), NL3D::CWaterModel::setupVertexBuffer(), NL3D::CNearVertexBufferInfo::setupVertexBuffer(), NL3D::CFarVertexBufferInfo::setupVertexBuffer(), NL3D::CVertexBufferInfo::setupVertexBuffer(), NL3D::CDriverGL::setupVertexBuffer(), NL3D::CMeshMultiLodInstance::setUVCoarseMesh(), NL3D::CWaterModel::traverseRender(), NL3D::CVertexBufferHardGLATI::unlock(), NL3D::CPSConstraintMesh::update(), NL3D::CMeshMorpher::update(), NL3D::CVegetableVBAllocator::updateDriver(), NL3D::CMeshMorpher::updateRawSkin(), NL3D::CMeshMRMGeom::updateRawSkinNormal(), and NL3D::CMeshMorpher::updateSkinned().

uint8 NL3D::CVertexBuffer::getNumWeight (  )  const

Return number of weight value in vertices.

Definition at line 913 of file vertex_buffer.cpp.

References _Type, Float1, Float2, Float3, Float4, and Weight.

sint NL3D::CVertexBuffer::getPaletteSkinOff (  )  const [inline]

Definition at line 437 of file vertex_buffer.h.

References _Flags, _Offset, nlassert, and PaletteSkin.

TPreferredMemory NL3D::CVertexBuffer::getPreferredMemory (  )  const [inline]
sint NL3D::CVertexBuffer::getSpecularOff (  )  const [inline]

See getColorPointer().

Definition at line 433 of file vertex_buffer.h.

References _Flags, _Offset, nlassert, SecondaryColor, and SecondaryColorFlag.

Referenced by NL3D::CMeshMRMGeom::applyGeomorphWithVBHardPtr().

sint NL3D::CVertexBuffer::getTexCoordOff ( uint8  stage = 0  )  const [inline]
uint NL3D::CVertexBuffer::getTouchFlags (  )  const [inline]
const uint8* NL3D::CVertexBuffer::getUVRouting (  )  const [inline]
CVertexBuffer::TValue NL3D::CVertexBuffer::getValueIdByNumberEx ( uint  valueNumber  )  [static]

get the corresponding TValue according to the number of vertex attribute wanted (v[0], v[1] .

..) Warning!: (TValue)valueNumber != getValueIdByNumberEx(valueNumber).

Parameters:
valueNumber is the value index (0..15) you want to know the valueId.

Definition at line 319 of file vertex_buffer.cpp.

References Empty, Fog, Normal, PaletteSkin, Position, PrimaryColor, SecondaryColor, TexCoord0, TexCoord1, TexCoord2, TexCoord3, TexCoord4, TexCoord5, TexCoord6, TexCoord7, and Weight.

sint NL3D::CVertexBuffer::getValueOffEx ( TValue  valueId  )  const [inline]
TType NL3D::CVertexBuffer::getValueType ( uint  value  )  const [inline]

Return the type of a value.

Definition at line 544 of file vertex_buffer.h.

References _Type, nlassert, and NumValue.

Referenced by NL3D::CMeshMRMGeom::applyGeomorphWithVBHardPtr(), and NL3D::CVertexBufferInfo::setupVertexBuffer().

const uint8* NL3D::CVertexBuffer::getValueTypePointer (  )  const [inline]

Return the type array.

Definition at line 549 of file vertex_buffer.h.

References _Type.

Referenced by NL3D::CDriverD3D::activeVertexBuffer().

TVertexColorType NL3D::CVertexBuffer::getVertexColorFormat (  )  const [inline]
uint16 NL3D::CVertexBuffer::getVertexFormat ( void   )  const [inline]

Return the vertex format used by the vertex buffer.

Return one or several flags between : PositionFlag, WeightFlag, NormalFlag, PrimaryColorFlag, SecondaryColorFlag, FogFlag, TexCoord0Flag, TexCoord1Flag, TexCoord2Flag, TexCoord3Flag, TexCoord4Flag, TexCoord5Flag, TexCoord6Flag, TexCoord7Flag, PaletteSkinFlag

If WeightFlag is specified, 4 float are used to setup the skinning value on 4 bones.

Definition at line 419 of file vertex_buffer.h.

References _Flags.

Referenced by NL3D::CDriverGL::activeVertexBuffer(), NL3D::CDriverD3D::activeVertexBuffer(), NL3D::CMeshMRMGeom::applyGeomorphWithVBHardPtr(), NL3D::CMeshMRMGeom::applySkin(), NL3D::CMeshGeom::bkupOriginalSkinVertices(), NL3D::CMeshMRMGeom::bkupOriginalSkinVerticesSubset(), NL3D::CVegetableShape::build(), NL3D::CMeshMRMSkinnedGeom::CPackedVertexBuffer::build(), NL3D::CMeshGeom::buildShadowSkin(), NL3D::CPSConstraintMesh::CMeshDisplayShare::buildVB(), NL3D::CMeshMRMGeom::compileRunTime(), NL3D::CPSConstraintMesh::computeColors(), NL3D::CPSConstraintMeshHelper::drawMeshs(), NL3D::CPSConstraintMeshHelper::drawPrerotatedMeshs(), NL3D::CMeshMRMGeom::getVBHeapInfo(), NL3D::CMeshGeom::getVBHeapInfo(), NL3D::CPSConstraintMesh::makePrerotatedVb(), NL3D::CMeshMRMGeom::profileSceneRender(), NL3D::CMeshGeom::profileSceneRender(), NL3D::CMeshMRMGeom::renderSkin(), NL3D::CMeshMRMGeom::renderSkinGroupGeom(), NL3D::CMeshMRMGeom::restoreOriginalSkinPart(), NL3D::CMeshMRMGeom::restoreOriginalSkinVertices(), NL3D::CMeshGeom::restoreOriginalSkinVertices(), NL3D::CMeshMultiLodInstance::setPosCoarseMesh(), NL3D::CNearVertexBufferInfo::setupVertexBuffer(), NL3D::CFarVertexBufferInfo::setupVertexBuffer(), NL3D::CVertexBufferInfo::setupVertexBuffer(), NL3D::CMeshMultiLodInstance::setUVCoarseMesh(), NL3D::CPSConstraintMesh::update(), NL3D::CMeshMorpher::update(), NL3D::CMeshMorpher::updateRawSkin(), and NL3D::CMeshMorpher::updateSkinned().

uint16 NL3D::CVertexBuffer::getVertexSize ( void   )  const [inline]

Return the size of a vertex.

Definition at line 539 of file vertex_buffer.h.

References _VertexSize.

Referenced by NL3D::CDriverD3D::activeVertexBuffer(), NL3D::CVegetableVBAllocator::allocateVertexBufferAndFillVBHard(), NL3D::CMeshMRMGeom::applyGeomorphWithVBHardPtr(), NL3D::CMeshMRMGeom::applySkin(), NL3D::CMeshGeom::applySkin(), NL3D::CMeshMRMGeom::buildGeometryForLod(), NL3D::CMeshGeom::buildShadowSkin(), NL3D::CPSConstraintMesh::CMeshDisplayShare::buildVB(), NL3D::CPSConstraintMesh::computeColors(), NL3D::CMeshMRMGeom::computeMeshVBHeap(), NL3D::CMeshGeom::computeMeshVBHeap(), copyVertices(), NL3D::CCloud::dispBill(), NL3D::CPSTailDot::displayRibbons(), NL3D::CPSRibbonLookAt::displayRibbons(), NL3D::CPSRibbon::displayRibbons(), NL3D::CCloud::dispXYZ(), NL3D::DrawDot(), NL3D::CPSFaceHelper::drawFaces(), NL3D::CPSFanLightHelper::drawFanLight(), NL3D::CPSFaceLookAtHelper::drawLookAt(), NL3D::CPSFaceLookAtHelper::drawLookAtAlignOnMotion(), NL3D::CPSConstraintMeshHelper::drawMeshs(), NL3D::CPSConstraintMeshHelper::drawPrerotatedMeshs(), NL3D::CDriverUser::drawQuads(), NL3D::CPSShockWaveHelper::drawShockWave(), NL3D::CDriverUser::drawTriangles(), NL3D::CCoarseMeshManager::flushRender(), NL3D::CVegetableVBAllocator::flushVertex(), NL3D::CCloud::genBill(), NL3D::CCloud::generate(), NL3D::CCoarseMeshManager::getVertexSize(), NL3D::CVertexBufferHardARB::invalidate(), NL3D::CVertexBufferHardGLMapObjectATI::invalidate(), NL3D::CCloud::light(), NL3D::CVertexBufferHardARB::lock(), NL3D::CVertexBufferHardGLMapObjectATI::lock(), NL3D::CPSConstraintMesh::makePrerotatedVb(), NL3D::nlCheckVBA(), NL3D::nlCheckVBARange(), NL3D::nlCheckVertexBuffer(), NL3D::CDriverGL::profileVBHardAllocation(), NL3D::CSegRemanence::render(), NL3D::CNoise3d::render(), NL3D::CComputedString::render2DClip(), NL3D::CComputedString::render2DUnProjected(), NL3D::CNoise3d::render2passes(), NL3D::CNoise3d::renderGrid(), NL3D::CNoise3d::renderGrid2passes(), NL3D::CCloud::reset(), NL3D::CMeshMRMGeom::restoreOriginalSkinPart(), NL3D::CMeshGeom::retrieveVertices(), NL3D::CMeshMultiLodInstance::setPosCoarseMesh(), NL3D::CNearVertexBufferInfo::setupVertexBuffer(), NL3D::CFarVertexBufferInfo::setupVertexBuffer(), NL3D::CVertexBufferInfo::setupVertexBuffer(), NL3D::CDriverGL::setupVertexBuffer(), NL3D::CMeshMultiLodInstance::setUVCoarseMesh(), NL3D::CVegetableManager::swapIgRdrPassHardMode(), NL3D::CFlareModel::traverseRender(), NL3D::CVertexBufferHardGLATI::unlock(), NL3D::CMeshMorpher::update(), NL3D::CMeshMorpher::updateRawSkin(), NL3D::CMeshMorpher::updateSkinned(), NL3D::CPSShockWave::updateVbColNUVForRender(), and NL3D::CPSQuad::updateVbColNUVForRender().

sint NL3D::CVertexBuffer::getWeightOff ( sint  wgt  )  const [inline]

NB: it is ensured that WeightOff(i)==WeightOff(0)+i*sizeof(float).

Definition at line 436 of file vertex_buffer.h.

References _Flags, _Offset, nlassert, Weight, and WeightFlag.

bool NL3D::CVertexBuffer::hasValueEx ( TValue  valueId  )  const

Test if the given value is present in the vertex buffer.

Definition at line 442 of file vertex_buffer.cpp.

References _Flags.

Referenced by NL3D::CDriverD3D::activeVertexBuffer().

void NL3D::CVertexBuffer::initEx (  ) 

Init the vertex buffer in extended mode.

If the buffer preferres AGP memory, the data are lost. The vertex buffer is no more resident. The vertex buffer is invalidated. The vertex buffer must be unlocked before the call.

Definition at line 449 of file vertex_buffer.cpp.

References _Capacity, _Flags, _NbVerts, _NonResidentVertices, _Offset, _Type, _VertexSize, isLocked(), nlassert, NumValue, restaureNonResidentMemory(), and SizeType.

Referenced by NL3D::CMeshGeom::build(), NL3D::CMRMBuilder::buildMeshBuildMrm(), NL3D::CWaterEnvMap::initFlattenVB(), NL3D::CWaterEnvMap::initTestVB(), serialHeader(), NL3D::CVegetableVBAllocator::setupVBFormat(), NL3D::CLandscapeVBAllocator::setupVBFormatAndVertexProgram(), and setVertexFormat().

bool NL3D::CVertexBuffer::isLocked (  )  const [inline]
bool NL3D::CVertexBuffer::isResident (  )  const [inline]
void NL3D::CVertexBuffer::lock ( CVertexBufferRead accessor,
uint  first = 0,
uint  last = 0 
) const [inline]

Read only vertices access.

Multi lock is possible only if no regions are used. Each lock need an accessor to be unlocked.

Lock the vertex buffer and return and fill an accessor object. Once the object is destroyed, the buffer in unlocked.

Readonly lock will fail if the buffer is resident in AGP or VRAM.

Parameters:
accessor is the accessor object to fill
first is the first vertex to be accessed. Put 0 to select all the vertices. What ever is this index, the indexices in the vertex buffer remain the same.
last is the last vertex to be accessed + 1. Put 0 to select all the vertices.

Definition at line 1194 of file vertex_buffer.h.

References _KeepLocalMemory, _Location, _LockCounter, _LockedBuffer, _NbVerts, _NonResidentVertices, NL3D::CVertexBufferRead::_Parent, _VertexSize, DrvInfos, isResident(), nlassert, nlassertex, RAMResident, and NL3D::CVertexBufferRead::unlock().

void NL3D::CVertexBuffer::lock ( CVertexBufferReadWrite accessor,
uint  first = 0,
uint  last = 0 
) [inline]

Access vertices.

Multi lock is possible only if no regions are used. Each lock need an accessor to be unlocked.

Lock the vertex buffer and return and fill an accessor object. Once the object is destroyed, the buffer in unlocked.

Parameters:
accessor is the accessor object to fill
first is the first vertex to be accessed. Put 0 to select all the vertices. What ever is this index, the indexices in the vertex buffer remain the same.
last is the last vertex to be accessed + 1. Put 0 to select all the vertices.

Definition at line 1159 of file vertex_buffer.h.

References NL3D::CVertexBufferReadWrite::_First, _KeepLocalMemory, NL3D::CVertexBufferReadWrite::_Last, _LockCounter, _LockedBuffer, _NbVerts, _NonResidentVertices, NL3D::CVertexBufferReadWrite::_Parent, _VertexSize, DrvInfos, isResident(), nlassert, and NL3D::CVertexBufferReadWrite::unlock().

Referenced by NL3D::CVegetableManager::addInstance(), NL3D::CZoneLighter::addTriangles(), NL3D::CInstanceLighter::addTriangles(), NL3D::CMeshMRMGeom::applyGeomorphWithVBHardPtr(), NL3D::CMeshMRMGeom::applySkin(), NL3D::CMeshGeom::applySkin(), NL3D::CMeshGeom::bkupOriginalSkinVertices(), NL3D::CMeshMRMGeom::bkupOriginalSkinVerticesSubset(), NL3D::CVegetableShape::build(), NL3D::CShapeInfo::build(), NL3D::CMeshMRMSkinnedGeom::CPackedVertexBuffer::build(), NL3D::CMeshMRMGeom::buildGeometryForLod(), NL3D::CMRMBuilder::buildMeshBuildMrm(), NL3D::CMeshGeom::buildShadowSkin(), NL3D::CPSConstraintMesh::CMeshDisplayShare::buildVB(), NL3D::CMeshMRMGeom::computeMeshVBHeap(), NL3D::CMeshGeom::computeMeshVBHeap(), NL3D::CFontManager::computeString(), copyVertices(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CCloud::disp(), NL3D::CCloud::dispBill(), NL3D::CPSUtil::displayArrow(), NL3D::CPSUtil::displayBBox(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CPSTailDot::displayRibbons(), NL3D::CPSRibbonLookAt::displayRibbons(), NL3D::CPSRibbon::displayRibbons(), NL3D::CCloud::dispXYZ(), NL3D::CDeform2d::doDeform(), NL3D::CDRU::drawBitmap(), NL3D::DrawDot(), NL3D::CPSFaceHelper::drawFaces(), NL3D::CPSFanLightHelper::drawFanLight(), NL3D::CDRU::drawLine(), NL3D::CDriverUser::drawLine(), NL3D::CDRU::drawLinesUnlit(), NL3D::CPSFaceLookAtHelper::drawLookAt(), NL3D::CPSFaceLookAtHelper::drawLookAtAlignOnMotion(), NL3D::CPSConstraintMeshHelper::drawMeshs(), NL3D::CPSConstraintMeshHelper::drawPrerotatedMeshs(), NL3D::CDRU::drawQuad(), NL3D::CDriverUser::drawQuad(), NL3D::CDriverUser::drawQuads(), NL3D::CPSShockWaveHelper::drawShockWave(), NL3D::CDRU::drawTriangle(), NL3D::CDriverUser::drawTriangle(), NL3D::CDriverUser::drawTriangles(), NL3D::CDRU::drawTrianglesUnlit(), NL3D::CMeshGeom::findVBId(), NL3D::CCoarseMeshManager::flushRender(), NL3D::CCloud::genBill(), NL3D::CCloud::generate(), NL3D::CPSFanLight::getVBnIB(), NL3D::CPSTailDot::getVBnPB(), NL3D::CPSShockWave::getVBnPB(), NL3D::CPSRibbonLookAt::getVBnPB(), NL3D::CPSRibbon::getVBnPB(), NL3D::CMeshMRMSkinnedGeom::getVertexBuffer(), NL3D::CWaterEnvMap::initFlattenVB(), NL3D::CWaterEnvMap::initTestVB(), NL3D::CCloud::light(), NL3D::CVertexStreamManager::lock(), NL3D::CVegetableVBAllocator::lockBuffer(), NL3D::CPSConstraintMesh::makePrerotatedVb(), NL3D::nlCheckVertexBuffer(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CCoarseMeshBuild::remapCoordinates(), NL3D::CSegRemanence::render(), NL3D::CPackedZone16::render(), NL3D::CPackedZone32::render(), NL3D::CNoise3d::render(), NL3D::CComputedString::render2DClip(), NL3D::CComputedString::render2DUnProjected(), NL3D::CNoise3d::render2passes(), NL3D::CShadowMapManager::renderGenerate(), NL3D::CNoise3d::renderGrid(), NL3D::CNoise3d::renderGrid2passes(), NL3D::CShadowPolyReceiver::renderSelection(), NL3D::CCloud::reset(), NL3D::CMeshMRMGeom::restoreOriginalSkinPart(), NL3D::CMeshMRMGeom::restoreOriginalSkinVertices(), NL3D::CMeshGeom::restoreOriginalSkinVertices(), NL3D::CMeshGeom::retrieveVertices(), NL3D::CShadowMapManager::setBlackQuad(), NL3D::CShadowMapManager::setBlurQuadFakeGaussian(), NL3D::CMeshMultiLodInstance::setPosCoarseMesh(), NL3D::SetupQuadVBTexCoords(), NL3D::CNearVertexBufferInfo::setupVertexBuffer(), NL3D::CFarVertexBufferInfo::setupVertexBuffer(), NL3D::CMeshMultiLodInstance::setUVCoarseMesh(), NL3D::CPSGravity::show(), NL3D::CVegetableManager::swapIgRdrPassHardMode(), NL3D::CRenderTrav::traverse(), NL3D::CFlareModel::traverseRender(), NL3D::CMeshMorpher::update(), NL3D::CVegetableManager::updateInstanceLighting(), NL3D::CFlareModel::updateOcclusionQuery(), NL3D::CMeshMorpher::updateRawSkin(), NL3D::CMeshMRMGeom::updateRawSkinNormal(), NL3D::CMeshMorpher::updateSkinned(), NL3D::CPSShockWave::updateVbColNUVForRender(), and NL3D::CPSQuad::updateVbColNUVForRender().

CVertexBuffer & NL3D::CVertexBuffer::operator= ( const CVertexBuffer vb  ) 

Copy operator.

Do not copy DrvInfos, copy all infos and set IDRV_VF_TOUCHED_ALL. All the destination vertex buffer is invalidated. Data are lost. The source and destination vertex buffers must be unlocked. Vertices datas are not copied

Reimplemented from NLMISC::CRefCount.

Definition at line 184 of file vertex_buffer.cpp.

References _Capacity, _Flags, _InternalFlags, _KeepLocalMemory, _Location, _LockCounter, _LockedBuffer, _NbVerts, _NonResidentVertices, _Offset, _PreferredMemory, _ResidentSize, _Type, _UVRouting, _VertexColorFormat, _VertexSize, isLocked(), MaxStage, nlassertex, NotResident, NumValue, and TouchedAll.

Referenced by CVertexBuffer().

uint16 NL3D::CVertexBuffer::remapV2Flags ( uint32  oldFlags,
uint weightCount 
) [private]
void NL3D::CVertexBuffer::reserve ( uint32  nVerts  ) 

Reserve space for nVerts vertices.

You are allowed to write your vertices on this space.

If the buffer preferres AGP memory, the data are lost. The vertex buffer is no more resident. The vertex buffer is invalidated. The vertex buffer must be unlocked before the call.

Definition at line 483 of file vertex_buffer.cpp.

References _Capacity, _NbVerts, isLocked(), min, nlassert, and restaureNonResidentMemory().

Referenced by NL3D::CMeshMRMGeom::build(), NL3D::CMeshGeom::build(), serialHeader(), serialOldV1Minus(), and setNumVertices().

void NL3D::CVertexBuffer::resetTouchFlags (  )  [inline, private]

Definition at line 660 of file vertex_buffer.h.

References _InternalFlags, and TouchedAll.

Referenced by setLocation().

void NL3D::CVertexBuffer::restaureNonResidentMemory (  )  [private]
void NL3D::CVertexBuffer::serial ( NLMISC::IStream f  ) 

If the buffer preferres AGP memory, the data are lost.

The vertex buffer is no more resident. The vertex buffer is invalidated. The vertex buffer must be unlocked before the call.

Definition at line 741 of file vertex_buffer.cpp.

References _NbVerts, isLocked(), nlassert, serialHeader(), serialOldV1Minus(), serialSubset(), and NLMISC::IStream::serialVersion().

void NL3D::CVertexBuffer::serialHeader ( NLMISC::IStream f  ) 
void NL3D::CVertexBuffer::serialOldV1Minus ( NLMISC::IStream f,
sint  ver 
) [private]
void NL3D::CVertexBuffer::serialSubset ( NLMISC::IStream f,
uint  vertexStart,
uint  vertexEnd 
)

just read/write a subset of the vertex buffer.

NB: because a version is serialised by subset, you must read same subset of vertices you have saved. (can't write 0-10, 10-20, and after load 0-5, 5-20).

Definition at line 934 of file vertex_buffer.cpp.

References _Flags, _NbVerts, _NonResidentVertices, _Type, _UVRouting, _VertexSize, getValueOffEx(), NLMISC::IStream::isReading(), MaxStage, nlassert, NumValue, restaureNonResidentMemory(), NLMISC::IStream::serialBuffer(), NLMISC::IStream::serialVersion(), and SizeType.

Referenced by serial(), and NL3D::CMeshMRMGeom::serialLodVertexData().

void NL3D::CVertexBuffer::setLocation ( TLocation  newLocation  ) 

Used by the driver implementation.

The driver must first allocate its internal buffer and fill DrvInfos. Then it has to call setLocation(true).

If newLocation!=NotResident, setLocation() will copy the non resident buffer in the choosed resident memory and untouch the buffer. If the buffer preferres RAM or AGP memory, it will release the non resident memory.

If newLocation==NotResident, setLocation() will realloc the non resident buffer, copy the vertex data if the buffer was resident in RAM. Then it will touch the buffer.

Definition at line 1059 of file vertex_buffer.cpp.

References _Capacity, _InternalFlags, _KeepLocalMemory, _Location, _NbVerts, _NonResidentVertices, _PreferredMemory, _ResidentSize, _VertexSize, AGPVolatile, NLMISC::contReset(), DrvInfos, min, nlassert, NotResident, RAMResident, RAMVolatile, resetTouchFlags(), StaticPreferred, and TouchedAll.

Referenced by NL3D::CDriverD3D::activeVertexBuffer(), NL3D::CDriverD3D::reset(), restaureNonResidentMemory(), and NL3D::CDriverGL::setupVertexBuffer().

void NL3D::CVertexBuffer::setName ( const std::string &  name  )  [inline]
void NL3D::CVertexBuffer::setNumVertices ( uint32  n  ) 

Set the number of active vertices.

It enlarge capacity, if needed. If the new size is bigger than capacity, reserve() will be called. see reserve(). If the new size is smaller than capacity, the data are keeped, the vertex buffer stay resident if it is resident.

Definition at line 498 of file vertex_buffer.cpp.

References _Capacity, _InternalFlags, _NbVerts, reserve(), and TouchedNumVertices.

Referenced by NL3D::CShadowPolyReceiver::allocateVertex(), NL3D::CLandscapeVBAllocator::allocateVertexBuffer(), NL3D::CVegetableVBAllocator::allocateVertexBufferAndFillVBHard(), NL3D::CVegetableShape::build(), NL3D::CMeshMRMGeom::build(), NL3D::CMeshGeom::build(), NL3D::CMRMBuilder::buildMeshBuildMrm(), NL3D::CPSConstraintMesh::CMeshDisplayShare::buildVB(), NL3D::CCloudScape::CCloudScape(), NL3D::CDriverUser::CDriverUser(), NL3D::CFontManager::computeString(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CPSUtil::displayArrow(), NL3D::CPSUtil::displayBBox(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CPSTailDot::displayRibbons(), NL3D::CPSRibbonLookAt::displayRibbons(), NL3D::CPSRibbon::displayRibbons(), NL3D::CDeform2d::doDeform(), NL3D::CDRU::drawBitmap(), NL3D::DrawDot(), NL3D::CPSFaceHelper::drawFaces(), NL3D::CPSFanLightHelper::drawFanLight(), NL3D::CDRU::drawLine(), NL3D::CDRU::drawLinesUnlit(), NL3D::CPSFaceLookAtHelper::drawLookAt(), NL3D::CPSFaceLookAtHelper::drawLookAtAlignOnMotion(), NL3D::CPSConstraintMeshHelper::drawMeshs(), NL3D::CPSConstraintMeshHelper::drawPrerotatedMeshs(), NL3D::CDRU::drawQuad(), NL3D::CDriverUser::drawQuads(), NL3D::CPSShockWaveHelper::drawShockWave(), NL3D::CDRU::drawTriangle(), NL3D::CDriverUser::drawTriangles(), NL3D::CDRU::drawTrianglesUnlit(), NL3D::CShadowMapManager::fillBlackBorder(), NL3D::CMeshGeom::findVBId(), NL3D::CCoarseMeshManager::flushRender(), NL3D::CPSFanLight::getVBnIB(), NL3D::CPSTailDot::getVBnPB(), NL3D::CPSShockWave::getVBnPB(), NL3D::CPSRibbonLookAt::getVBnPB(), NL3D::CPSRibbon::getVBnPB(), NL3D::CMeshMRMSkinnedGeom::getVertexBuffer(), NL3D::CVertexStreamManager::init(), NL3D::CWaterEnvMap::initFlattenVB(), NL3D::CPSConstraintMesh::initPrerotVB(), NL3D::CFlareModel::initStatics(), NL3D::CWaterEnvMap::initTestVB(), NL3D::CPSQuad::initVertexBuffers(), NL3D::CPSDot::initVertexBuffers(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CSegRemanence::render(), NL3D::CPackedZone16::render(), NL3D::CPackedZone32::render(), NL3D::CNoise3d::render(), NL3D::CComputedString::render2DClip(), NL3D::CComputedString::render2DUnProjected(), NL3D::CNoise3d::render2passes(), NL3D::CNoise3d::renderGrid(), NL3D::CNoise3d::renderGrid2passes(), NL3D::CShadowPolyReceiver::renderSelection(), serialHeader(), serialOldV1Minus(), NL3D::CWaterModel::setupVertexBuffer(), NL3D::CPSGravity::show(), NL3D::CDriverGL::swapBuffers(), and NL3D::CFlareModel::traverseRender().

void NL3D::CVertexBuffer::setPreferredMemory ( TPreferredMemory  preferredMemory,
bool  keepLocalMemory 
)

Set the buffer preferred memory.

Default preferred memory is RAM.

Preferre RAM if the buffer is changed several times in the same render pass. Preferre AGP if the buffer is changed only one time in the same render pass. Preferre Static if the buffer is changed only one time for initialisation.

If static memory is chosen, the driver will choose VRAM or AGP depending of the user configuration.

If static or RAM memory is preferred, the buffer won't be lost after a driver reset.

If the buffer preferres AGP memory, the buffer is lost after a driver reset. When the buffer is lost, it returns in a non resident state. The state must be tested at each pass with isResident(). If the buffer is in a non resident state, the user must refill it.

If VRAM memory allocation failed, the driver will try with AGP and then with RAM. If AGP memory allocation failed, the driver will try with RAM. RAM allocation should never failed.

Performance note:

  • for RAM CVertexBuffer, you can read / write as you like.
  • for AGP CVertexBuffer, you should write sequentially to take full advantage of the write combiners. You can't read.
  • for Static CVertexBuffer, you should write only one time, to init. You can read. Each modification will be done in a RAM buffer. Then the unlocked area will be copied into the VRAM or AGP memory.

Volatile buffers must be completely filled at each pass. They are lost after each swapBuffers(). They are writeonly. Volatile buffers must be resized before the lock call. Only one lock per render must be done with volatile buffers if keepLocalMemory is false.

If keepLocalMemory is true, lock() will return a local memory pointer. The local memory will copied in resident memory during the activation of the buffer. The not all the buffer capacity is copied but only the used size.

If the buffer preferres AGP memory, the data are lost. The buffer is no more resident. The buffer is invalidated. The buffer must be unlocked before the call.

Definition at line 1046 of file vertex_buffer.cpp.

References _KeepLocalMemory, _PreferredMemory, and restaureNonResidentMemory().

Referenced by NL3D::CLandscapeVBAllocator::allocateVertexBuffer(), NL3D::CVegetableVBAllocator::allocateVertexBufferAndFillVBHard(), NL3D::CMeshGeom::build(), NL3D::CPSConstraintMesh::CMeshDisplayShare::buildVB(), NL3D::CComputedString::CComputedString(), NL3D::CDriverUser::CDriverUser(), NL3D::CMeshGeom::compileRunTime(), NL3D::CRenderStringBuffer::CRenderStringBuffer(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CShadowPolyReceiver::CShadowPolyReceiver(), NL3D::CPSFanLightHelper::drawFanLight(), NL3D::CPSFanLight::getVBnIB(), NL3D::CPSTailDot::getVBnPB(), NL3D::CPSShockWave::getVBnPB(), NL3D::CPSRibbonLookAt::getVBnPB(), NL3D::CPSRibbon::getVBnPB(), NL3D::CVertexStreamManager::init(), NL3D::CWaterEnvMap::initFlattenVB(), NL3D::CFlareModel::initStatics(), NL3D::CWaterEnvMap::initTestVB(), NL3D::CPSQuad::initVertexBuffers(), NL3D::CPSDot::initVertexBuffers(), NL3D::CSegRemanence::render(), NL3D::CMeshGeom::render(), NL3D::CWaterModel::setupVertexBuffer(), and NL3D::CFlareModel::traverseRender().

void NL3D::CVertexBuffer::setUVRouting ( uint8  uvChannel,
uint  newUVRouting 
) [inline]
bool NL3D::CVertexBuffer::setVertexColorFormat ( TVertexColorType  format  ) 

Set the vertex color format.

If the vertex buffer is not in this format, the colors will be converted See getColorPointer()

The vertex buffer must not be resident.

The vertex buffer is invalidated. The vertex buffer must be unlocked.

Returns:
false if the vertex buffer is resident.

Definition at line 995 of file vertex_buffer.cpp.

References _Flags, _NbVerts, _NonResidentVertices, _Offset, _VertexColorFormat, _VertexSize, isLocked(), isResident(), nlassert, PrimaryColor, PrimaryColorFlag, restaureNonResidentMemory(), SecondaryColor, and SecondaryColorFlag.

Referenced by NL3D::CDriverD3D::activeVertexBuffer(), NL3D::CCoarseMeshManager::flushRender(), NL3D::CComputedString::render2DClip(), and NL3D::CComputedString::render2DUnProjected().

bool NL3D::CVertexBuffer::setVertexFormat ( uint32  Flags  ) 

Setup the vertex format using standard values.

Do it before any other standard methods.

Use one or several flag between : PositionFlag, WeightFlag, NormalFlag, PrimaryColorFlag, SecondaryColorFlag, FogFlag, TexCoord0Flag, TexCoord1Flag, TexCoord2Flag, TexCoord3Flag, TexCoord4Flag, TexCoord5Flag, TexCoord6Flag, TexCoord7Flag, PaletteSkinFlag

If the buffer preferres AGP memory, the data are lost. The vertex buffer is no more resident. The vertex buffer is invalidated. The vertex buffer must be unlocked before the call.

If WeightFlag is specified, 4 float are used to setup the skinning value on 4 bones.

Definition at line 239 of file vertex_buffer.cpp.

References addValueEx(), clearValueEx(), Float1, Float2, Float3, Float4, Fog, FogFlag, initEx(), isLocked(), MaxStage, nlassertex, Normal, NormalFlag, PaletteSkin, PaletteSkinFlag, Position, PositionFlag, PrimaryColor, PrimaryColorFlag, restaureNonResidentMemory(), SecondaryColor, SecondaryColorFlag, TexCoord0, TexCoord0Flag, UChar4, Weight, and WeightFlag.

Referenced by NL3D::CLodCharacterManager::beginRender(), NL3D::CVegetableShape::build(), NL3D::CMeshGeom::build(), NL3D::CMRMBuilder::buildMeshBuildMrm(), NL3D::CPSConstraintMesh::CMeshDisplayShare::buildVB(), NL3D::CCloudScape::CCloudScape(), NL3D::CComputedString::CComputedString(), NL3D::CDriverUser::CDriverUser(), NL3D::CRenderStringBuffer::CRenderStringBuffer(), NL3D::CShadowMapManager::CShadowMapManager(), NL3D::CShadowPolyReceiver::CShadowPolyReceiver(), NL3D::CPSUtil::displayArrow(), NL3D::CPSUtil::displayBBox(), NL3D::CInstanceGroup::displayDebugClusters(), NL3D::CDeform2d::doDeform(), NL3D::CDRU::drawBitmap(), NL3D::CDRU::drawLine(), NL3D::CDRU::drawLinesUnlit(), NL3D::CDRU::drawQuad(), NL3D::CDRU::drawTriangle(), NL3D::CDRU::drawTrianglesUnlit(), NL3D::CPSFanLight::getVBnIB(), NL3D::CPSTailDot::getVBnPB(), NL3D::CPSShockWave::getVBnPB(), NL3D::CPSRibbonLookAt::getVBnPB(), NL3D::CPSRibbon::getVBnPB(), NL3D::CMeshMRMSkinnedGeom::getVertexBuffer(), NL3D::CVertexStreamManager::init(), NL3D::CNoise3d::init(), NL3D::CPSConstraintMesh::initPrerotVB(), NL3D::CFlareModel::initStatics(), NL3D::CPSQuad::initVertexBuffers(), NL3D::CPSDot::initVertexBuffers(), NL3D::CMotionBlur::performMotionBlur(), NL3D::CSegRemanence::render(), serialOldV1Minus(), NL3D::CLandscapeVBAllocator::setupVBFormatAndVertexProgram(), NL3D::CWaterModel::setupVertexBuffer(), NL3D::CPSGravity::show(), NL3D::CDriverGL::swapBuffers(), and NL3D::CFlareModel::traverseRender().

void NL3D::CVertexBuffer::unlock (  )  const [inline, private]

Unlock the vertex buffer.

Called by CVertexBufferRead.

Parameters:
first the first vertex that as been modified.
last the last vertex that as been modified + 1.

Definition at line 1248 of file vertex_buffer.h.

References _KeepLocalMemory, _LockCounter, _LockedBuffer, _NonResidentVertices, DrvInfos, isResident(), nlassert, and nlassertex.

void NL3D::CVertexBuffer::unlock ( uint  first,
uint  last 
) [inline, private]

Unlock the vertex buffer.

Called by CVertexBufferReadWrite.

Parameters:
first the first vertex that as been modified.
last the last vertex that as been modified + 1.

Definition at line 1229 of file vertex_buffer.h.

References _KeepLocalMemory, _LockCounter, _LockedBuffer, _NonResidentVertices, DrvInfos, isResident(), nlassert, and nlassertex.

Referenced by NL3D::CVertexBufferRead::unlock(), and NL3D::CVertexBufferReadWrite::unlock().


Friends And Related Function Documentation

friend class CVertexBufferRead [friend]

Definition at line 102 of file vertex_buffer.h.

friend class CVertexBufferReadWrite [friend]

Definition at line 101 of file vertex_buffer.h.


Member Data Documentation

Definition at line 675 of file vertex_buffer.h.

Referenced by addValueEx(), clearValueEx(), construct(), CVertexBuffer(), dumpFormat(), getColorOff(), NL3D::CVertexBufferRead::getColorPointer(), NL3D::CVertexBufferReadWrite::getColorPointer(), NL3D::CVertexBufferRead::getNormalCoordPointer(), NL3D::CVertexBufferReadWrite::getNormalCoordPointer(), getNormalOff(), getNumTexCoordUsed(), getPaletteSkinOff(), NL3D::CVertexBufferRead::getPaletteSkinPointer(), NL3D::CVertexBufferReadWrite::getPaletteSkinPointer(), getSpecularOff(), NL3D::CVertexBufferRead::getSpecularPointer(), NL3D::CVertexBufferReadWrite::getSpecularPointer(), getTexCoordOff(), NL3D::CVertexBufferRead::getTexCoordPointer(), NL3D::CVertexBufferReadWrite::getTexCoordPointer(), NL3D::CVertexBufferRead::getValueEx(), NL3D::CVertexBufferReadWrite::getValueEx(), getValueOffEx(), getVertexFormat(), getWeightOff(), NL3D::CVertexBufferRead::getWeightPointer(), NL3D::CVertexBufferReadWrite::getWeightPointer(), hasValueEx(), initEx(), operator=(), serialHeader(), serialOldV1Minus(), serialSubset(), NL3D::CVertexBufferReadWrite::setColor(), NL3D::CVertexBufferReadWrite::setNormalCoord(), NL3D::CVertexBufferReadWrite::setPaletteSkin(), NL3D::CVertexBufferReadWrite::setSpecular(), NL3D::CVertexBufferReadWrite::setTexCoord(), NL3D::CVertexBufferReadWrite::setValueFloat1Ex(), NL3D::CVertexBufferReadWrite::setValueFloat2Ex(), NL3D::CVertexBufferReadWrite::setValueFloat3Ex(), NL3D::CVertexBufferReadWrite::setValueFloat4Ex(), NL3D::CVertexBufferReadWrite::setValueUChar4Ex(), setVertexColorFormat(), NL3D::CVertexBufferReadWrite::setVertexCoord(), and NL3D::CVertexBufferReadWrite::setWeight().

Definition at line 699 of file vertex_buffer.h.

Referenced by construct(), CVertexBuffer(), isLocked(), lock(), operator=(), and unlock().

Definition at line 690 of file vertex_buffer.h.

Referenced by checkLockedBuffer(), construct(), CVertexBuffer(), NL3D::CVertexBufferRead::getColorPointer(), NL3D::CVertexBufferReadWrite::getColorPointer(), NL3D::CVertexBufferRead::getNormalCoordPointer(), NL3D::CVertexBufferReadWrite::getNormalCoordPointer(), NL3D::CVertexBufferRead::getPaletteSkinPointer(), NL3D::CVertexBufferReadWrite::getPaletteSkinPointer(), NL3D::CVertexBufferRead::getSpecularPointer(), NL3D::CVertexBufferReadWrite::getSpecularPointer(), NL3D::CVertexBufferRead::getTexCoordPointer(), NL3D::CVertexBufferReadWrite::getTexCoordPointer(), NL3D::CVertexBufferRead::getValueEx(), NL3D::CVertexBufferReadWrite::getValueEx(), NL3D::CVertexBufferRead::getVertexCoordPointer(), NL3D::CVertexBufferReadWrite::getVertexCoordPointer(), NL3D::CVertexBufferRead::getWeightPointer(), NL3D::CVertexBufferReadWrite::getWeightPointer(), lock(), operator=(), NL3D::CVertexBufferReadWrite::setColor(), NL3D::CVertexBufferReadWrite::setNormalCoord(), NL3D::CVertexBufferReadWrite::setPaletteSkin(), NL3D::CVertexBufferReadWrite::setSpecular(), NL3D::CVertexBufferReadWrite::setTexCoord(), NL3D::CVertexBufferReadWrite::setValueFloat1Ex(), NL3D::CVertexBufferReadWrite::setValueFloat2Ex(), NL3D::CVertexBufferReadWrite::setValueFloat3Ex(), NL3D::CVertexBufferReadWrite::setValueFloat4Ex(), NL3D::CVertexBufferReadWrite::setValueUChar4Ex(), NL3D::CVertexBufferReadWrite::setVertexCoord(), NL3D::CVertexBufferReadWrite::setWeight(), and unlock().

std::string NL3D::CVertexBuffer::_Name [private]

Definition at line 711 of file vertex_buffer.h.

Referenced by CVertexBuffer(), getName(), serialHeader(), and setName().

uint16 NL3D::CVertexBuffer::_Offset[NumValue] [private]

Definition at line 708 of file vertex_buffer.h.

Referenced by construct(), CVertexBuffer(), operator=(), and setLocation().

uint8 NL3D::CVertexBuffer::_Type[NumValue] [private]

Definition at line 672 of file vertex_buffer.h.

Referenced by construct(), CVertexBuffer(), fillBuffer(), NL3D::CVertexBufferRead::getColorPointer(), NL3D::CVertexBufferReadWrite::getColorPointer(), NL3D::CVertexBufferRead::getNormalCoordPointer(), NL3D::CVertexBufferReadWrite::getNormalCoordPointer(), NL3D::CVertexBufferRead::getPaletteSkinPointer(), NL3D::CVertexBufferReadWrite::getPaletteSkinPointer(), NL3D::CVertexBufferRead::getSpecularPointer(), NL3D::CVertexBufferReadWrite::getSpecularPointer(), NL3D::CVertexBufferRead::getTexCoordPointer(), NL3D::CVertexBufferReadWrite::getTexCoordPointer(), NL3D::CVertexBufferRead::getValueEx(), NL3D::CVertexBufferReadWrite::getValueEx(), NL3D::CVertexBufferRead::getVertexCoordPointer(), NL3D::CVertexBufferReadWrite::getVertexCoordPointer(), getVertexSize(), NL3D::CVertexBufferRead::getWeightPointer(), NL3D::CVertexBufferReadWrite::getWeightPointer(), initEx(), lock(), operator=(), serialOldV1Minus(), serialSubset(), NL3D::CVertexBufferReadWrite::setColor(), setLocation(), NL3D::CVertexBufferReadWrite::setNormalCoord(), NL3D::CVertexBufferReadWrite::setPaletteSkin(), NL3D::CVertexBufferReadWrite::setSpecular(), NL3D::CVertexBufferReadWrite::setTexCoord(), NL3D::CVertexBufferReadWrite::setValueFloat1Ex(), NL3D::CVertexBufferReadWrite::setValueFloat2Ex(), NL3D::CVertexBufferReadWrite::setValueFloat3Ex(), NL3D::CVertexBufferReadWrite::setValueFloat4Ex(), NL3D::CVertexBufferReadWrite::setValueUChar4Ex(), setVertexColorFormat(), NL3D::CVertexBufferReadWrite::setVertexCoord(), and NL3D::CVertexBufferReadWrite::setWeight().

Initial value:
{
    Float3,     
    Float3,     
    Float2,     
    Float2,     
    Float2,     
    Float2,     
    Float2,     
    Float2,     
    Float2,     
    Float2,     
    UChar4,     
    UChar4,     
    Float4,     
    UChar4,     
    Float1,     
    Float1,     
}

Static array with the standard type of each value.

Definition at line 237 of file vertex_buffer.h.

Referenced by serialHeader(), and serialOldV1Minus().

Initial value:
{
    1,
    1,
    1,
    2,
    2,
    2,
    3,
    3,
    3,
    4,
    4,
    4,
    4
}

Static array with the number of component of each value type.

Definition at line 242 of file vertex_buffer.h.

Referenced by addValueEx(), and NL3D::CDriverGL::setupGlArraysStd().

Initial value:
{
    1*sizeof(double),
    1*sizeof(float),
    1*sizeof(short),
    2*sizeof(double),
    2*sizeof(float),
    2*sizeof(short),
    3*sizeof(double),
    3*sizeof(float),
    3*sizeof(short),
    4*sizeof(double),
    4*sizeof(float),
    4*sizeof(short),
    4*sizeof(char),
}

Static array with the size in byte of each value type.

Definition at line 232 of file vertex_buffer.h.

Referenced by NL3D::CDriverD3D::createVertexDeclaration(), initEx(), and serialSubset().


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

Generated on Thu Jan 7 08:30:14 2010 for NeL by  doxygen 1.6.1