Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:21

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() : myIsTextureReady (Standard_False) {}
0032 
0033   //! Return TRUE if resource is up-to-date.
0034   bool IsReady() const { return myIsTextureReady; }
0035 
0036   //! Invalidate resource state.
0037   void Invalidate() { myIsTextureReady = false; }
0038 
0039   //! Return textures array.
0040   const Handle(OpenGl_TextureSet)& TextureSet (const Handle(OpenGl_Context)& theCtx,
0041                                                const Handle(Graphic3d_Aspects)& theAspect,
0042                                                const Handle(OpenGl_PointSprite)& theSprite,
0043                                                const Handle(OpenGl_PointSprite)& theSpriteA,
0044                                                bool theToHighlight)
0045   {
0046     if (!myIsTextureReady)
0047     {
0048       build (theCtx, theAspect, theSprite, theSpriteA);
0049       myIsTextureReady = true;
0050     }
0051     return theToHighlight && !myTextures[1].IsNull()
0052          ? myTextures[1]
0053          : myTextures[0];
0054   }
0055 
0056   //! Update texture resource up-to-date state.
0057   Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect);
0058 
0059   //! Release texture resource.
0060   Standard_EXPORT void Release (OpenGl_Context* theCtx);
0061 
0062 private:
0063 
0064   //! Build texture resource.
0065   Standard_EXPORT void build (const Handle(OpenGl_Context)& theCtx,
0066                               const Handle(Graphic3d_Aspects)& theAspect,
0067                               const Handle(OpenGl_PointSprite)& theSprite,
0068                               const Handle(OpenGl_PointSprite)& theSpriteA);
0069 
0070 private:
0071 
0072   Handle(OpenGl_TextureSet) myTextures[2];
0073   Standard_Boolean          myIsTextureReady;
0074 
0075 };
0076 
0077 #endif // _OpenGl_AspectsTextureSet_Header