Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-28 09:19:07

0001 // Created on: 2011-08-05
0002 // Created by: Sergey ZERCHANINOV
0003 // Copyright (c) 2011-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef OpenGl_Element_HeaderFile
0017 #define OpenGl_Element_HeaderFile
0018 
0019 #include <Standard_Type.hxx>
0020 
0021 class Graphic3d_FrameStatsDataTmp;
0022 class OpenGl_Workspace;
0023 class OpenGl_Context;
0024 
0025 //! Base interface for drawable elements.
0026 class OpenGl_Element
0027 {
0028 public:
0029   Standard_EXPORT OpenGl_Element();
0030 
0031   virtual void Render(const Handle(OpenGl_Workspace)& theWorkspace) const = 0;
0032 
0033   //! Release GPU resources.
0034   //! Pointer to the context is used because this method might be called
0035   //! when the context is already being destroyed and usage of a handle
0036   //! would be unsafe
0037   virtual void Release(OpenGl_Context* theContext) = 0;
0038 
0039   //! Pointer to the context is used because this method might be called
0040   //! when the context is already being destroyed and usage of a handle
0041   //! would be unsafe
0042   template <typename theResource_t>
0043   static void Destroy(OpenGl_Context* theContext, theResource_t*& theElement)
0044   {
0045     if (theElement == NULL)
0046     {
0047       return;
0048     }
0049 
0050     theElement->Release(theContext);
0051     OpenGl_Element* anElement = theElement;
0052     delete anElement;
0053     theElement = NULL;
0054   }
0055 
0056 public:
0057   //! Return TRUE if primitive type generates shaded triangulation (to be used in filters).
0058   virtual Standard_Boolean IsFillDrawMode() const { return false; }
0059 
0060   //! Returns estimated GPU memory usage for holding data without considering overheads and
0061   //! allocation alignment rules.
0062   virtual Standard_Size EstimatedDataSize() const { return 0; }
0063 
0064   //! Increment memory usage statistics.
0065   //! Default implementation puts EstimatedDataSize() into
0066   //! Graphic3d_FrameStatsCounter_EstimatedBytesGeom.
0067   Standard_EXPORT virtual void UpdateMemStats(Graphic3d_FrameStatsDataTmp& theStats) const;
0068 
0069   //! Increment draw calls statistics.
0070   //! @param[in][out] theStats   frame counters to increment
0071   //! @param[in] theIsDetailed   indicate detailed dump (more counters - number of triangles,
0072   //! points, etc.)
0073   Standard_EXPORT virtual void UpdateDrawStats(Graphic3d_FrameStatsDataTmp& theStats,
0074                                                bool                         theIsDetailed) const;
0075 
0076   //! Update parameters of the drawable elements.
0077   virtual void SynchronizeAspects() {}
0078 
0079   //! Dumps the content of me into the stream
0080   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream,
0081                                         Standard_Integer  theDepth = -1) const;
0082 
0083 protected:
0084   Standard_EXPORT virtual ~OpenGl_Element();
0085 
0086 public:
0087   DEFINE_STANDARD_ALLOC
0088 };
0089 
0090 #endif // OpenGl_Element_Header