1 // Copyright (c) 2018 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _Graphic3d_AttribBuffer_HeaderFile
15 #define _Graphic3d_AttribBuffer_HeaderFile
17 #include <Graphic3d_Buffer.hxx>
19 //! Buffer of vertex attributes.
20 //! This class is intended for advanced usage allowing invalidation of entire buffer content or its sub-part.
21 class Graphic3d_AttribBuffer : public Graphic3d_Buffer
23 DEFINE_STANDARD_RTTIEXT(Graphic3d_AttribBuffer, Graphic3d_Buffer)
25 //! Empty constructor.
26 Standard_EXPORT Graphic3d_AttribBuffer (const Handle(NCollection_BaseAllocator)& theAlloc);
28 //! Allocates new empty array
29 Standard_EXPORT bool Init (const Standard_Integer theNbElems,
30 const Graphic3d_Attribute* theAttribs,
31 const Standard_Integer theNbAttribs);
33 //! Allocates new empty array
34 bool Init (const Standard_Integer theNbElems,
35 const Graphic3d_Array1OfAttribute& theAttribs)
37 return Init (theNbElems, &theAttribs.First(), theAttribs.Size());
40 //! Return TRUE if data can be invalidated; FALSE by default.
41 virtual Standard_Boolean IsMutable() const Standard_OVERRIDE { return myIsMutable; }
43 //! Set if data can be invalidated.
44 Standard_EXPORT void SetMutable (Standard_Boolean theMutable);
46 //! Return TRUE for interleaved array; TRUE by default.
47 virtual Standard_Boolean IsInterleaved() const Standard_OVERRIDE { return myIsInterleaved; }
49 //! Setup interleaved/non-interleaved array.
50 //! WARNING! Filling non-interleaved buffer should be implemented on user side
51 //! without Graphic3d_Buffer auxiliary methods designed for interleaved data.
52 Standard_EXPORT void SetInterleaved (Standard_Boolean theIsInterleaved);
54 //! Return invalidated range.
55 virtual Graphic3d_BufferRange InvalidatedRange() const Standard_OVERRIDE { return myInvalidatedRange; }
57 //! Reset invalidated range.
58 virtual void Validate() Standard_OVERRIDE { myInvalidatedRange.Clear(); }
60 //! Invalidate the entire buffer data.
61 Standard_EXPORT virtual void Invalidate() Standard_OVERRIDE;
63 //! Invalidate the entire attribute data.
64 Standard_EXPORT void Invalidate (Standard_Integer theAttributeIndex);
66 //! Invalidate attribute data within specified sub-range (starting from 0).
67 Standard_EXPORT void Invalidate (Standard_Integer theAttributeIndex,
68 Standard_Integer theVertexLower,
69 Standard_Integer theVertexUpper);
71 //! Invalidate all attribute data within specified vertex sub-range (starting from 0).
72 Standard_EXPORT void Invalidate (Standard_Integer theVertexLower,
73 Standard_Integer theVertexUpper);
75 //! Invalidate specified sub-range of data (as byte offsets).
76 Standard_EXPORT void invalidate (const Graphic3d_BufferRange& theRange);
79 Graphic3d_BufferRange myInvalidatedRange; //!< invalidated buffer data range (as byte offsets)
80 Standard_Boolean myIsInterleaved; //!< flag indicating the vertex attributes being interleaved
81 Standard_Boolean myIsMutable; //!< flag indicating that data can be invalidated
84 #endif // _Graphic3d_AttribBuffer_HeaderFile