0032121: Draw Harness, ViewerTest - implement -reset option for vlight command
[occt.git] / src / OpenGl / OpenGl_AspectsTextureSet.hxx
CommitLineData
bf5f0ca2 1// Copyright (c) 2019 OPEN CASCADE SAS
2//
3// This file is part of Open CASCADE Technology software library.
4//
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.
10//
11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
13
14#ifndef _OpenGl_AspectsTextureSet_Header
15#define _OpenGl_AspectsTextureSet_Header
16
737e9a8d 17#include <Graphic3d_Aspects.hxx>
bf5f0ca2 18#include <Graphic3d_TextureMap.hxx>
19#include <Graphic3d_TextureSet.hxx>
20
21class OpenGl_Context;
22class OpenGl_TextureSet;
737e9a8d 23class OpenGl_PointSprite;
bf5f0ca2 24
25//! OpenGl resources for custom textures.
26class OpenGl_AspectsTextureSet
27{
28public:
29 DEFINE_STANDARD_ALLOC
30public:
31 //! Empty constructor.
32 OpenGl_AspectsTextureSet() : myIsTextureReady (Standard_False) {}
33
737e9a8d 34 //! Return TRUE if resource is up-to-date.
35 bool IsReady() const { return myIsTextureReady; }
36
37 //! Invalidate resource state.
38 void Invalidate() { myIsTextureReady = false; }
39
bf5f0ca2 40 //! Return textures array.
41 const Handle(OpenGl_TextureSet)& TextureSet (const Handle(OpenGl_Context)& theCtx,
737e9a8d 42 const Handle(Graphic3d_Aspects)& theAspect,
43 const Handle(OpenGl_PointSprite)& theSprite,
44 const Handle(OpenGl_PointSprite)& theSpriteA,
45 bool theToHighlight)
bf5f0ca2 46 {
47 if (!myIsTextureReady)
48 {
737e9a8d 49 build (theCtx, theAspect, theSprite, theSpriteA);
bf5f0ca2 50 myIsTextureReady = true;
51 }
737e9a8d 52 return theToHighlight && !myTextures[1].IsNull()
53 ? myTextures[1]
54 : myTextures[0];
bf5f0ca2 55 }
56
57 //! Update texture resource up-to-date state.
737e9a8d 58 Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect);
bf5f0ca2 59
60 //! Release texture resource.
61 Standard_EXPORT void Release (OpenGl_Context* theCtx);
62
63private:
64
65 //! Build texture resource.
66 Standard_EXPORT void build (const Handle(OpenGl_Context)& theCtx,
737e9a8d 67 const Handle(Graphic3d_Aspects)& theAspect,
68 const Handle(OpenGl_PointSprite)& theSprite,
69 const Handle(OpenGl_PointSprite)& theSpriteA);
bf5f0ca2 70
71private:
72
737e9a8d 73 Handle(OpenGl_TextureSet) myTextures[2];
bf5f0ca2 74 Standard_Boolean myIsTextureReady;
75
76};
77
78#endif // _OpenGl_AspectsTextureSet_Header