0031505: Point Cloud Rendering - fix on-screen statistics about number of visible...
[occt.git] / src / OpenGl / OpenGl_Element.hxx
CommitLineData
b311480e 1// Created on: 2011-08-05
2// Created by: Sergey ZERCHANINOV
973c2be1 3// Copyright (c) 2011-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
2166f0fa
SK
16#ifndef OpenGl_Element_Header
17#define OpenGl_Element_Header
18
4269bd1b 19#include <OpenGl_RenderFilter.hxx>
1b661a81 20#include <Standard_Type.hxx>
2166f0fa 21
b9f43ad1 22class Graphic3d_FrameStatsDataTmp;
c04c30b3 23class OpenGl_Workspace;
24class OpenGl_Context;
25
a174a3c5 26//! Base interface for drawable elements.
2166f0fa
SK
27class OpenGl_Element
28{
5e27df78 29public:
2166f0fa 30
a174a3c5 31 Standard_EXPORT OpenGl_Element();
5e27df78 32
33 virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const = 0;
34
35 //! Release GPU resources.
10b9c7df 36 //! Pointer to the context is used because this method might be called
37 //! when the context is already being destroyed and usage of a handle
38 //! would be unsafe
39 virtual void Release (OpenGl_Context* theContext) = 0;
40
41 //! Pointer to the context is used because this method might be called
42 //! when the context is already being destroyed and usage of a handle
43 //! would be unsafe
5e27df78 44 template <typename theResource_t>
10b9c7df 45 static void Destroy (OpenGl_Context* theContext,
46 theResource_t*& theElement)
5e27df78 47 {
48 if (theElement == NULL)
49 {
50 return;
51 }
52
53 theElement->Release (theContext);
54 OpenGl_Element* anElement = theElement;
55 delete anElement;
56 theElement = NULL;
57 }
58
4269bd1b 59public:
60
64c6d8df 61 //! Return TRUE if primitive type generates shaded triangulation (to be used in filters).
62 virtual Standard_Boolean IsFillDrawMode() const { return false; }
63
3d60d73f 64 //! Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
65 virtual Standard_Size EstimatedDataSize() const { return 0; }
66
b9f43ad1 67 //! Increment memory usage statistics.
68 //! Default implementation puts EstimatedDataSize() into Graphic3d_FrameStatsCounter_EstimatedBytesGeom.
69 Standard_EXPORT virtual void UpdateMemStats (Graphic3d_FrameStatsDataTmp& theStats) const;
70
71 //! Increment draw calls statistics.
72 //! @param theStats [in] [out] frame counters to increment
73 //! @param theIsDetailed [in] indicate detailed dump (more counters - number of triangles, points, etc.)
74 Standard_EXPORT virtual void UpdateDrawStats (Graphic3d_FrameStatsDataTmp& theStats,
75 bool theIsDetailed) const;
76
eaac0866 77 //! Update parameters of the drawable elements.
78 virtual void SynchronizeAspects() {}
79
bc73b006 80 //! Dumps the content of me into the stream
81 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
82
5e27df78 83protected:
84
a174a3c5 85 Standard_EXPORT virtual ~OpenGl_Element();
5e27df78 86
87public:
2166f0fa 88
1c35b92f 89 DEFINE_STANDARD_ALLOC
5e27df78 90
2166f0fa
SK
91};
92
a174a3c5 93#endif // OpenGl_Element_Header