Change Encyclo button name and macros icon
[ryzomcore.git] / nel / src / 3d / debug_vb.cpp
blobb1aebe6e06517a0c68744b9e166cd64bc4a19a2e
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "std3d.h"
18 #include "nel/3d/debug_vb.h"
19 #include "nel/3d/vertex_buffer.h"
20 #include "nel/3d/index_buffer.h"
22 #ifdef DEBUG_NEW
23 #define new DEBUG_NEW
24 #endif
26 namespace NL3D
29 static void checkRange(const uint8 *min, const uint8 *max, const uint8 *start, uint length, const std::string &msg)
31 if (start + length < min || start >= max)
33 nlwarning("Buffer start = %p, end = %p, accessed range = (%p, %p), %s", min, max, start, start + length, msg.c_str());
34 nlassert(0);
38 // ************************************************************************************
39 void nlCheckVertexBuffer(const CVertexBuffer &vb, const uint8 *ptr)
41 CVertexBufferRead vba;
42 vb.lock (vba);
43 checkRange((uint8 *) vba.getVertexCoordPointer(), (uint8 *) vba.getVertexCoordPointer() + vb.getNumVertices() * vb.getVertexSize(), ptr, 0, vb.getName());
46 // ************************************************************************************
47 void nlCheckVBA(CVertexBufferRead &vba, const uint8 *ptr)
49 checkRange((uint8 *) vba.getVertexCoordPointer(), (uint8 *) vba.getVertexCoordPointer() + vba.getParent()->getNumVertices() * vba.getParent()->getVertexSize(), ptr, 0, vba.getParent()->getName());
52 // ************************************************************************************
53 void nlCheckVBA(CVertexBufferReadWrite &vba, const uint8 *ptr)
55 checkRange((uint8 *) vba.getVertexCoordPointer(), (uint8 *) vba.getVertexCoordPointer() + vba.getParent()->getNumVertices() * vba.getParent()->getVertexSize(), ptr, 0, vba.getParent()->getName());
58 // ************************************************************************************
59 void nlCheckVBARange(CVertexBufferRead &vba, const uint8 *ptStart, uint length)
61 checkRange((uint8 *) vba.getVertexCoordPointer(), (uint8 *) vba.getVertexCoordPointer() + vba.getParent()->getNumVertices() * vba.getParent()->getVertexSize(), ptStart, length, vba.getParent()->getName());
64 // ************************************************************************************
65 void nlCheckVBARange(CVertexBufferReadWrite &vba, const uint8 *ptStart, uint length)
67 checkRange((uint8 *) vba.getVertexCoordPointer(), (uint8 *) vba.getVertexCoordPointer() + vba.getParent()->getNumVertices() * vba.getParent()->getVertexSize(), ptStart, length, vba.getParent()->getName());
70 // ************************************************************************************
71 void nlCheckIBARange(CIndexBufferReadWrite &iba, const uint8 *ptStart, uint length)
73 checkRange((uint8 *) iba.getPtr(), (uint8 *) iba.getPtr() + iba.getParent()->getNumIndexes() * iba.getIndexNumBytes(), ptStart, length, iba.getParent()->getName());
76 // ************************************************************************************
77 void nlCheckIBARange(CIndexBufferRead &iba, const uint8 *ptStart, uint length)
79 checkRange((uint8 *) iba.getPtr(), (uint8 *) iba.getPtr() + iba.getParent()->getNumIndexes() * iba.getIndexNumBytes(), ptStart, length, iba.getParent()->getName());
82 // ************************************************************************************
83 void nlCheckIBA(CIndexBufferReadWrite &iba, const uint8 *ptStart)
85 checkRange((uint8 *) iba.getPtr(), (uint8 *) iba.getPtr() + iba.getParent()->getNumIndexes() * iba.getIndexNumBytes(), ptStart, 0, iba.getParent()->getName());
88 // ************************************************************************************
89 void nlCheckIBA(CIndexBufferRead &iba, const uint8 *ptStart)
91 checkRange((uint8 *) iba.getPtr(), (uint8 *) iba.getPtr() + iba.getParent()->getNumIndexes() * iba.getIndexNumBytes(), ptStart, 0, iba.getParent()->getName());
94 } // NL3D