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 struct Graphic3d_ZLayerSettings
29 Graphic3d_ZLayerSettings()
30 : DepthOffsetFactor (1.0f),
31 DepthOffsetUnits (1.0f),
32 Flags (Graphic3d_ZLayerDepthTest
33 | Graphic3d_ZLayerDepthWrite
34 | Graphic3d_ZLayerDepthClear)
37 //! Returns true if theSetting is enabled.
38 const Standard_Boolean IsSettingEnabled (const Graphic3d_ZLayerSetting theSetting) const
40 return (Flags & theSetting) == theSetting;
43 //! Enables theSetting
44 void EnableSetting (const Graphic3d_ZLayerSetting theSetting)
46 Flags = Flags | theSetting;
49 //! Disables theSetting
50 void DisableSetting (const Graphic3d_ZLayerSetting theSetting)
52 Flags = Flags & (~theSetting);
55 //! Sets minimal possible positive depth offset.
56 //! Access DepthOffsetFactor and DepthOffsetUnits values for manual offset control.
57 void SetDepthOffsetPositive()
59 DepthOffsetFactor = 1.f;
60 DepthOffsetUnits = 1.f;
61 EnableSetting (Graphic3d_ZLayerDepthOffset);
64 //! Sets minimal possible negative depth offset.
65 //! Access DepthOffsetFactor and DepthOffsetUnits values for manual offset control.
66 void SetDepthOffsetNegative()
68 DepthOffsetFactor = 1.f;
69 DepthOffsetUnits = -1.f;
70 EnableSetting (Graphic3d_ZLayerDepthOffset);
73 Standard_ShortReal DepthOffsetFactor; //!< Factor argument value for OpenGl glPolygonOffset function.
74 Standard_ShortReal DepthOffsetUnits; //!< Units argument value for OpenGl glPolygonOffset function.
76 Standard_Integer Flags; //!< Storage field for settings.
79 #endif // _Graphic3d_ZLayerSettings_HeaderFile