Skip to main content
GameDev.net gamedev.net

PRO Tired of ads? Read GameDev.net ad-free and help keep the community independent with GameDev Pro — $3/month.

First Steps - Managed DirectX

First Steps - Managed DirectX

dwarfsoft
dwarfsoft
PowerShell Games · · 1 min read
4,556 0
I know that Managed DirectX is old, unsupported, and unfortunately only 32-bit code. It doesn't matter. It's a good place to start for the simple reason that it's most likely already installed on the machine...

So, what do we do first? First we fire up PowerShell in x86 mode. There should be a "Windows PowerShell (x86)" link available in the start menu. Then we can run the following:
#First get the folder that contains DirectX$dir = (gci (Split-Path ( Split-Path ([Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory()) )) | ? {$_.Name -cmatch 'DirectX'}).FullName#Then find the DirectDraw Assembly$assm = ls $dir -Filter *DirectX*DirectDraw.dll -r|select -ExpandProperty FullName#Load the Assembly[void][reflection.assembly]::LoadFile($assm)#Now Create a DirectDraw device$d = new-object Microsoft.DirectX.DirectDraw.Device
From here our device $d allows us to interact with the video card retrieving information:

[font='courier new']PS C:\Users\dwarfsoft> $d.DeviceInformation[/font]

[font='courier new']DeviceGuid : d7b78e66-4266-11cf-1a74-e301a6c2cd35[/font]
[font='courier new']Description : Intel(R) HD Graphics Family[/font]
[font='courier new']Driver : aticfx32.dll[/font]
[font='courier new']WhqlLevel : 1[/font]
[font='courier new']Revision : 9[/font]
[font='courier new']SubSystemId : 568530858[/font]
[font='courier new']DeviceId : 294[/font]
[font='courier new']VendorId : 32902[/font]
[font='courier new']DriverVersion : 0[/font]

[font='courier new']PS C:\Users\dwarfsoft> $d.DisplayMode|Select Height,Width,RefreshRate|fl[/font]

[font='courier new']Height : 768[/font]
[font='courier new']Width : 1366[/font]
[font='courier new']RefreshRate : 60[/font]


Now that we can interact with objects using the Assemblies, the next step is to actually display something on screen.

Cheers, Chris.

Discussion

Loading comments...