3 * Copyright (c) 2007-2010 SlimDX Group
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 #include "DepthStencilOperationDescription.h"
27 #include "DepthStencilStateDescription.h"
29 using namespace System;
35 DepthStencilStateDescription::DepthStencilStateDescription( const D3D10_DEPTH_STENCIL_DESC& native )
37 m_DepthEnable = native.DepthEnable ? true : false;
38 m_DepthWriteMask = static_cast<Direct3D10::DepthWriteMask>( native.DepthWriteMask );
39 m_DepthFunc = static_cast<Comparison>( native.DepthFunc );
40 m_StencilEnable = native.StencilEnable ? true : false;
41 m_StencilReadMask = native.StencilReadMask;
42 m_StencilWriteMask = native.StencilWriteMask;
43 m_FrontFace = DepthStencilOperationDescription( native.FrontFace );
44 m_BackFace = DepthStencilOperationDescription( native.BackFace );
47 D3D10_DEPTH_STENCIL_DESC DepthStencilStateDescription::CreateNativeVersion()
49 D3D10_DEPTH_STENCIL_DESC native;
50 native.DepthEnable = m_DepthEnable;
51 native.DepthWriteMask = static_cast<D3D10_DEPTH_WRITE_MASK>( m_DepthWriteMask );
52 native.DepthFunc = static_cast<D3D10_COMPARISON_FUNC>( m_DepthFunc );
53 native.StencilEnable = m_StencilEnable;
54 native.StencilReadMask = m_StencilReadMask;
55 native.StencilWriteMask = m_StencilWriteMask;
56 native.FrontFace = m_FrontFace.CreateNativeVersion();
57 native.BackFace = m_BackFace.CreateNativeVersion();
62 bool DepthStencilStateDescription::IsDepthEnabled::get()
67 void DepthStencilStateDescription::IsDepthEnabled::set( bool value )
69 m_DepthEnable = value;
72 Direct3D10::DepthWriteMask DepthStencilStateDescription::DepthWriteMask::get()
74 return m_DepthWriteMask;
77 void DepthStencilStateDescription::DepthWriteMask::set( Direct3D10::DepthWriteMask value )
79 m_DepthWriteMask = value;
82 Comparison DepthStencilStateDescription::DepthComparison::get()
87 void DepthStencilStateDescription::DepthComparison::set( Comparison value )
92 bool DepthStencilStateDescription::IsStencilEnabled::get()
94 return m_StencilEnable;
97 void DepthStencilStateDescription::IsStencilEnabled::set( bool value )
99 m_StencilEnable = value;
102 Byte DepthStencilStateDescription::StencilReadMask::get()
104 return m_StencilReadMask;
107 void DepthStencilStateDescription::StencilReadMask::set( Byte value )
109 m_StencilReadMask = value;
112 Byte DepthStencilStateDescription::StencilWriteMask::get()
114 return m_StencilWriteMask;
117 void DepthStencilStateDescription::StencilWriteMask::set( Byte value )
119 m_StencilWriteMask = value;
122 DepthStencilOperationDescription DepthStencilStateDescription::FrontFace::get()
127 void DepthStencilStateDescription::FrontFace::set( DepthStencilOperationDescription value )
132 DepthStencilOperationDescription DepthStencilStateDescription::BackFace::get()
137 void DepthStencilStateDescription::BackFace::set( DepthStencilOperationDescription value )
142 bool DepthStencilStateDescription::operator == ( DepthStencilStateDescription left, DepthStencilStateDescription right )
144 return DepthStencilStateDescription::Equals( left, right );
147 bool DepthStencilStateDescription::operator != ( DepthStencilStateDescription left, DepthStencilStateDescription right )
149 return !DepthStencilStateDescription::Equals( left, right );
152 int DepthStencilStateDescription::GetHashCode()
154 return m_DepthEnable.GetHashCode() + m_DepthWriteMask.GetHashCode() + m_DepthFunc.GetHashCode()
155 + m_StencilEnable.GetHashCode() + m_StencilReadMask.GetHashCode() + m_StencilWriteMask.GetHashCode()
156 + m_FrontFace.GetHashCode() + m_BackFace.GetHashCode();
159 bool DepthStencilStateDescription::Equals( Object^ value )
161 if( value == nullptr )
164 if( value->GetType() != GetType() )
167 return Equals( safe_cast<DepthStencilStateDescription>( value ) );
170 bool DepthStencilStateDescription::Equals( DepthStencilStateDescription value )
172 return ( m_DepthEnable == value.m_DepthEnable && m_DepthWriteMask == value.m_DepthWriteMask && m_DepthFunc == value.m_DepthFunc
173 && m_StencilEnable == value.m_StencilEnable && m_StencilReadMask == value.m_StencilReadMask && m_StencilWriteMask == value.m_StencilWriteMask
174 && m_FrontFace == value.m_FrontFace && m_BackFace == value.m_BackFace );
177 bool DepthStencilStateDescription::Equals( DepthStencilStateDescription% value1, DepthStencilStateDescription% value2 )
179 return ( value1.m_DepthEnable == value2.m_DepthEnable && value1.m_DepthWriteMask == value2.m_DepthWriteMask && value1.m_DepthFunc == value2.m_DepthFunc
180 && value1.m_StencilEnable == value2.m_StencilEnable && value1.m_StencilReadMask == value2.m_StencilReadMask && value1.m_StencilWriteMask == value2.m_StencilWriteMask
181 && value1.m_FrontFace == value2.m_FrontFace && value1.m_BackFace == value2.m_BackFace );