|
||||
File indexing completed on 2025-01-18 10:04:21
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 0030 Standard_EXPORT OpenGl_Element(); 0031 0032 virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const = 0; 0033 0034 //! Release GPU resources. 0035 //! Pointer to the context is used because this method might be called 0036 //! when the context is already being destroyed and usage of a handle 0037 //! would be unsafe 0038 virtual void Release (OpenGl_Context* theContext) = 0; 0039 0040 //! Pointer to the context is used because this method might be called 0041 //! when the context is already being destroyed and usage of a handle 0042 //! would be unsafe 0043 template <typename theResource_t> 0044 static void Destroy (OpenGl_Context* theContext, 0045 theResource_t*& theElement) 0046 { 0047 if (theElement == NULL) 0048 { 0049 return; 0050 } 0051 0052 theElement->Release (theContext); 0053 OpenGl_Element* anElement = theElement; 0054 delete anElement; 0055 theElement = NULL; 0056 } 0057 0058 public: 0059 0060 //! Return TRUE if primitive type generates shaded triangulation (to be used in filters). 0061 virtual Standard_Boolean IsFillDrawMode() const { return false; } 0062 0063 //! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules. 0064 virtual Standard_Size EstimatedDataSize() const { return 0; } 0065 0066 //! Increment memory usage statistics. 0067 //! Default implementation puts EstimatedDataSize() into Graphic3d_FrameStatsCounter_EstimatedBytesGeom. 0068 Standard_EXPORT virtual void UpdateMemStats (Graphic3d_FrameStatsDataTmp& theStats) const; 0069 0070 //! Increment draw calls statistics. 0071 //! @param theStats [in] [out] frame counters to increment 0072 //! @param theIsDetailed [in] indicate detailed dump (more counters - number of triangles, 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, Standard_Integer theDepth = -1) const; 0081 0082 protected: 0083 0084 Standard_EXPORT virtual ~OpenGl_Element(); 0085 0086 public: 0087 0088 DEFINE_STANDARD_ALLOC 0089 0090 }; 0091 0092 #endif // OpenGl_Element_Header
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |