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_TextureSet;
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 RGB sprite.
35 const Handle(OpenGl_TextureSet)& Sprite (const Handle(OpenGl_Context)& theCtx,
36 const Handle(Graphic3d_Aspects)& theAspecta)
40 build (theCtx, theAspecta->MarkerImage(), theAspecta->MarkerType(), theAspecta->MarkerScale(), theAspecta->ColorRGBA(), myMarkerSize);
41 myIsSpriteReady = true;
46 //! Return Alpha sprite.
47 const Handle(OpenGl_TextureSet)& SpriteA (const Handle(OpenGl_Context)& theCtx,
48 const Handle(Graphic3d_Aspects)& theAspecta)
52 build (theCtx, theAspecta->MarkerImage(), theAspecta->MarkerType(), theAspecta->MarkerScale(), theAspecta->ColorRGBA(), myMarkerSize);
53 myIsSpriteReady = true;
58 //! Update texture resource up-to-date state.
59 Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect);
61 //! Release texture resource.
62 Standard_EXPORT void Release (OpenGl_Context* theCtx);
66 //! Build texture resources.
67 Standard_EXPORT void build (const Handle(OpenGl_Context)& theCtx,
68 const Handle(Graphic3d_MarkerImage)& theMarkerImage,
69 Aspect_TypeOfMarker theType,
70 Standard_ShortReal theScale,
71 const Graphic3d_Vec4& theColor,
72 Standard_ShortReal& theMarkerSize);
74 //! Generate resource keys for a sprite.
75 static void spriteKeys (const Handle(Graphic3d_MarkerImage)& theMarkerImage,
76 Aspect_TypeOfMarker theType,
77 Standard_ShortReal theScale,
78 const Graphic3d_Vec4& theColor,
79 TCollection_AsciiString& theKey,
80 TCollection_AsciiString& theKeyA);
84 Handle(OpenGl_TextureSet) mySprite;
85 Handle(OpenGl_TextureSet) mySpriteA;
86 Standard_ShortReal myMarkerSize;
87 Standard_Boolean myIsSpriteReady;
91 #endif // _OpenGl_Aspects_Header