c5751993 |
1 | // Copyright (c) 2014 OPEN CASCADE SAS |
2 | // |
3 | // This file is part of Open CASCADE Technology software library. |
4 | // |
0a36ca0a |
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 |
c5751993 |
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. |
10 | // |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
13 | |
14 | #ifndef _Graphic3d_ZLayerSettings_HeaderFile |
15 | #define _Graphic3d_ZLayerSettings_HeaderFile |
16 | |
17 | #include <Standard_TypeDef.hxx> |
18 | |
19 | enum Graphic3d_ZLayerSetting |
20 | { |
21 | Graphic3d_ZLayerDepthTest = 1, |
22 | Graphic3d_ZLayerDepthWrite = 2, |
23 | Graphic3d_ZLayerDepthClear = 4, |
24 | Graphic3d_ZLayerDepthOffset = 8 |
25 | }; |
26 | |
a1954302 |
27 | //! Structure defines list of ZLayer properties. |
c5751993 |
28 | struct Graphic3d_ZLayerSettings |
29 | { |
a1954302 |
30 | |
31 | //! Default settings. |
c5751993 |
32 | Graphic3d_ZLayerSettings() |
33 | : DepthOffsetFactor (1.0f), |
34 | DepthOffsetUnits (1.0f), |
35 | Flags (Graphic3d_ZLayerDepthTest |
36 | | Graphic3d_ZLayerDepthWrite |
a1954302 |
37 | | Graphic3d_ZLayerDepthClear), |
83da37b1 |
38 | IsImmediate (false), |
39 | UseEnvironmentTexture (true) |
c5751993 |
40 | {} |
41 | |
42 | //! Returns true if theSetting is enabled. |
487bf1ce |
43 | Standard_Boolean IsSettingEnabled (const Graphic3d_ZLayerSetting theSetting) const |
c5751993 |
44 | { |
45 | return (Flags & theSetting) == theSetting; |
46 | } |
47 | |
48 | //! Enables theSetting |
49 | void EnableSetting (const Graphic3d_ZLayerSetting theSetting) |
50 | { |
51 | Flags = Flags | theSetting; |
52 | } |
53 | |
54 | //! Disables theSetting |
55 | void DisableSetting (const Graphic3d_ZLayerSetting theSetting) |
56 | { |
57 | Flags = Flags & (~theSetting); |
58 | } |
59 | |
60 | //! Sets minimal possible positive depth offset. |
61 | //! Access DepthOffsetFactor and DepthOffsetUnits values for manual offset control. |
62 | void SetDepthOffsetPositive() |
63 | { |
64 | DepthOffsetFactor = 1.f; |
65 | DepthOffsetUnits = 1.f; |
66 | EnableSetting (Graphic3d_ZLayerDepthOffset); |
67 | } |
68 | |
69 | //! Sets minimal possible negative depth offset. |
70 | //! Access DepthOffsetFactor and DepthOffsetUnits values for manual offset control. |
71 | void SetDepthOffsetNegative() |
72 | { |
73 | DepthOffsetFactor = 1.f; |
74 | DepthOffsetUnits = -1.f; |
75 | EnableSetting (Graphic3d_ZLayerDepthOffset); |
76 | } |
77 | |
a1954302 |
78 | public: |
79 | |
83da37b1 |
80 | Standard_ShortReal DepthOffsetFactor; //!< factor argument value for OpenGl glPolygonOffset function |
81 | Standard_ShortReal DepthOffsetUnits; //!< units argument value for OpenGl glPolygonOffset function |
82 | Standard_Integer Flags; //!< storage field for settings |
83 | bool IsImmediate; //!< immediate layer will be drawn after all normal layers |
84 | bool UseEnvironmentTexture; //!< flag to allow/prevent environment texture mapping usage for specific layer |
c5751993 |
85 | |
c5751993 |
86 | }; |
87 | |
88 | #endif // _Graphic3d_ZLayerSettings_HeaderFile |