Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:58:49

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_AspectsSprite_Header
0015 #define _OpenGl_AspectsSprite_Header
0016 
0017 #include <Graphic3d_Aspects.hxx>
0018 #include <Graphic3d_TextureMap.hxx>
0019 
0020 class OpenGl_Context;
0021 class OpenGl_PointSprite;
0022 
0023 //! OpenGl resources for custom point sprites.
0024 class OpenGl_AspectsSprite
0025 {
0026 public:
0027   DEFINE_STANDARD_ALLOC
0028 public:
0029   //! Empty constructor.
0030   OpenGl_AspectsSprite()
0031       : myMarkerSize(1.0f),
0032         myIsSpriteReady(false)
0033   {
0034   }
0035 
0036   float MarkerSize() const { return myMarkerSize; }
0037 
0038   //! Return TRUE if resource is up-to-date.
0039   bool IsReady() const { return myIsSpriteReady; }
0040 
0041   //! Invalidate resource state.
0042   void Invalidate() { myIsSpriteReady = false; }
0043 
0044   //! Return TRUE if OpenGl point sprite resource defines texture.
0045   Standard_EXPORT bool HasPointSprite(const occ::handle<OpenGl_Context>&    theCtx,
0046                                       const occ::handle<Graphic3d_Aspects>& theAspects);
0047 
0048   //! Return TRUE if OpenGl point sprite resource defined by obsolete Display List (bitmap).
0049   Standard_EXPORT bool IsDisplayListSprite(const occ::handle<OpenGl_Context>&    theCtx,
0050                                            const occ::handle<Graphic3d_Aspects>& theAspects);
0051 
0052   //! Return sprite.
0053   Standard_EXPORT const occ::handle<OpenGl_PointSprite>& Sprite(
0054     const occ::handle<OpenGl_Context>&    theCtx,
0055     const occ::handle<Graphic3d_Aspects>& theAspects,
0056     bool                                  theIsAlphaSprite);
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 resources.
0066   Standard_EXPORT void build(const occ::handle<OpenGl_Context>&        theCtx,
0067                              const occ::handle<Graphic3d_MarkerImage>& theMarkerImage,
0068                              Aspect_TypeOfMarker                       theType,
0069                              float                                     theScale,
0070                              const NCollection_Vec4<float>&            theColor,
0071                              float&                                    theMarkerSize);
0072 
0073   //! Generate resource keys for a sprite.
0074   static void spriteKeys(const occ::handle<Graphic3d_MarkerImage>& theMarkerImage,
0075                          Aspect_TypeOfMarker                       theType,
0076                          float                                     theScale,
0077                          const NCollection_Vec4<float>&            theColor,
0078                          TCollection_AsciiString&                  theKey,
0079                          TCollection_AsciiString&                  theKeyA);
0080 
0081 private:
0082   occ::handle<OpenGl_PointSprite> mySprite;
0083   occ::handle<OpenGl_PointSprite> mySpriteA;
0084   float                           myMarkerSize;
0085   bool                            myIsSpriteReady;
0086 };
0087 
0088 #endif // _OpenGl_Aspects_Header