Advertisement Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

About this blog

Writing PowerShell Games

Entries in this blog


First Steps - Managed DirectX

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.




Why PowerShell?

Why is a good question to ask. Why use PowerShell for game development?

The only answer I have is: Why not.

I spend every day of my working life buried neck deep in PowerShell, so it is the language I am most comfortable using. I have experience using it for things it really shouldn't be used for (PowerShell wrapping a C# interface to .Net calling Unmanaged system drivers for example). Mainly, PowerShell is not well understood for its more complex tasks. In theory, anything that .Net can do, PowerShell can do, and I'd like to explore the limits of what I can achieve with this peculiar toolset.

My ambitions extend to DirectX integration using PowerShell... Simply because I think I can. In the process I hope to build client/server networking system, all within this shell scripting language.

I hope you enjoy it as much as I do.

Cheers, Chris.



Sign in to follow this  
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!