OSDN Git Service

フォーラム[#56172] SlimDX(改)のフォルダ内容が不完全だったので再UP。
[dtxmania/dtxmania.git] / SlimDXc_Jun2010(VC++2008) / source / direct3d9 / PresentParameters.cpp
1 #include "stdafx.h"\r
2 /*\r
3 * Copyright (c) 2007-2010 SlimDX Group\r
4\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
11\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
14\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
21 * THE SOFTWARE.\r
22 */\r
23 #include <d3d9.h>\r
24 #include <d3dx9.h>\r
25 \r
26 #include "PresentParameters.h"\r
27 \r
28 using namespace System;\r
29 \r
30 namespace SlimDX\r
31 {\r
32 namespace Direct3D9\r
33 {\r
34         D3DPRESENT_PARAMETERS PresentParameters::ToUnmanaged()\r
35         {\r
36                 D3DPRESENT_PARAMETERS d3dpp;\r
37 \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
52 \r
53                 return d3dpp;\r
54         }\r
55 \r
56         PresentParameters::PresentParameters( const D3DPRESENT_PARAMETERS& d3dpp )\r
57         {\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
72         }\r
73 \r
74         PresentParameters::PresentParameters()\r
75         {\r
76                 BackBufferWidth = 640;\r
77                 BackBufferHeight = 480;\r
78                 BackBufferFormat = Format::X8R8G8B8;\r
79                 BackBufferCount = 1;\r
80 \r
81                 Multisample = MultisampleType::None;\r
82 \r
83                 SwapEffect = SlimDX::Direct3D9::SwapEffect::Discard;\r
84                 DeviceWindowHandle = IntPtr::Zero;\r
85                 Windowed = true;\r
86                 EnableAutoDepthStencil = true;\r
87                 AutoDepthStencilFormat = Format::D24X8;\r
88                 PresentFlags = SlimDX::Direct3D9::PresentFlags::None;\r
89 \r
90                 PresentationInterval = PresentInterval::Immediate;\r
91         }\r
92 \r
93         PresentParameters^ PresentParameters::Clone()\r
94         {\r
95                 PresentParameters^ result = gcnew PresentParameters();\r
96 \r
97                 result->BackBufferWidth = BackBufferWidth;\r
98                 result->BackBufferHeight = BackBufferHeight;\r
99                 result->BackBufferFormat = BackBufferFormat;\r
100                 result->BackBufferCount = BackBufferCount;\r
101 \r
102                 result->Multisample = Multisample;\r
103                 result->MultisampleQuality = MultisampleQuality;\r
104 \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
111 \r
112                 result->FullScreenRefreshRateInHertz = FullScreenRefreshRateInHertz;\r
113                 result->PresentationInterval = PresentationInterval;\r
114 \r
115                 return result;\r
116         }\r
117 \r
118         bool PresentParameters::operator == ( PresentParameters^ left, PresentParameters^ right )\r
119         {\r
120                 if( ReferenceEquals( left, nullptr ) )\r
121                         return ReferenceEquals( right, nullptr );\r
122 \r
123                 return PresentParameters::Equals( left, right );\r
124         }\r
125 \r
126         bool PresentParameters::operator != ( PresentParameters^ left, PresentParameters^ right )\r
127         {\r
128                 return !( left == right );\r
129         }\r
130 \r
131         int PresentParameters::GetHashCode()\r
132         {               \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
138         }\r
139 \r
140         bool PresentParameters::Equals( Object^ value )\r
141         {\r
142                 if( value == nullptr )\r
143                         return false;\r
144 \r
145                 if( value->GetType() != GetType() )\r
146                         return false;\r
147 \r
148                 return Equals( safe_cast<PresentParameters^>( value ) );\r
149         }\r
150 \r
151         bool PresentParameters::Equals( PresentParameters^ value )\r
152         {\r
153                 if( value == nullptr )\r
154                         return false;\r
155 \r
156                 if( ReferenceEquals( this, value ) )\r
157                         return true;\r
158 \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
164         }\r
165 \r
166         bool PresentParameters::Equals( PresentParameters^ value1, PresentParameters^ value2 )\r
167         {\r
168                 return value1->Equals( value2 );\r
169         }\r
170 }\r
171 }