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 "../ComObject.h"
\r
27 #include "../Utilities.h"
\r
29 #include "Direct3D9Exception.h"
\r
30 #include "Direct3D9NotFoundException.h"
\r
31 #include "Direct3DX9NotFoundException.h"
\r
35 #include "Direct3DEx.h"
\r
37 using namespace System;
\r
38 using namespace System::Collections::Generic;
\r
44 Direct3DEx::Direct3DEx()
\r
48 IDirect3D9Ex *direct3D = NULL;
\r
52 hr = Direct3DCreate9Ex( D3D_SDK_VERSION, &direct3D );
\r
54 catch( System::Runtime::InteropServices::SEHException^ ex )
\r
56 throw gcnew Direct3D9NotFoundException( "Direct3D 9 was not found. Reinstalling DirectX may fix the problem.", ex );
\r
59 if( RECORD_D3D9( hr ).IsFailure )
\r
60 throw gcnew Direct3D9Exception( Result::Last );
\r
62 if( direct3D == NULL )
\r
63 throw gcnew Direct3D9Exception( "Could not create Direct3DEx instance." );
\r
65 Adapters = gcnew AdapterCollection( direct3D, false );
\r
66 adaptersEx = gcnew AdapterExCollection( direct3D, false );
\r
70 D3DXCheckVersion( D3D_SDK_VERSION, D3DX_SDK_VERSION );
\r
72 catch( System::Runtime::InteropServices::SEHException^ ex )
\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
78 Construct( direct3D );
\r
81 Direct3DEx::Direct3DEx( IDirect3D9Ex* direct3d, ComObject^ owner )
\r
84 Construct( direct3d, owner );
\r
87 Direct3DEx::Direct3DEx( IntPtr pointer )
\r
90 Construct( pointer, NativeInterface );
\r
93 Direct3DEx^ Direct3DEx::FromPointer( IDirect3D9Ex* pointer, ComObject^ owner, ComObjectFlags flags )
\r
95 return ComObject::ConstructFromPointer<Direct3DEx,IDirect3D9Ex>( pointer, owner, flags );
\r
98 Direct3DEx^ Direct3DEx::FromPointer( IntPtr pointer )
\r
100 return ComObject::ConstructFromUserPointer<Direct3DEx>( pointer );
\r
103 DisplayModeEx Direct3DEx::GetAdapterDisplayModeEx( int adapter )
\r
105 D3DDISPLAYMODEEX nativeMode = {0};
\r
106 nativeMode.Size = sizeof(D3DDISPLAYMODEEX);
\r
107 HRESULT hr = InternalPointer->GetAdapterDisplayModeEx( adapter, &nativeMode, NULL );
\r
110 DisplayModeEx mode = DisplayModeEx::FromUnmanaged( nativeMode );
\r
114 DisplayModeEx Direct3DEx::GetAdapterDisplayModeEx( int adapter, [Out] DisplayRotation% rotation )
\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
122 DisplayModeEx mode = DisplayModeEx::FromUnmanaged( nativeMode );
\r
123 rotation = static_cast<DisplayRotation>( nativeRotation );
\r
128 System::Int64 Direct3DEx::GetAdapterLuid( int adapter )
\r
131 InternalPointer->GetAdapterLUID( adapter, reinterpret_cast<LUID*>( &luid ) );
\r
135 int Direct3DEx::GetAdapterModeCountEx( int adapter, DisplayModeFilter filter )
\r
137 D3DDISPLAYMODEFILTER nativeFilter;
\r
138 filter.ToUnmanaged( nativeFilter );
\r
140 return InternalPointer->GetAdapterModeCountEx( adapter, &nativeFilter );
\r
143 DisplayModeEx Direct3DEx::EnumerateAdapterModesEx( int adapter, DisplayModeFilter filter, int modeIndex )
\r
145 D3DDISPLAYMODEEX nativeMode = {0};
\r
146 nativeMode.Size = sizeof(D3DDISPLAYMODEEX);
\r
147 D3DDISPLAYMODEFILTER nativeFilter;
\r
148 filter.ToUnmanaged( nativeFilter );
\r
150 HRESULT hr = InternalPointer->EnumAdapterModesEx( adapter, &nativeFilter, modeIndex, &nativeMode );
\r
153 DisplayModeEx mode = mode.FromUnmanaged( nativeMode );
\r