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_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() : myMarkerSize (1.0f), myIsSpriteReady  (Standard_False) {}
0031 
0032   Standard_ShortReal MarkerSize() const { return myMarkerSize; }
0033 
0034   //! Return TRUE if resource is up-to-date.
0035   bool IsReady() const { return myIsSpriteReady; }
0036 
0037   //! Invalidate resource state.
0038   void Invalidate() { myIsSpriteReady = false; }
0039 
0040   //! Return TRUE if OpenGl point sprite resource defines texture.
0041   Standard_EXPORT bool HasPointSprite (const Handle(OpenGl_Context)& theCtx,
0042                                        const Handle(Graphic3d_Aspects)& theAspects);
0043 
0044   //! Return TRUE if OpenGl point sprite resource defined by obsolete Display List (bitmap).
0045   Standard_EXPORT bool IsDisplayListSprite (const Handle(OpenGl_Context)& theCtx,
0046                                             const Handle(Graphic3d_Aspects)& theAspects);
0047 
0048   //! Return sprite.
0049   Standard_EXPORT const Handle(OpenGl_PointSprite)& Sprite (const Handle(OpenGl_Context)& theCtx,
0050                                                             const Handle(Graphic3d_Aspects)& theAspects,
0051                                                             bool theIsAlphaSprite);
0052 
0053   //! Update texture resource up-to-date state.
0054   Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect);
0055 
0056   //! Release texture resource.
0057   Standard_EXPORT void Release (OpenGl_Context* theCtx);
0058 
0059 private:
0060 
0061   //! Build texture resources.
0062   Standard_EXPORT void build (const Handle(OpenGl_Context)& theCtx,
0063                               const Handle(Graphic3d_MarkerImage)& theMarkerImage,
0064                               Aspect_TypeOfMarker theType,
0065                               Standard_ShortReal theScale,
0066                               const Graphic3d_Vec4& theColor,
0067                               Standard_ShortReal& theMarkerSize);
0068 
0069   //! Generate resource keys for a sprite.
0070   static void spriteKeys (const Handle(Graphic3d_MarkerImage)& theMarkerImage,
0071                           Aspect_TypeOfMarker theType,
0072                           Standard_ShortReal theScale,
0073                           const Graphic3d_Vec4& theColor,
0074                           TCollection_AsciiString& theKey,
0075                           TCollection_AsciiString& theKeyA);
0076 
0077 private:
0078 
0079   Handle(OpenGl_PointSprite) mySprite;
0080   Handle(OpenGl_PointSprite) mySpriteA;
0081   Standard_ShortReal myMarkerSize;
0082   Standard_Boolean myIsSpriteReady;
0083 
0084 };
0085 
0086 #endif // _OpenGl_Aspects_Header