Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

RFC: A Perl module for DirectX

by kejohm (Hermit)
on Mar 17, 2010 at 01:17 UTC ( #829056=perlmeditation: print w/replies, xml ) Need Help??

Greetings fellow monks,

I was hoping I could get some feedback on a module I am creating. It's a Perl interface to DirectX.

I have been working on it for a while now and so far it has been promising. I already have a fairly solid interface built for Direct3D, DirectInput, and DirectSound, although it still needs a lot of work.

So far, the interface is only a thin wrapper around the DirectX methods. In time, I hope to create an interface that is much simpler to use, especially for those who would like to use the module, but have little to no experience with DirectX.

I have been able to integrate it quite well with the Win32::GUI module. This makes the task of creating windows for a DirectX application quite simple.

I hope to eventually have support for as many DirectX components as I can, including older ones.

Any thoughts on the subject would be appreciated, especially from anyone out there who has experience using DirectX.



Replies are listed 'Best First'.
Re: RFC: A Perl module for DirectX
by Corion (Pope) on Mar 17, 2010 at 08:22 UTC

    One thing I really like about OpenGL is the GLUT library, which makes it fairly trivial to bring up a window and have (keyboard) interaction with the program. Providing something similar would make it really easy to jumpstart an application to test the application. In the long run, both, GLUT and your event loop will likely become a roadblock, but you have to reach such a roadblock first.

    The other recommendations are with regard to distribution:

    • Make sure that your libraries can dynamically link to as many versions of DirectX as possible, at least to DirectX 9 (Windows XP) and DirectX 10 (Windows Vista onwards?)
    • Provide a mostly automatic install by including all external dependencies directly or by providing a Alien:: package that will download and install the prerequisites. I don't think you'll need to distribute the DirectX Runtime though, but the less hoops a (proficient Perl) user has to jump through to try out your module the better.
Re: RFC: A Perl module for DirectX
by jdrago999 (Pilgrim) on Mar 18, 2010 at 19:04 UTC

    I don't have any experience with DirectX, but I really like your idea. Please go full-steam-ahead and make the module!

    "So far, the interface is only a thin wrapper around the DirectX methods. In time, I hope to create an interface that is much simpler to use, especially for those who would like to use the module, but have little to no experience with DirectX."

    I do have some advice here: Just make the thin interface for now. Consider the "simpler interface" an optimization - and we all know...

    Premature Optimization is the Root of All Evil

    So stick with the thin wrapper - if nothing else, the methods in your wrapper will be mostly familiar to anyone with previous experience using "normal" DirectX. As a side-benefit, if you don't wander too far away from the original interface then users of your module can also reflect on documentation from the original DirectX interface (maybe).

    If the "thin wrapper" approach you take becomes popular then expect others to write some more Perlish wrappers around your module - in specific ways that you may not have thought of.

    So the moral, I suppose is:

    Keep It Simple, Smartypants

    Leave the optimization for later (or someone else).

Re: RFC: A Perl module for DirectX
by BrowserUk (Pope) on Mar 18, 2010 at 19:20 UTC

    If you'd like some of us to exercise what you've got so far, make it available somewhere. I'd have a play.

Re: RFC: A Perl module for DirectX
by kejohm (Hermit) on Mar 19, 2010 at 04:47 UTC


    Thanks for the comments so far. I really appreciate the input.


    Regarding your comments about GLUT, some of the more recent DirectX SDKs contain a library called DXUT, which is used to build a lot of the samples that are included. The library includes code to build windows and controls, cameras, shapes, etc. and supports both Direct3D 9 and Direct3D 10. It is quite similar to GLUT.

    Technically, it isn't a DirectX component, so the libraries have to built from source. Hopefully I can get it to work. Otherwise, I could try creating a pure Perl version of my own, although that would probably be best left for later.

    Also, regarding your comment on installation, I have been working on modifying the so that it goes looking for the required headers and libraries, and even skip components if it can't find all the files. Unfortunately, all the required files are packaged up in the DirectX SDK, which at a few hundred megabytes, is something I can't really distribute with the module, or by using an Alien:: package. The best I could do is to get people to download the SDK themselves.


    You're right, it's probably best to just stick with the 'thin' interface for now, although if I can get DXUT working, I might not need to bother with my own.


    Thanks for the offer, although probably not just yet, the module isn't quite ready for testing. Stay tuned. I will definitely need people to test the module before I release it. Any ideas on where I could make it available? (I could just email it directly to anyone who wants to test the module)

    Thanks again,


      Having looked at the size of the SDK 500MB compressed, and the non-uninstallable nature of the 100MB "redistributable", unless you can make this a binary distribution, I doubt that you'll get many users. Hell. Even the EULA is 135k.

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
Re: RFC: A Perl module for DirectX
by kejohm (Hermit) on Apr 21, 2010 at 07:16 UTC

    Hi monks,

    My module has reached a point where I think it is time to let people test what I have done so far and get some feedback. It is a long way from finished, but I would like to get people's thoughts on the module so far. At this point, the documentation for the module is minimal, so it's probably best to just read the documentation that comes with the DirectX SDK, which you will need to install anyway to use the module. Remember that this is a work in progress, so there are portions that I haven't completed yet or don't quite work properly. This being my first foray into the world of developing a software project, I also wouldn't mind feedback on the module code itself, style, layout, etc. Also, does anyone have any suggestions for tools that could be useful for developing/maintaining a software project?

    While creating this module, I used the March 2009 DirectX SDK installed on Windows XP with ActiveState Perl 5.10.0 Build 1002. If you can't get the module to work using a different setup, please let me know. I would like to try and get this module to work with as many different setups as possible. In theory, as long as the SDK or OS isn't too out of date, it should work fine. I have set the minimum required level of Perl to 5.8.9, although it probably works with previous versions. If anyone has any advice on Perl backwards-compatibility, I wouldn't mind hearing it.

    I was thinking the best way to distribute my module for testing would be for people to send me a private message with their email address and I can send it to them directly. If anyone thinks of an alternative method, please let me know.



      Maybe I missed something, but you haven't said where it can be obtained? Or what it is called?

        My module is called Win32::DirectX.

        I haven't uploaded it anywhere yet, but I will eventually create a project on SourceForge, as well as upload it to CPAN. To begin with, though, I will send a copy for testing to anyone who sends me a private message with their email address. This just seemed the easiest way to make the module available for testing, to begin with at least.

Re: RFC: A Perl module for DirectX
by kejohm (Hermit) on Apr 24, 2010 at 13:22 UTC

    Just letting everyone know that I have now created a project on SourceForge for Win32::DirectX, here. I have uploaded my first alpha release for people to have a play with. Since I haven't got the project page completely up and running yet, if you wish to provide feedback, or are having problems, either send me an email (my address is in the README) or post here on PerlMonks. Posting here may be preferable, if you wish to discuss with other people.

    Update: Link fixed.

      Hi kejohm

      I just searched for perl + DirectX and landed in your sourceforge project. Excellent, I really like this idea. In order to play around, Can you please make a binary release also (Either PPM / pre built module)? This would enable many folks to easily play around and give comments on this module.

      Thanks & Regards,
      Bakkiaraj M
      My Perl Gtk2 technology demo project - , contributions are welcome.

        Thanks for the feedback. I have been quite busy as of late, and haven't gotten around to releasing a new version, but I hope to release one soon, and will look into releasing PPMs. As a starting point, which Perl version(s) would you require?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://829056]
Approved by desemondo
Front-paged by Arunbear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2019-10-19 02:54 GMT
Find Nodes?
    Voting Booth?