// NeL - MMORPG Framework // Copyright (C) 2010 Winch Gate Property Limited // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . #include "std3d.h" #include "nel/3d/vertex_stream_manager.h" #include "nel/misc/hierarchical_timer.h" using namespace NLMISC; namespace NL3D { // *************************************************************************** CVertexStreamManager::CVertexStreamManager() { _InitOk= false; _SupportVolatileVB = false; _VertexFormat= 0; _VertexSize= 0; _MaxVertices= 0; _CurentVB= 0; _NumVB= 0; _LockDone = false; } // *************************************************************************** CVertexStreamManager::~CVertexStreamManager() { release(); } // *************************************************************************** void CVertexStreamManager::init(IDriver *driver, uint vertexFormat, uint maxVertices, uint numVBHard, const std::string &vbName, bool allowVolatileVertexBuffer /*= false*/) { nlassert(driver); // clean before. release(); // Create VBHard placeholder if(numVBHard==0 || maxVertices==0) return; _NumVB= numVBHard; _VB.resize(_NumVB); // setup, => correct for possible release below _Driver= driver; // create the VBHard, if possible uint i; for(i=0;i<_NumVB;i++) { _VB[i].setVertexFormat(vertexFormat); // For the moment, all UV channel are routed to UV0 uint j; for (j=0; jsupportVolatileVertexBuffer() && allowVolatileVertexBuffer) { _VBVolatile.setVertexFormat(vertexFormat); // For the moment, all UV channel are routed to UV0 uint j; for (j=0; jactiveVertexBuffer(_VBVolatile); } else { _Driver->activeVertexBuffer(_VB[_CurentVB]); } } // *************************************************************************** void CVertexStreamManager::swapVBHard() { nlassert(_InitOk); _LockDone = false; if (!_SupportVolatileVB) { _CurentVB++; _CurentVB= _CurentVB%_NumVB; } } // *************************************************************************** bool CVertexStreamManager::isBRGA() const { nlassert(_InitOk); nlassert(_LockDone); return _VBA.getParent()->getVertexColorFormat()==CVertexBuffer::TBGRA; } } // NL3D