Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 09:15:22

0001 // Copyright (c) 2019 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _OpenGl_AspectsTextureSet_Header
0015 #define _OpenGl_AspectsTextureSet_Header
0016 
0017 #include <Graphic3d_Aspects.hxx>
0018 #include <Graphic3d_TextureMap.hxx>
0019 
0020 class OpenGl_Context;
0021 class OpenGl_TextureSet;
0022 class OpenGl_PointSprite;
0023 
0024 //! OpenGl resources for custom textures.
0025 class OpenGl_AspectsTextureSet
0026 {
0027 public:
0028   DEFINE_STANDARD_ALLOC
0029 public:
0030   //! Empty constructor.
0031   OpenGl_AspectsTextureSet()
0032       : myIsTextureReady(false)
0033   {
0034   }
0035 
0036   //! Return TRUE if resource is up-to-date.
0037   bool IsReady() const { return myIsTextureReady; }
0038 
0039   //! Invalidate resource state.
0040   void Invalidate() { myIsTextureReady = false; }
0041 
0042   //! Return textures array.
0043   const occ::handle<OpenGl_TextureSet>& TextureSet(
0044     const occ::handle<OpenGl_Context>&     theCtx,
0045     const occ::handle<Graphic3d_Aspects>&  theAspect,
0046     const occ::handle<OpenGl_PointSprite>& theSprite,
0047     const occ::handle<OpenGl_PointSprite>& theSpriteA,
0048     bool                                   theToHighlight)
0049   {
0050     if (!myIsTextureReady)
0051     {
0052       build(theCtx, theAspect, theSprite, theSpriteA);
0053       myIsTextureReady = true;
0054     }
0055     return theToHighlight && !myTextures[1].IsNull() ? myTextures[1] : myTextures[0];
0056   }
0057 
0058   //! Update texture resource up-to-date state.
0059   Standard_EXPORT void UpdateRediness(const occ::handle<Graphic3d_Aspects>& theAspect);
0060 
0061   //! Release texture resource.
0062   Standard_EXPORT void Release(OpenGl_Context* theCtx);
0063 
0064 private:
0065   //! Build texture resource.
0066   Standard_EXPORT void build(const occ::handle<OpenGl_Context>&     theCtx,
0067                              const occ::handle<Graphic3d_Aspects>&  theAspect,
0068                              const occ::handle<OpenGl_PointSprite>& theSprite,
0069                              const occ::handle<OpenGl_PointSprite>& theSpriteA);
0070 
0071 private:
0072   occ::handle<OpenGl_TextureSet> myTextures[2];
0073   bool                           myIsTextureReady;
0074 };
0075 
0076 #endif // _OpenGl_AspectsTextureSet_Header