1 // Copyright (c) 2019 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _OpenGl_AspectsSprite_Header
15 #define _OpenGl_AspectsSprite_Header
17 #include <Graphic3d_Aspects.hxx>
18 #include <Graphic3d_TextureMap.hxx>
21 class OpenGl_PointSprite;
23 //! OpenGl resources for custom point sprites.
24 class OpenGl_AspectsSprite
29 //! Empty constructor.
30 OpenGl_AspectsSprite() : myMarkerSize (1.0f), myIsSpriteReady (Standard_False) {}
32 Standard_ShortReal MarkerSize() const { return myMarkerSize; }
34 //! Return TRUE if resource is up-to-date.
35 bool IsReady() const { return myIsSpriteReady; }
37 //! Invalidate resource state.
38 void Invalidate() { myIsSpriteReady = false; }
40 //! Return TRUE if OpenGl point sprite resource defines texture.
41 Standard_EXPORT bool HasPointSprite (const Handle(OpenGl_Context)& theCtx,
42 const Handle(Graphic3d_Aspects)& theAspects);
44 //! Return TRUE if OpenGl point sprite resource defined by obsolete Display List (bitmap).
45 Standard_EXPORT bool IsDisplayListSprite (const Handle(OpenGl_Context)& theCtx,
46 const Handle(Graphic3d_Aspects)& theAspects);
49 Standard_EXPORT const Handle(OpenGl_PointSprite)& Sprite (const Handle(OpenGl_Context)& theCtx,
50 const Handle(Graphic3d_Aspects)& theAspects,
51 bool theIsAlphaSprite);
53 //! Update texture resource up-to-date state.
54 Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect);
56 //! Release texture resource.
57 Standard_EXPORT void Release (OpenGl_Context* theCtx);
61 //! Build texture resources.
62 Standard_EXPORT void build (const Handle(OpenGl_Context)& theCtx,
63 const Handle(Graphic3d_MarkerImage)& theMarkerImage,
64 Aspect_TypeOfMarker theType,
65 Standard_ShortReal theScale,
66 const Graphic3d_Vec4& theColor,
67 Standard_ShortReal& theMarkerSize);
69 //! Generate resource keys for a sprite.
70 static void spriteKeys (const Handle(Graphic3d_MarkerImage)& theMarkerImage,
71 Aspect_TypeOfMarker theType,
72 Standard_ShortReal theScale,
73 const Graphic3d_Vec4& theColor,
74 TCollection_AsciiString& theKey,
75 TCollection_AsciiString& theKeyA);
79 Handle(OpenGl_PointSprite) mySprite;
80 Handle(OpenGl_PointSprite) mySpriteA;
81 Standard_ShortReal myMarkerSize;
82 Standard_Boolean myIsSpriteReady;
86 #endif // _OpenGl_Aspects_Header