First Steps - Managed DirectX

posted in PowerShell Games
Published November 06, 2014
Advertisement
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.
Previous Entry Why PowerShell?
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Why PowerShell?

2495 views

LOL

1391 views

LOL

1305 views

Untitled

1284 views

Exhaustion

1593 views

BANG! Accounting!

1597 views

BANG! Statistics!

1160 views
Advertisement