NL3D::CVertexArrayRangeATI Class Reference

#include <driver_opengl_vertex_buffer_hard.h>

Inheritance diagram for NL3D::CVertexArrayRangeATI:

NL3D::IVertexArrayRange

Detailed Description

Work only if ATIVertexArrayObject is enabled. else, only call to ctor/dtor/free() is valid. any call to allocateVB() will return NULL.

Definition at line 250 of file driver_opengl_vertex_buffer_hard.h.

Public Member Functions

 CVertexArrayRangeATI (CDriverGL *drv)
void disable ()
void enable ()
void freeVB (void *ptr)
 free a VB allocated with allocateVB. No-op if NULL.

uint getATIVertexObjectId () const
 get Handle of the ATI buffer.

Implementation
virtual bool allocate (uint32 size, IDriver::TVBHardType vbType)
 allocate a vertex array sapce. false if error. must free before re-allocate.

virtual IVertexBufferHardGLcreateVBHardGL (uint16 vertexFormat, const uint8 *typeArray, uint32 numVertices, const uint8 *uvRouting)
 create a IVertexBufferHardGL

virtual void free ()
 free this space.

virtual uint sizeAllocated () const
 return the size allocated. 0 if not allocated or failure


Protected Attributes

CDriverGL_Driver

Private Member Functions

void * allocateVB (uint32 size)
 Allocate a small subset of the memory. NULL if not enough mem.


Private Attributes

bool _Allocated
NLMISC::CHeapMemory _HeapMemory
uint32 _VertexArraySize
uint _VertexObjectId


Constructor & Destructor Documentation

NL3D::CVertexArrayRangeATI::CVertexArrayRangeATI CDriverGL drv  ) 
 

Definition at line 434 of file driver_opengl_vertex_buffer_hard.cpp.

References _Allocated, and _VertexObjectId.

00434                                                          : IVertexArrayRange(drv)
00435 {
00436         _Allocated= false;
00437         _VertexObjectId= 0;
00438         _VertexArraySize= 0;
00439 }


Member Function Documentation

bool NL3D::CVertexArrayRangeATI::allocate uint32  size,
IDriver::TVBHardType  vbType
[virtual]
 

allocate a vertex array sapce. false if error. must free before re-allocate.

Implements NL3D::IVertexArrayRange.

Definition at line 441 of file driver_opengl_vertex_buffer_hard.cpp.

References _Allocated, _VertexObjectId, GL_DYNAMIC_ATI, GL_STATIC_ATI, NLMISC::CHeapMemory::initHeap(), nglIsObjectBufferATI, nglNewObjectBufferATI, NL3D_DRV_ATI_FAKE_MEM_START, nlassert, size, and uint32.

00442 {
00443         nlassert(!_Allocated);
00444 
00445         // try to allocate AGP (suppose mean ATI dynamic) or VRAM (suppose mean ATI static) data.
00446         switch(vbType)
00447         {
00448         case IDriver::VBHardAGP: 
00449                 _VertexObjectId= nglNewObjectBufferATI(size, NULL, GL_DYNAMIC_ATI);
00450                 break;
00451         case IDriver::VBHardVRAM:
00452                 _VertexObjectId= nglNewObjectBufferATI(size, NULL, GL_STATIC_ATI);
00453                 break;
00454         };
00455 
00456 
00457         // init the allocator, if success
00458         if( nglIsObjectBufferATI(_VertexObjectId) )
00459         {
00460                 _Allocated= true;
00461                 /* Init with an alignment of 8. Not sure if it is usefull.
00462                         Init With a FAKE memory starting at NL3D_DRV_ATI_FAKE_MEM_START
00463                 */
00464                 _HeapMemory.initHeap((void*)NL3D_DRV_ATI_FAKE_MEM_START, size, 8);
00465 
00466                 // set the size
00467                 _VertexArraySize= size;
00468 
00469                 // Ok!
00470                 return true;
00471         }
00472         else
00473         {
00474                 // failure.
00475                 return false;
00476         }
00477 }

void * NL3D::CVertexArrayRangeATI::allocateVB uint32  size  )  [private]
 

Allocate a small subset of the memory. NULL if not enough mem.

Definition at line 555 of file driver_opengl_vertex_buffer_hard.cpp.

References NLMISC::CHeapMemory::allocate(), size, and uint32.

Referenced by createVBHardGL().

00556 {
00557         return _HeapMemory.allocate(size);
00558 }

IVertexBufferHardGL * NL3D::CVertexArrayRangeATI::createVBHardGL uint16  vertexFormat,
const uint8 typeArray,
uint32  numVertices,
const uint8 uvRouting
[virtual]
 

create a IVertexBufferHardGL

Implements NL3D::IVertexArrayRange.

Definition at line 500 of file driver_opengl_vertex_buffer_hard.cpp.

References _Allocated, allocateVB(), NL3D::CVertexBufferHardGLATI::createRAMMirror(), NL3D::IVertexBufferHard::getNumVertices(), NL3D::IVertexBufferHard::getVertexSize(), NL3D::IVertexBufferHardGL::initFormat(), NL3D::CVertexBufferHardGLATI::initGL(), size, uint16, uint32, and uint8.

00501 {
00502         // create a ATI VBHard
00503         CVertexBufferHardGLATI  *newVbHard= new CVertexBufferHardGLATI(_Driver);
00504 
00505         // Init the format of the VB.
00506         newVbHard->initFormat(vertexFormat, typeArray, numVertices, uvRouting);
00507 
00508         // compute size to allocate.
00509         uint32  size= newVbHard->getVertexSize() * newVbHard->getNumVertices();
00510 
00511         // try to allocate
00512         void    *vertexPtr =NULL;
00513         if( _Allocated )
00514         {
00515                  vertexPtr= allocateVB(size);
00516         }
00517 
00518         // If allocation fails.
00519         if( !vertexPtr )
00520         {
00521                 // just destroy this object (no free()).
00522                 delete newVbHard;
00523                 return NULL;
00524         }
00525         else
00526         {
00527                 // Then try to create a RAM mirror in the VB.
00528                 if( newVbHard->createRAMMirror(size) )
00529                 {
00530                         // Ok, setup
00531                         newVbHard->initGL(this, vertexPtr);
00532                         return newVbHard;
00533                 }
00534                 else
00535                 {
00536                         // Discard the VB.
00537                         delete newVbHard;
00538                         return NULL;
00539                 }
00540         }
00541 }

void NL3D::CVertexArrayRangeATI::disable  ) 
 

disable this VertexArrayRange. _Driver->_CurrentVertexArrayRange= NULL; NB: no-op for ATI, but ensure correct _Driver->_CurrentVertexArrayRange value.

Definition at line 549 of file driver_opengl_vertex_buffer_hard.cpp.

References NL3D::CDriverGL::_CurrentVertexArrayRange.

Referenced by NL3D::CVertexBufferHardGLATI::disable().

00550 {
00551         // No-op for ATI !!!
00552         _Driver->_CurrentVertexArrayRange= NULL;
00553 }

void NL3D::CVertexArrayRangeATI::enable  ) 
 

active this VertexArrayRange as the current vertex array range used. no-op if already setup. NB: no-op for ATI, but ensure correct _Driver->_CurrentVertexArrayRange value.

Definition at line 543 of file driver_opengl_vertex_buffer_hard.cpp.

References NL3D::CDriverGL::_CurrentVertexArrayRange.

Referenced by NL3D::CVertexBufferHardGLATI::enable().

00544 {
00545         // No-op for ATI !!!
00546         _Driver->_CurrentVertexArrayRange= this;
00547 }

void NL3D::CVertexArrayRangeATI::free  )  [virtual]
 

free this space.

Implements NL3D::IVertexArrayRange.

Definition at line 484 of file driver_opengl_vertex_buffer_hard.cpp.

References _Allocated, _VertexObjectId, nglDeleteObjectBufferATI, and NLMISC::CHeapMemory::reset().

00485 {
00486         // release the ptr.
00487         if(_Allocated)
00488         {
00489                 // reset the allocator.
00490                 _HeapMemory.reset();
00491 
00492                 // Free special memory.
00493                 nglDeleteObjectBufferATI(_VertexObjectId);
00494 
00495                 _Allocated= false;
00496                 _VertexArraySize= 0;
00497         }
00498 }

void NL3D::CVertexArrayRangeATI::freeVB void *  ptr  ) 
 

free a VB allocated with allocateVB. No-op if NULL.

Definition at line 560 of file driver_opengl_vertex_buffer_hard.cpp.

References NLMISC::CHeapMemory::free().

Referenced by NL3D::CVertexBufferHardGLATI::~CVertexBufferHardGLATI().

00561 {
00562         _HeapMemory.free(ptr);
00563 }

uint NL3D::CVertexArrayRangeATI::getATIVertexObjectId  )  const [inline]
 

get Handle of the ATI buffer.

Definition at line 284 of file driver_opengl_vertex_buffer_hard.h.

References _VertexObjectId, and uint.

Referenced by NL3D::CVertexBufferHardGLATI::getATIVertexObjectId().

00284 {return _VertexObjectId;}

uint NL3D::CVertexArrayRangeATI::sizeAllocated  )  const [virtual]
 

return the size allocated. 0 if not allocated or failure

Implements NL3D::IVertexArrayRange.

Definition at line 479 of file driver_opengl_vertex_buffer_hard.cpp.

References uint.

00480 {
00481         return _VertexArraySize;
00482 }


Field Documentation

bool NL3D::CVertexArrayRangeATI::_Allocated [private]
 

Definition at line 289 of file driver_opengl_vertex_buffer_hard.h.

Referenced by allocate(), createVBHardGL(), CVertexArrayRangeATI(), and free().

CDriverGL* NL3D::IVertexArrayRange::_Driver [protected, inherited]
 

Definition at line 69 of file driver_opengl_vertex_buffer_hard.h.

NLMISC::CHeapMemory NL3D::CVertexArrayRangeATI::_HeapMemory [private]
 

Definition at line 293 of file driver_opengl_vertex_buffer_hard.h.

uint32 NL3D::CVertexArrayRangeATI::_VertexArraySize [private]
 

Definition at line 290 of file driver_opengl_vertex_buffer_hard.h.

uint NL3D::CVertexArrayRangeATI::_VertexObjectId [private]
 

Definition at line 288 of file driver_opengl_vertex_buffer_hard.h.

Referenced by allocate(), CVertexArrayRangeATI(), free(), and getATIVertexObjectId().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 08:23:03 2004 for NeL by doxygen 1.3.6