OSDN Git Service

#36897 [DTXC] MIDIインポート機能の呼び出し口を、ファイルメニュー内にも配置。
[dtxmania/dtxmania.git] / SlimDXc_Jun2010(VC++2008) / source / direct3d9 / Direct3DEx.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 "../ComObject.h"\r
27 #include "../Utilities.h"\r
28 \r
29 #include "Direct3D9Exception.h"\r
30 #include "Direct3D9NotFoundException.h"\r
31 #include "Direct3DX9NotFoundException.h"\r
32 \r
33 #include "Enums.h"\r
34 \r
35 #include "Direct3DEx.h"\r
36 \r
37 using namespace System;\r
38 using namespace System::Collections::Generic;\r
39 \r
40 namespace SlimDX\r
41 {\r
42 namespace Direct3D9\r
43 {\r
44         Direct3DEx::Direct3DEx()\r
45                 : Direct3D( true )\r
46         {\r
47                 HRESULT hr;\r
48                 IDirect3D9Ex *direct3D = NULL;\r
49 \r
50         try\r
51         {\r
52                     hr = Direct3DCreate9Ex( D3D_SDK_VERSION, &direct3D );\r
53         }\r
54         catch( System::Runtime::InteropServices::SEHException^ ex )\r
55         {\r
56             throw gcnew Direct3D9NotFoundException( "Direct3D 9 was not found. Reinstalling DirectX may fix the problem.", ex );\r
57         }\r
58 \r
59                 if( RECORD_D3D9( hr ).IsFailure )\r
60                         throw gcnew Direct3D9Exception( Result::Last );\r
61 \r
62                 if( direct3D == NULL )\r
63                         throw gcnew Direct3D9Exception( "Could not create Direct3DEx instance." );\r
64 \r
65                 Adapters = gcnew AdapterCollection( direct3D, false );\r
66                 adaptersEx = gcnew AdapterExCollection( direct3D, false );\r
67 \r
68         try\r
69         {\r
70             D3DXCheckVersion( D3D_SDK_VERSION, D3DX_SDK_VERSION );\r
71         }\r
72         catch( System::Runtime::InteropServices::SEHException^ ex )\r
73         {\r
74             throw gcnew Direct3DX9NotFoundException( "Direct3DX 9 was not found. Please install "\r
75                 "the latest DirectX end-user redistributable package from Microsoft.", ex );\r
76         }\r
77 \r
78                 Construct( direct3D );\r
79         }\r
80         \r
81         Direct3DEx::Direct3DEx( IDirect3D9Ex* direct3d, ComObject^ owner )\r
82                 : Direct3D( true )\r
83         {\r
84                 Construct( direct3d, owner );\r
85         }\r
86 \r
87         Direct3DEx::Direct3DEx( IntPtr pointer )\r
88                 : Direct3D( true )\r
89         {\r
90                 Construct( pointer, NativeInterface );\r
91         }\r
92         \r
93         Direct3DEx^ Direct3DEx::FromPointer( IDirect3D9Ex* pointer, ComObject^ owner, ComObjectFlags flags ) \r
94         {\r
95                 return ComObject::ConstructFromPointer<Direct3DEx,IDirect3D9Ex>( pointer, owner, flags );\r
96         }\r
97         \r
98         Direct3DEx^ Direct3DEx::FromPointer( IntPtr pointer )\r
99         {\r
100                 return ComObject::ConstructFromUserPointer<Direct3DEx>( pointer );\r
101         }\r
102         \r
103     DisplayModeEx Direct3DEx::GetAdapterDisplayModeEx( int adapter )\r
104         {\r
105                 D3DDISPLAYMODEEX nativeMode = {0};\r
106                 nativeMode.Size = sizeof(D3DDISPLAYMODEEX);\r
107                 HRESULT hr = InternalPointer->GetAdapterDisplayModeEx( adapter, &nativeMode, NULL );\r
108                 RECORD_D3D9( hr );\r
109 \r
110                 DisplayModeEx mode = DisplayModeEx::FromUnmanaged( nativeMode );\r
111                 return mode;\r
112         }\r
113 \r
114     DisplayModeEx Direct3DEx::GetAdapterDisplayModeEx( int adapter, [Out] DisplayRotation% rotation )\r
115         {\r
116                 D3DDISPLAYMODEEX nativeMode = {0};\r
117                 nativeMode.Size = sizeof(D3DDISPLAYMODEEX);\r
118                 D3DDISPLAYROTATION nativeRotation = D3DDISPLAYROTATION_IDENTITY;\r
119                 HRESULT hr = InternalPointer->GetAdapterDisplayModeEx( adapter, &nativeMode, &nativeRotation );\r
120                 RECORD_D3D9( hr );\r
121 \r
122                 DisplayModeEx mode = DisplayModeEx::FromUnmanaged( nativeMode );\r
123                 rotation = static_cast<DisplayRotation>( nativeRotation );\r
124 \r
125                 return mode;\r
126         }\r
127 \r
128         System::Int64 Direct3DEx::GetAdapterLuid( int adapter )\r
129         {\r
130                 Int64 luid = 0;\r
131                 InternalPointer->GetAdapterLUID( adapter, reinterpret_cast<LUID*>( &luid ) );\r
132                 return luid;\r
133         }\r
134 \r
135     int Direct3DEx::GetAdapterModeCountEx( int adapter, DisplayModeFilter filter )\r
136         {\r
137                 D3DDISPLAYMODEFILTER nativeFilter;\r
138                 filter.ToUnmanaged( nativeFilter );\r
139 \r
140                 return InternalPointer->GetAdapterModeCountEx( adapter, &nativeFilter );\r
141         }\r
142 \r
143     DisplayModeEx Direct3DEx::EnumerateAdapterModesEx( int adapter, DisplayModeFilter filter, int modeIndex )\r
144         {\r
145                 D3DDISPLAYMODEEX nativeMode = {0};\r
146                 nativeMode.Size = sizeof(D3DDISPLAYMODEEX);\r
147                 D3DDISPLAYMODEFILTER nativeFilter;\r
148                 filter.ToUnmanaged( nativeFilter );\r
149 \r
150                 HRESULT hr = InternalPointer->EnumAdapterModesEx( adapter, &nativeFilter, modeIndex, &nativeMode );\r
151                 RECORD_D3D9( hr );\r
152 \r
153                 DisplayModeEx mode = mode.FromUnmanaged( nativeMode );\r
154                 return mode;\r
155         }\r
156 }\r
157 }\r