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) const
50 return myResTextureSet.TextureSet (theCtx, myAspect->TextureSet());
53 //! Init and return OpenGl shader program resource.
54 //! @return shader program resource.
55 const Handle(OpenGl_ShaderProgram)& ShaderProgramRes (const Handle(OpenGl_Context)& theCtx) const
57 return myResProgram.ShaderProgram (theCtx, myAspect->ShaderProgram());
60 //! @return marker size
61 Standard_ShortReal MarkerSize() const { return myResSprite.MarkerSize(); }
63 //! Init and return OpenGl point sprite resource.
64 //! @return point sprite texture.
65 const Handle(OpenGl_TextureSet)& SpriteRes (const Handle(OpenGl_Context)& theCtx) const
67 return myResSprite.Sprite (theCtx, myAspect);
70 //! Init and return OpenGl highlight point sprite resource.
71 //! @return point sprite texture for highlight.
72 const Handle(OpenGl_TextureSet)& SpriteHighlightRes (const Handle(OpenGl_Context)& theCtx) const
74 return myResSprite.SpriteA (theCtx, myAspect);
77 Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const Standard_OVERRIDE;
78 Standard_EXPORT virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
80 //! Update presentation aspects parameters after their modification.
81 virtual void SynchronizeAspects() Standard_OVERRIDE { SetAspect (myAspect); }
86 mutable OpenGl_AspectsProgram myResProgram;
87 mutable OpenGl_AspectsTextureSet myResTextureSet;
88 mutable OpenGl_AspectsSprite myResSprite;
90 Handle(Graphic3d_Aspects) myAspect;
91 Graphic3d_TypeOfShadingModel myShadingModel;
99 #endif // _OpenGl_Aspects_Header