8613985b |
1 | // Created on: 2013-10-02 |
2 | // Created by: Denis BOGOLEPOV |
3 | // Copyright (c) 2013-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
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 |
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. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef _OpenGl_MaterialState_HeaderFile |
17 | #define _OpenGl_MaterialState_HeaderFile |
18 | |
19 | #include <OpenGl_ShaderStates.hxx> |
20 | #include <OpenGl_Material.hxx> |
21 | |
22 | //! Defines generic state of material properties. |
23 | class OpenGl_MaterialState : public OpenGl_StateInterface |
24 | { |
25 | public: |
26 | |
27 | //! Creates new material state. |
c40eb6b9 |
28 | OpenGl_MaterialState() : myAlphaCutoff (0.5f), myToDistinguish (false), myToMapTexture (false) {} |
8613985b |
29 | |
30 | //! Sets new material aspect. |
31 | void Set (const OpenGl_Material& theFrontMat, |
32 | const OpenGl_Material& theBackMat, |
c40eb6b9 |
33 | const float theAlphaCutoff, |
8613985b |
34 | const bool theToDistinguish, |
35 | const bool theToMapTexture) |
36 | { |
37 | myMatFront = theFrontMat; |
38 | myMatBack = theBackMat; |
c40eb6b9 |
39 | myAlphaCutoff = theAlphaCutoff; |
8613985b |
40 | myToDistinguish = theToDistinguish; |
41 | myToMapTexture = theToMapTexture; |
42 | } |
43 | |
44 | //! Return front material. |
45 | const OpenGl_Material& FrontMaterial() const { return myMatFront; } |
46 | |
47 | //! Return back material. |
48 | const OpenGl_Material& BackMaterial() const { return myMatBack; } |
49 | |
c40eb6b9 |
50 | //! Alpha cutoff value. |
51 | float AlphaCutoff() const { return myAlphaCutoff; } |
52 | |
2a332745 |
53 | //! Return TRUE if alpha test should be enabled. |
54 | bool HasAlphaCutoff() const { return myAlphaCutoff <= 1.0f; } |
55 | |
8613985b |
56 | //! Distinguish front/back flag. |
57 | bool ToDistinguish() const { return myToDistinguish; } |
58 | |
59 | //! Flag for mapping a texture. |
60 | bool ToMapTexture() const { return myToMapTexture; } |
61 | |
62 | private: |
63 | |
64 | OpenGl_Material myMatFront; //!< front material |
65 | OpenGl_Material myMatBack; //!< back material |
c40eb6b9 |
66 | float myAlphaCutoff; //!< alpha cutoff value |
8613985b |
67 | bool myToDistinguish; //!< distinguish front/back flag |
68 | bool myToMapTexture; //!< flag for mapping a texture |
69 | |
70 | }; |
71 | |
72 | #endif // _OpenGl_MaterialState_HeaderFile |