0032465: Visualization, TKOpenGles - invalid enum on GL_RGBA16F initialization in...
[occt.git] / src / OpenGl / OpenGl_AspectsSprite.hxx
1 // Copyright (c) 2019 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _OpenGl_AspectsSprite_Header
15 #define _OpenGl_AspectsSprite_Header
16
17 #include <Graphic3d_Aspects.hxx>
18 #include <Graphic3d_TextureMap.hxx>
19
20 class OpenGl_Context;
21 class OpenGl_PointSprite;
22
23 //! OpenGl resources for custom point sprites.
24 class OpenGl_AspectsSprite
25 {
26 public:
27   DEFINE_STANDARD_ALLOC
28 public:
29   //! Empty constructor.
30   OpenGl_AspectsSprite() : myMarkerSize (1.0f), myIsSpriteReady  (Standard_False) {}
31
32   Standard_ShortReal MarkerSize() const { return myMarkerSize; }
33
34   //! Return TRUE if resource is up-to-date.
35   bool IsReady() const { return myIsSpriteReady; }
36
37   //! Invalidate resource state.
38   void Invalidate() { myIsSpriteReady = false; }
39
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);
43
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);
47
48   //! Return sprite.
49   Standard_EXPORT const Handle(OpenGl_PointSprite)& Sprite (const Handle(OpenGl_Context)& theCtx,
50                                                             const Handle(Graphic3d_Aspects)& theAspects,
51                                                             bool theIsAlphaSprite);
52
53   //! Update texture resource up-to-date state.
54   Standard_EXPORT void UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect);
55
56   //! Release texture resource.
57   Standard_EXPORT void Release (OpenGl_Context* theCtx);
58
59 private:
60
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);
68
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);
76
77 private:
78
79   Handle(OpenGl_PointSprite) mySprite;
80   Handle(OpenGl_PointSprite) mySpriteA;
81   Standard_ShortReal myMarkerSize;
82   Standard_Boolean myIsSpriteReady;
83
84 };
85
86 #endif // _OpenGl_Aspects_Header