3 * Copyright (c) 2007-2010 SlimDX Group
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
6 * of this software and associated documentation files (the "Software"), to deal
\r
7 * in the Software without restriction, including without limitation the rights
\r
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
9 * copies of the Software, and to permit persons to whom the Software is
\r
10 * furnished to do so, subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in
\r
13 * all copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
26 #include "PresentParameters.h"
\r
28 using namespace System;
\r
34 D3DPRESENT_PARAMETERS PresentParameters::ToUnmanaged()
\r
36 D3DPRESENT_PARAMETERS d3dpp;
\r
38 d3dpp.AutoDepthStencilFormat = static_cast<D3DFORMAT>( AutoDepthStencilFormat );
\r
39 d3dpp.BackBufferCount = BackBufferCount;
\r
40 d3dpp.BackBufferFormat = static_cast<D3DFORMAT>( BackBufferFormat );
\r
41 d3dpp.BackBufferHeight = BackBufferHeight;
\r
42 d3dpp.BackBufferWidth = BackBufferWidth;
\r
43 d3dpp.EnableAutoDepthStencil = EnableAutoDepthStencil;
\r
44 d3dpp.Flags = static_cast<DWORD>( PresentFlags );
\r
45 d3dpp.FullScreen_RefreshRateInHz = FullScreenRefreshRateInHertz;
\r
46 d3dpp.hDeviceWindow = static_cast<HWND>( DeviceWindowHandle.ToPointer() );
\r
47 d3dpp.MultiSampleQuality = MultisampleQuality;
\r
48 d3dpp.MultiSampleType = static_cast<D3DMULTISAMPLE_TYPE>( Multisample );
\r
49 d3dpp.PresentationInterval = static_cast<UINT>( PresentationInterval );
\r
50 d3dpp.SwapEffect = static_cast<D3DSWAPEFFECT>( SwapEffect );
\r
51 d3dpp.Windowed = Windowed;
\r
56 PresentParameters::PresentParameters( const D3DPRESENT_PARAMETERS& d3dpp )
\r
58 AutoDepthStencilFormat = static_cast<Format>( d3dpp.AutoDepthStencilFormat );
\r
59 BackBufferCount = d3dpp.BackBufferCount;
\r
60 BackBufferFormat = static_cast<Format>( d3dpp.BackBufferFormat );
\r
61 BackBufferHeight = d3dpp.BackBufferHeight;
\r
62 BackBufferWidth = d3dpp.BackBufferWidth;
\r
63 EnableAutoDepthStencil = d3dpp.EnableAutoDepthStencil == TRUE;
\r
64 PresentFlags = static_cast<SlimDX::Direct3D9::PresentFlags>( d3dpp.Flags );
\r
65 FullScreenRefreshRateInHertz = d3dpp.FullScreen_RefreshRateInHz;
\r
66 DeviceWindowHandle = IntPtr( d3dpp.hDeviceWindow );
\r
67 MultisampleQuality = d3dpp.MultiSampleQuality;
\r
68 Multisample = static_cast<MultisampleType>( d3dpp.MultiSampleType );
\r
69 PresentationInterval = static_cast<PresentInterval>( d3dpp.PresentationInterval );
\r
70 SwapEffect = static_cast<SlimDX::Direct3D9::SwapEffect>( d3dpp.SwapEffect );
\r
71 Windowed = d3dpp.Windowed == TRUE;
\r
74 PresentParameters::PresentParameters()
\r
76 BackBufferWidth = 640;
\r
77 BackBufferHeight = 480;
\r
78 BackBufferFormat = Format::X8R8G8B8;
\r
79 BackBufferCount = 1;
\r
81 Multisample = MultisampleType::None;
\r
83 SwapEffect = SlimDX::Direct3D9::SwapEffect::Discard;
\r
84 DeviceWindowHandle = IntPtr::Zero;
\r
86 EnableAutoDepthStencil = true;
\r
87 AutoDepthStencilFormat = Format::D24X8;
\r
88 PresentFlags = SlimDX::Direct3D9::PresentFlags::None;
\r
90 PresentationInterval = PresentInterval::Immediate;
\r
93 PresentParameters^ PresentParameters::Clone()
\r
95 PresentParameters^ result = gcnew PresentParameters();
\r
97 result->BackBufferWidth = BackBufferWidth;
\r
98 result->BackBufferHeight = BackBufferHeight;
\r
99 result->BackBufferFormat = BackBufferFormat;
\r
100 result->BackBufferCount = BackBufferCount;
\r
102 result->Multisample = Multisample;
\r
103 result->MultisampleQuality = MultisampleQuality;
\r
105 result->SwapEffect = SwapEffect;
\r
106 result->DeviceWindowHandle = DeviceWindowHandle;
\r
107 result->Windowed = Windowed;
\r
108 result->EnableAutoDepthStencil = EnableAutoDepthStencil;
\r
109 result->AutoDepthStencilFormat = AutoDepthStencilFormat;
\r
110 result->PresentFlags = PresentFlags;
\r
112 result->FullScreenRefreshRateInHertz = FullScreenRefreshRateInHertz;
\r
113 result->PresentationInterval = PresentationInterval;
\r
118 bool PresentParameters::operator == ( PresentParameters^ left, PresentParameters^ right )
\r
120 if( ReferenceEquals( left, nullptr ) )
\r
121 return ReferenceEquals( right, nullptr );
\r
123 return PresentParameters::Equals( left, right );
\r
126 bool PresentParameters::operator != ( PresentParameters^ left, PresentParameters^ right )
\r
128 return !( left == right );
\r
131 int PresentParameters::GetHashCode()
\r
133 return BackBufferWidth.GetHashCode() + BackBufferHeight.GetHashCode() + BackBufferFormat.GetHashCode() +
\r
134 BackBufferCount.GetHashCode() + Multisample.GetHashCode() + MultisampleQuality.GetHashCode() +
\r
135 SwapEffect.GetHashCode() + DeviceWindowHandle.GetHashCode() + Windowed.GetHashCode() +
\r
136 EnableAutoDepthStencil.GetHashCode() + AutoDepthStencilFormat.GetHashCode() + PresentFlags.GetHashCode() +
\r
137 FullScreenRefreshRateInHertz.GetHashCode() + PresentationInterval.GetHashCode();
\r
140 bool PresentParameters::Equals( Object^ value )
\r
142 if( value == nullptr )
\r
145 if( value->GetType() != GetType() )
\r
148 return Equals( safe_cast<PresentParameters^>( value ) );
\r
151 bool PresentParameters::Equals( PresentParameters^ value )
\r
153 if( value == nullptr )
\r
156 if( ReferenceEquals( this, value ) )
\r
159 return ( value->BackBufferWidth == BackBufferWidth && value->BackBufferHeight == BackBufferHeight && value->BackBufferFormat == BackBufferFormat &&
\r
160 value->BackBufferCount == BackBufferCount && value->Multisample == Multisample && value->MultisampleQuality == MultisampleQuality &&
\r
161 value->SwapEffect == SwapEffect && value->DeviceWindowHandle == DeviceWindowHandle && value->Windowed == Windowed &&
\r
162 value->EnableAutoDepthStencil == EnableAutoDepthStencil && value->AutoDepthStencilFormat == AutoDepthStencilFormat && value->PresentFlags == PresentFlags &&
\r
163 value->FullScreenRefreshRateInHertz == FullScreenRefreshRateInHertz && value->PresentationInterval == PresentationInterval );
\r
166 bool PresentParameters::Equals( PresentParameters^ value1, PresentParameters^ value2 )
\r
168 return value1->Equals( value2 );
\r