OSDN Git Service

#36897 [DTXC] MIDIインポート機能の呼び出し口を、ファイルメニュー内にも配置。
[dtxmania/dtxmania.git] / SlimDXc_Jun2010(VC++2008) / source / dxgi / Factory1.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 \r
24 #include "DXGIException.h"\r
25 \r
26 #include "Factory1.h"\r
27 #include "Adapter1.h"\r
28 \r
29 using namespace System;\r
30 \r
31 namespace SlimDX\r
32 {\r
33 namespace DXGI\r
34 {\r
35         Factory1::Factory1( IDXGIFactory1* pointer, ComObject^ owner )\r
36                 : Factory( true )\r
37         {\r
38                 Construct( pointer, owner );\r
39         }\r
40         \r
41         Factory1::Factory1( IntPtr pointer )\r
42                 : Factory( true )\r
43         {\r
44                 Construct( pointer, NativeInterface );\r
45         }\r
46         \r
47         Factory1^ Factory1::FromPointer( IDXGIFactory1* pointer, ComObject^ owner, ComObjectFlags flags )\r
48         {\r
49                 return ComObject::ConstructFromPointer<Factory1, IDXGIFactory1>( pointer, owner, flags );\r
50         }\r
51         \r
52         Factory1^ Factory1::FromPointer( IntPtr pointer )\r
53         {\r
54                 return ComObject::ConstructFromUserPointer<Factory1>( pointer );\r
55         }\r
56 \r
57         Factory1::Factory1()\r
58                 : Factory(true)\r
59         {\r
60                 IDXGIFactory1* factory = 0;\r
61                 RECORD_DXGI( CreateDXGIFactory1( __uuidof( IDXGIFactory1 ), reinterpret_cast<void**>( &factory ) ) );\r
62                 if( Result::Last.IsFailure )\r
63                         throw gcnew DXGIException( Result::Last );\r
64 \r
65                 Construct( factory );\r
66         }\r
67 \r
68         int Factory1::GetAdapterCount1()\r
69         {\r
70                 int count = 0;\r
71                 IDXGIAdapter1* adapter = 0;\r
72                 while( InternalPointer->EnumAdapters1( count, &adapter ) != DXGI_ERROR_NOT_FOUND )\r
73                 {\r
74                         adapter->Release();\r
75                         ++count;\r
76                 }\r
77 \r
78                 return count;\r
79         }\r
80 \r
81         Adapter1^ Factory1::GetAdapter1(int index)\r
82         {\r
83                 IDXGIAdapter1* adapter = 0;\r
84                 RECORD_DXGI( InternalPointer->EnumAdapters1( index, &adapter) );\r
85                 if( Result::Last.IsFailure )\r
86                         return nullptr;\r
87 \r
88                 return Adapter1::FromPointer( adapter, this );\r
89         }\r
90 \r
91         bool Factory1::IsCurrent::get()\r
92         {\r
93                 return InternalPointer->IsCurrent() == TRUE;\r
94         }\r
95 }\r
96 }\r