1 // Copyright (c) 2017 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 _OpenGl_TextureSet_Header
15 #define _OpenGl_TextureSet_Header
17 #include <Graphic3d_TextureSet.hxx>
21 //! Class holding array of textures to be mapped as a set.
22 class OpenGl_TextureSet : public Standard_Transient
24 DEFINE_STANDARD_RTTIEXT(OpenGl_TextureSet, Standard_Transient)
27 //! Class for iterating texture set.
28 class Iterator : public NCollection_Array1<Handle(OpenGl_Texture)>::Iterator
31 //! Empty constructor.
35 Iterator (const Handle(OpenGl_TextureSet)& theSet)
39 NCollection_Array1<Handle(OpenGl_Texture)>::Iterator::Init (theSet->myTextures);
46 //! Empty constructor.
47 OpenGl_TextureSet() {}
50 OpenGl_TextureSet (Standard_Integer theNbTextures)
51 : myTextures (0, theNbTextures - 1) {}
53 //! Constructor for a single texture.
54 OpenGl_TextureSet (const Handle(OpenGl_Texture)& theTexture)
57 myTextures.ChangeFirst() = theTexture;
60 //! Return TRUE if texture array is empty.
61 Standard_Boolean IsEmpty() const { return myTextures.IsEmpty(); }
63 //! Return number of textures.
64 Standard_Integer Size() const { return myTextures.Size(); }
66 //! Return the lower index in texture set.
67 Standard_Integer Lower() const { return myTextures.Lower(); }
69 //! Return the upper index in texture set.
70 Standard_Integer Upper() const { return myTextures.Upper(); }
72 //! Return the first texture.
73 const Handle(OpenGl_Texture)& First() const { return myTextures.First(); }
75 //! Return the first texture.
76 Handle(OpenGl_Texture)& ChangeFirst() { return myTextures.ChangeFirst(); }
78 //! Return the last texture.
79 const Handle(OpenGl_Texture)& Last() const { return myTextures.Last(); }
81 //! Return the last texture.
82 Handle(OpenGl_Texture)& ChangeLast() { return myTextures.ChangeLast(); }
84 //! Return the texture at specified position within [0, Size()) range.
85 const Handle(OpenGl_Texture)& Value (Standard_Integer theIndex) const { return myTextures.Value (theIndex); }
87 //! Return the texture at specified position within [0, Size()) range.
88 Handle(OpenGl_Texture)& ChangeValue (Standard_Integer theIndex) { return myTextures.ChangeValue (theIndex); }
90 //! Return TRUE if texture color modulation has been enabled for the first texture
91 //! or if texture is not set at all.
92 Standard_EXPORT bool IsModulate() const;
94 //! Return TRUE if other than point sprite textures are defined within point set.
95 Standard_EXPORT bool HasNonPointSprite() const;
97 //! Return TRUE if last texture is a point sprite.
98 Standard_EXPORT bool HasPointSprite() const;
100 //! Nullify all handles.
103 myTextures.Init (Handle(OpenGl_Texture)());
108 NCollection_Array1<Handle(OpenGl_Texture)> myTextures;
112 #endif //_OpenGl_TextureSet_Header