Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/OpenGl_Aspects.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (c) 2019 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _OpenGl_Aspects_Header
0015 #define _OpenGl_Aspects_Header
0016 
0017 #include <OpenGl_Element.hxx>
0018 #include <OpenGl_AspectsProgram.hxx>
0019 #include <OpenGl_AspectsTextureSet.hxx>
0020 #include <OpenGl_AspectsSprite.hxx>
0021 #include <Graphic3d_Aspects.hxx>
0022 
0023 //! The element holding Graphic3d_Aspects.
0024 class OpenGl_Aspects : public OpenGl_Element
0025 {
0026 public:
0027   //! Empty constructor.
0028   Standard_EXPORT OpenGl_Aspects();
0029 
0030   //! Create and assign parameters.
0031   Standard_EXPORT OpenGl_Aspects(const occ::handle<Graphic3d_Aspects>& theAspect);
0032 
0033   //! Return aspect.
0034   const occ::handle<Graphic3d_Aspects>& Aspect() const { return myAspect; }
0035 
0036   //! Assign parameters.
0037   Standard_EXPORT void SetAspect(const occ::handle<Graphic3d_Aspects>& theAspect);
0038 
0039   //! Returns Shading Model.
0040   Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
0041 
0042   //! Set if lighting should be disabled or not.
0043   void SetNoLighting() { myShadingModel = Graphic3d_TypeOfShadingModel_Unlit; }
0044 
0045   //! Returns textures map.
0046   const occ::handle<OpenGl_TextureSet>& TextureSet(const occ::handle<OpenGl_Context>& theCtx,
0047                                                    bool theToHighlight = false) const
0048   {
0049     const occ::handle<OpenGl_PointSprite>& aSprite  = myResSprite.Sprite(theCtx, myAspect, false);
0050     const occ::handle<OpenGl_PointSprite>& aSpriteA = myResSprite.Sprite(theCtx, myAspect, true);
0051     return myResTextureSet.TextureSet(theCtx, myAspect, aSprite, aSpriteA, theToHighlight);
0052   }
0053 
0054   //! Init and return OpenGl shader program resource.
0055   //! @return shader program resource.
0056   const occ::handle<OpenGl_ShaderProgram>& ShaderProgramRes(
0057     const occ::handle<OpenGl_Context>& theCtx) const
0058   {
0059     return myResProgram.ShaderProgram(theCtx, myAspect->ShaderProgram());
0060   }
0061 
0062   //! @return marker size
0063   float MarkerSize() const { return myResSprite.MarkerSize(); }
0064 
0065   //! Return TRUE if OpenGl point sprite resource defines texture.
0066   bool HasPointSprite(const occ::handle<OpenGl_Context>& theCtx) const
0067   {
0068     return myResSprite.HasPointSprite(theCtx, myAspect);
0069   }
0070 
0071   //! Return TRUE if OpenGl point sprite resource defined by obsolete Display List (bitmap).
0072   bool IsDisplayListSprite(const occ::handle<OpenGl_Context>& theCtx) const
0073   {
0074     return myResSprite.IsDisplayListSprite(theCtx, myAspect);
0075   }
0076 
0077   //! Init and return OpenGl point sprite resource.
0078   //! @return point sprite texture.
0079   const occ::handle<OpenGl_PointSprite>& SpriteRes(const occ::handle<OpenGl_Context>& theCtx,
0080                                                    bool theIsAlphaSprite) const
0081   {
0082     return myResSprite.Sprite(theCtx, myAspect, theIsAlphaSprite);
0083   }
0084 
0085   Standard_EXPORT void Render(const occ::handle<OpenGl_Workspace>& theWorkspace) const override;
0086   Standard_EXPORT void Release(OpenGl_Context* theContext) override;
0087 
0088   //! Update presentation aspects parameters after their modification.
0089   void SynchronizeAspects() override { SetAspect(myAspect); }
0090 
0091   //! Dumps the content of me into the stream
0092   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override;
0093 
0094 protected:
0095   //! OpenGl resources
0096   mutable OpenGl_AspectsProgram    myResProgram;
0097   mutable OpenGl_AspectsTextureSet myResTextureSet;
0098   mutable OpenGl_AspectsSprite     myResSprite;
0099 
0100   occ::handle<Graphic3d_Aspects> myAspect;
0101   Graphic3d_TypeOfShadingModel   myShadingModel;
0102 
0103 public:
0104   DEFINE_STANDARD_ALLOC
0105 };
0106 
0107 #endif // _OpenGl_Aspects_Header