1 // Copyright (c) 2019 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_AspectsTextureSet_Header
15 #define _OpenGl_AspectsTextureSet_Header
17 #include <Graphic3d_Aspects.hxx>
18 #include <Graphic3d_TextureMap.hxx>
19 #include <Graphic3d_TextureSet.hxx>
22 class OpenGl_TextureSet;
23 class OpenGl_PointSprite;
25 //! OpenGl resources for custom textures.
26 class OpenGl_AspectsTextureSet
31 //! Empty constructor.
32 OpenGl_AspectsTextureSet() : myIsTextureReady (Standard_False) {}
34 //! Return TRUE if resource is up-to-date.
35 bool IsReady() const { return myIsTextureReady; }
37 //! Invalidate resource state.
38 void Invalidate() { myIsTextureReady = false; }
40 //! Return textures array.
41 const Handle(OpenGl_TextureSet)& TextureSet (const Handle(OpenGl_Context)& theCtx,
42 const Handle(Graphic3d_Aspects)& theAspect,
43 const Handle(OpenGl_PointSprite)& theSprite,
44 const Handle(OpenGl_PointSprite)& theSpriteA,
47 if (!myIsTextureReady)
49 build (theCtx, theAspect, theSprite, theSpriteA);
50 myIsTextureReady = true;
52 return theToHighlight && !myTextures[1].IsNull()
57 //! Update texture resource up-to-date state.
58 Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect);
60 //! Release texture resource.
61 Standard_EXPORT void Release (OpenGl_Context* theCtx);
65 //! Build texture resource.
66 Standard_EXPORT void build (const Handle(OpenGl_Context)& theCtx,
67 const Handle(Graphic3d_Aspects)& theAspect,
68 const Handle(OpenGl_PointSprite)& theSprite,
69 const Handle(OpenGl_PointSprite)& theSpriteA);
73 Handle(OpenGl_TextureSet) myTextures[2];
74 Standard_Boolean myIsTextureReady;
78 #endif // _OpenGl_AspectsTextureSet_Header