1 // Copyright (c) 2014 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 _Graphic3d_ZLayerSettings_HeaderFile
15 #define _Graphic3d_ZLayerSettings_HeaderFile
17 #include <Standard_TypeDef.hxx>
19 enum Graphic3d_ZLayerSetting
21 Graphic3d_ZLayerDepthTest = 1,
22 Graphic3d_ZLayerDepthWrite = 2,
23 Graphic3d_ZLayerDepthClear = 4,
24 Graphic3d_ZLayerDepthOffset = 8
27 //! Structure defines list of ZLayer properties.
28 struct Graphic3d_ZLayerSettings
32 Graphic3d_ZLayerSettings()
33 : DepthOffsetFactor (1.0f),
34 DepthOffsetUnits (1.0f),
35 Flags (Graphic3d_ZLayerDepthTest
36 | Graphic3d_ZLayerDepthWrite
37 | Graphic3d_ZLayerDepthClear),
41 //! Returns true if theSetting is enabled.
42 Standard_Boolean IsSettingEnabled (const Graphic3d_ZLayerSetting theSetting) const
44 return (Flags & theSetting) == theSetting;
47 //! Enables theSetting
48 void EnableSetting (const Graphic3d_ZLayerSetting theSetting)
50 Flags = Flags | theSetting;
53 //! Disables theSetting
54 void DisableSetting (const Graphic3d_ZLayerSetting theSetting)
56 Flags = Flags & (~theSetting);
59 //! Sets minimal possible positive depth offset.
60 //! Access DepthOffsetFactor and DepthOffsetUnits values for manual offset control.
61 void SetDepthOffsetPositive()
63 DepthOffsetFactor = 1.f;
64 DepthOffsetUnits = 1.f;
65 EnableSetting (Graphic3d_ZLayerDepthOffset);
68 //! Sets minimal possible negative depth offset.
69 //! Access DepthOffsetFactor and DepthOffsetUnits values for manual offset control.
70 void SetDepthOffsetNegative()
72 DepthOffsetFactor = 1.f;
73 DepthOffsetUnits = -1.f;
74 EnableSetting (Graphic3d_ZLayerDepthOffset);
79 Standard_ShortReal DepthOffsetFactor; //!< factor argument value for OpenGl glPolygonOffset function
80 Standard_ShortReal DepthOffsetUnits; //!< units argument value for OpenGl glPolygonOffset function
81 Standard_Integer Flags; //!< storage field for settings
82 bool IsImmediate; //!< immediate layer will be drawn after all normal layers
86 #endif // _Graphic3d_ZLayerSettings_HeaderFile