#include <driver_opengl_vertex_buffer_hard.h>
Inheritance diagram for NL3D::CVertexArrayRangeNVidia:
Definition at line 127 of file driver_opengl_vertex_buffer_hard.h.
Public Member Functions | |
CVertexArrayRangeNVidia (CDriverGL *drv) | |
void | disable () |
disable this VertexArrayRange. _Driver->_CurrentVertexArrayRange= NULL; | |
void | enable () |
active this VertexArrayRange as the current vertex array range used. no-op if already setup. | |
void | freeVB (void *ptr) |
free a VB allocated with allocateVB. No-op if NULL. | |
Implementation | |
virtual bool | allocate (uint32 size, IDriver::TVBHardType vbType) |
allocate a vertex array sapce. false if error. must free before re-allocate. | |
virtual IVertexBufferHardGL * | createVBHardGL (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 | |
bool | allocated () const |
true if allocated. | |
void * | allocateVB (uint32 size) |
Allocate a small subset of the memory. NULL if not enough mem. | |
Private Attributes | |
NLMISC::CHeapMemory | _HeapMemory |
void * | _VertexArrayPtr |
uint32 | _VertexArraySize |
|
Definition at line 93 of file driver_opengl_vertex_buffer_hard.cpp. References _VertexArrayPtr, and _VertexArraySize.
00093 : IVertexArrayRange(drv) 00094 { 00095 _VertexArrayPtr= NULL; 00096 _VertexArraySize= 0; 00097 } |
|
allocate a vertex array sapce. false if error. must free before re-allocate.
Implements NL3D::IVertexArrayRange. Definition at line 101 of file driver_opengl_vertex_buffer_hard.cpp. References _HeapMemory, _VertexArrayPtr, _VertexArraySize, NLMISC::CHeapMemory::initHeap(), nlassert, size, and uint32.
00102 { 00103 nlassert(_VertexArrayPtr==NULL); 00104 00105 #ifdef NL_OS_WINDOWS 00106 // try to allocate AGP or VRAM data. 00107 switch(vbType) 00108 { 00109 case IDriver::VBHardAGP: 00110 _VertexArrayPtr= wglAllocateMemoryNV(size, 0, 0, 0.5f); 00111 break; 00112 case IDriver::VBHardVRAM: 00113 _VertexArrayPtr= wglAllocateMemoryNV(size, 0, 0, 1.0f); 00114 break; 00115 }; 00116 #endif // NL_OS_WINDOWS 00117 00118 00119 // init the allocator. 00120 if(_VertexArrayPtr) 00121 { 00122 /* Init with an alignment of 8. Not sure it is usefull, but GDC01_Performance.pdf papers talks about 00123 "Data arrays must be 8-byte aligned". Don't know what "Data" is. 00124 */ 00125 _HeapMemory.initHeap(_VertexArrayPtr, size, 8); 00126 00127 // set the size 00128 _VertexArraySize= size; 00129 } 00130 00131 00132 return _VertexArrayPtr!=NULL; 00133 } |
|
true if allocated.
Definition at line 165 of file driver_opengl_vertex_buffer_hard.h. References _VertexArrayPtr. Referenced by createVBHardGL().
00165 {return _VertexArrayPtr!=NULL;} |
|
Allocate a small subset of the memory. NULL if not enough mem.
Definition at line 205 of file driver_opengl_vertex_buffer_hard.cpp. References _HeapMemory, NLMISC::CHeapMemory::allocate(), size, and uint32. Referenced by createVBHardGL().
00206 { 00207 return _HeapMemory.allocate(size); 00208 } |
|
create a IVertexBufferHardGL
Implements NL3D::IVertexArrayRange. Definition at line 219 of file driver_opengl_vertex_buffer_hard.cpp. References allocated(), allocateVB(), NL3D::IVertexBufferHard::getNumVertices(), NL3D::IVertexBufferHard::getVertexSize(), NL3D::IVertexBufferHardGL::initFormat(), NL3D::CVertexBufferHardGLNVidia::initGL(), size, uint16, uint32, and uint8.
00220 { 00221 // create a NVidia VBHard 00222 CVertexBufferHardGLNVidia *newVbHard= new CVertexBufferHardGLNVidia(_Driver); 00223 00224 // Init the format of the VB. 00225 newVbHard->initFormat(vertexFormat, typeArray, numVertices, uvRouting); 00226 00227 // compute size to allocate. 00228 uint32 size= newVbHard->getVertexSize() * newVbHard->getNumVertices(); 00229 00230 // try to allocate 00231 void *vertexPtr; 00232 if( allocated() ) 00233 { 00234 vertexPtr= allocateVB(size); 00235 } 00236 00237 // If allocation fails. 00238 if( !vertexPtr ) 00239 { 00240 // just destroy this object (no free()). 00241 delete newVbHard; 00242 return NULL; 00243 } 00244 else 00245 { 00246 // Ok, setup, and allocate the fence. 00247 newVbHard->initGL(this, vertexPtr); 00248 return newVbHard; 00249 } 00250 } |
|
disable this VertexArrayRange. _Driver->_CurrentVertexArrayRange= NULL;
Definition at line 191 of file driver_opengl_vertex_buffer_hard.cpp. References NL3D::CDriverGL::_CurrentVertexArrayRange, NL3D::CDriverGL::_Extensions, and NL3D::CGlExtensions::NVStateVARWithoutFlush. Referenced by NL3D::CVertexBufferHardGLNVidia::disable().
00192 { 00193 // if not already disabled. 00194 if(_Driver->_CurrentVertexArrayRange!=NULL) 00195 { 00196 // just disable the state, don't change VAR ptr setup. 00197 // NB: flush is unesufull, so don't flush if extension is OK 00198 glDisableClientState(_Driver->_Extensions.NVStateVARWithoutFlush); 00199 _Driver->_CurrentVertexArrayRange= NULL; 00200 } 00201 } |
|
active this VertexArrayRange as the current vertex array range used. no-op if already setup.
Definition at line 166 of file driver_opengl_vertex_buffer_hard.cpp. References NL3D::CDriverGL::_CurrentVertexArrayRange, NL3D::CDriverGL::_Extensions, NL3D::CDriverGL::_NVCurrentVARPtr, NL3D::CDriverGL::_NVCurrentVARSize, _VertexArrayPtr, _VertexArraySize, nglVertexArrayRangeNV, and NL3D::CGlExtensions::NVStateVARWithoutFlush. Referenced by NL3D::CVertexBufferHardGLNVidia::enable().
00167 { 00168 // if not already enabled. 00169 if(_Driver->_CurrentVertexArrayRange!=this) 00170 { 00171 // Setup the ptrs only if differnets from last time (may rarely happens) 00172 if( _Driver->_NVCurrentVARSize != _VertexArraySize || _Driver->_NVCurrentVARPtr != _VertexArrayPtr) 00173 { 00174 // Yoyo: fucking NVidia Bug ?? must do this strange thing, this ensure that it is correclty setuped. 00175 glFinish(); 00176 nglVertexArrayRangeNV(_VertexArraySize, _VertexArrayPtr); 00177 glEnableClientState(GL_VERTEX_ARRAY_RANGE_NV); 00178 glVertexPointer(3,GL_FLOAT, 0, _VertexArrayPtr); 00179 // cache. 00180 _Driver->_NVCurrentVARSize= _VertexArraySize; 00181 _Driver->_NVCurrentVARPtr= _VertexArrayPtr; 00182 } 00183 // enable VAR. NB: flush is unesufull, so don't flush if extension is OK 00184 glEnableClientState(_Driver->_Extensions.NVStateVARWithoutFlush); 00185 _Driver->_CurrentVertexArrayRange= this; 00186 } 00187 } |
|
free this space.
Implements NL3D::IVertexArrayRange. Definition at line 144 of file driver_opengl_vertex_buffer_hard.cpp. References _HeapMemory, _VertexArrayPtr, _VertexArraySize, and NLMISC::CHeapMemory::reset().
00145 { 00146 // release the ptr. 00147 if(_VertexArrayPtr) 00148 { 00149 // reset the allocator. 00150 _HeapMemory.reset(); 00151 00152 00153 // Free special memory. 00154 #ifdef NL_OS_WINDOWS 00155 wglFreeMemoryNV(_VertexArrayPtr); 00156 #endif // NL_OS_WINDOWS 00157 00158 00159 _VertexArrayPtr= NULL; 00160 _VertexArraySize= 0; 00161 } 00162 } |
|
free a VB allocated with allocateVB. No-op if NULL.
Definition at line 212 of file driver_opengl_vertex_buffer_hard.cpp. References _HeapMemory, and NLMISC::CHeapMemory::free(). Referenced by NL3D::CVertexBufferHardGLNVidia::~CVertexBufferHardGLNVidia().
00213 { 00214 _HeapMemory.free(ptr); 00215 } |
|
return the size allocated. 0 if not allocated or failure
Implements NL3D::IVertexArrayRange. Definition at line 137 of file driver_opengl_vertex_buffer_hard.cpp. References _VertexArraySize, and uint.
00138 { 00139 return _VertexArraySize; 00140 } |
|
Definition at line 69 of file driver_opengl_vertex_buffer_hard.h. |
|
Definition at line 162 of file driver_opengl_vertex_buffer_hard.h. Referenced by allocate(), allocateVB(), free(), and freeVB(). |
|
Definition at line 158 of file driver_opengl_vertex_buffer_hard.h. Referenced by allocate(), allocated(), CVertexArrayRangeNVidia(), enable(), and free(). |
|
Definition at line 159 of file driver_opengl_vertex_buffer_hard.h. Referenced by allocate(), CVertexArrayRangeNVidia(), enable(), free(), and sizeAllocated(). |