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_Aspects_Header
15 #define _OpenGl_Aspects_Header
17 #include <OpenGl_Element.hxx>
18 #include <OpenGl_AspectsProgram.hxx>
19 #include <OpenGl_AspectsTextureSet.hxx>
20 #include <OpenGl_AspectsSprite.hxx>
21 #include <Graphic3d_Aspects.hxx>
22 #include <Graphic3d_BSDF.hxx>
24 //! The element holding Graphic3d_Aspects.
25 class OpenGl_Aspects : public OpenGl_Element
29 //! Empty constructor.
30 Standard_EXPORT OpenGl_Aspects();
32 //! Create and assign parameters.
33 Standard_EXPORT OpenGl_Aspects (const Handle(Graphic3d_Aspects)& theAspect);
36 const Handle(Graphic3d_Aspects)& Aspect() const { return myAspect; }
38 //! Assign parameters.
39 Standard_EXPORT void SetAspect (const Handle(Graphic3d_Aspects)& theAspect);
41 //! Returns Shading Model.
42 Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
44 //! Set if lighting should be disabled or not.
45 void SetNoLighting() { myShadingModel = Graphic3d_TOSM_UNLIT; }
47 //! Returns textures map.
48 const Handle(OpenGl_TextureSet)& TextureSet (const Handle(OpenGl_Context)& theCtx,
49 bool theToHighlight = false) const
51 const Handle(OpenGl_PointSprite)& aSprite = myResSprite.Sprite (theCtx, myAspect, false);
52 const Handle(OpenGl_PointSprite)& aSpriteA = myResSprite.Sprite (theCtx, myAspect, true);
53 return myResTextureSet.TextureSet (theCtx, myAspect, aSprite, aSpriteA, theToHighlight);
56 //! Init and return OpenGl shader program resource.
57 //! @return shader program resource.
58 const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Context)& theCtx) const
60 return myResProgram.ShaderProgram (theCtx, myAspect->ShaderProgram());
63 //! @return marker size
64 Standard_ShortReal MarkerSize() const { return myResSprite.MarkerSize(); }
66 //! Return TRUE if OpenGl point sprite resource defines texture.
67 bool HasPointSprite (const Handle(OpenGl_Context)& theCtx) const
69 return myResSprite.HasPointSprite (theCtx, myAspect);
72 //! Return TRUE if OpenGl point sprite resource defined by obsolete Display List (bitmap).
73 bool IsDisplayListSprite (const Handle(OpenGl_Context)& theCtx) const
75 return myResSprite.IsDisplayListSprite (theCtx, myAspect);
78 //! Init and return OpenGl point sprite resource.
79 //! @return point sprite texture.
80 const Handle(OpenGl_PointSprite)& SpriteRes (const Handle(OpenGl_Context)& theCtx,
81 bool theIsAlphaSprite) const
83 return myResSprite.Sprite (theCtx, myAspect, theIsAlphaSprite);
86 Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
87 Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
89 //! Update presentation aspects parameters after their modification.
90 virtual void SynchronizeAspects() Standard_OVERRIDE { SetAspect (myAspect); }
92 //! Dumps the content of me into the stream
93 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
98 mutable OpenGl_AspectsProgram myResProgram;
99 mutable OpenGl_AspectsTextureSet myResTextureSet;
100 mutable OpenGl_AspectsSprite myResSprite;
102 Handle(Graphic3d_Aspects) myAspect;
103 Graphic3d_TypeOfShadingModel myShadingModel;
107 DEFINE_STANDARD_ALLOC
111 #endif // _OpenGl_Aspects_Header