A cornucopia of topics!

It’s been a while since I’ve written anything here, but a few other posts today have gotten me to change that now.  First David Weller tries answering the question “Does Managed DirectX discriminate against VB.NET Developers”..  Since he put me on the spot to answer it, i’ll do that first.

In short, no, of course not.  He hits the nail on the head that it’s mainly about time, and given my busy schedule, it’s quite difficult to get the stuff out that I do end up releasing.  It’s also at least partially about maintenance.  Considering in the past when we had VB.NET and C# version of the samples, the VB.NET versions were simply mirrors of the C# version.  Which means not only do you need to ‘write’ two versions of the same code (3 if you count the original unmanaged version), whenever any one of them changes, all of them must be updated..  It can become quite a bit of work when the samples are changing daily.

I’d also disagree with David’s assertion that you can’t possibly master DX without knowing C++, but the fact is the *majority* of our customers (the game developers) do know c++, C# is a more logical language to use as the starting block for the managed samples.  We will have a VB.NET sample in this upcoming release though.  Oh, and the original post that David quotes is using a bug that shipped in the summer 2004 release as the reason for the discrimination question..  It is just that, a bug.  One that has now been fixed and will be released soon.  We would *never* intentionally ‘break’ something out of spite or whatever the case may be.

So, to summarize, we have no intentional ‘discrimination’ against vb developers in the least.  In a perfect world, where I had infinite time, we would have thousands of samples, in all the languages available, but the fact is, it’s not a perfect world.  We’re trying to add new stuff (including VB samples) as we’re progressing.

David also mentioned Andy Dunn’s new web site on Managed DirectX.  It includes an interview with the lead developer on the first retail MDX game i posted about last time.  In his ‘disadvantages’ section, he lists a few problems he had with MDX, which were all based on the Summer 2003 version.  I believe that I addressed all of those in the latest version, but by all means, if people are seeing bugs and/or issues in the assemblies, please let me know.

Since i’m on a writing roll, let’s continue on to books..  The second book should be hitting store shelves ‘soon’ (it’s definitely already been sent to printing, i’m just not exactly sure when it’ll arrive on shelves).  However, the third book is a different story.  At this point in time, I simply do not have the time required to dedicate myself to writing that book.  I think it’s an important book that is written though, so I’m glad that one of my coworkers has picked up the project.  While it may be not be me writing the book or the code directly, I will be at least tangentally involved (he’s right down the hall from me after all).  The project has been left in good hands, and i’m excited to see the end result.

Oh, and unlike David, I haven’t found Half Life 2 to be all that great.  Sure, the graphics engine is *amazing*, but in reality, I’m so burnt out on first person shooters, I just get annoyed with the gameplay half the time..  I fully expect to get flamed for those last two sentences. =)  It would be hard to disagree with the statement on World of Warcraft though.  I find myself playing that way too often..  (Even though I was sad when they deleted my level 60 warlock from the closed beta)

The first Managed DirectX game..

To my knowledge, the first ‘retail’ game written in Managed DirectX has been released..  It’s called “Tin Soliders: Alexander the Great“, and you can read more about it here.  It seems to be a turned based strategy game.  I’ve never played it, I really don’t know anything about it, but I expect it to be the first of many games written entirely in managed code using Managed DirectX..

Oh, and if there are other ‘retail’ games written in MDX that I’m not aware of, sorry..  You should let me know!

Who would have thought road trips involved so much driving?

I guess I should have realized that since I did use Streets And Trips 2005 to actually plan the trip, but I’m here to tell you..  Reading about a 2-day 19 hour one way drive is a lot different than actually *doing* said drive.  That being said though, once you ignore all of the driving that was done, once we were actually in Vegas, then we had a great time.  It wasn’t our first trip onto the strip, but it was the first time I actually realized you could go up to the top of the Eifel tower they have there.  You get a great view, but boy was it windy..

Of course, while you’re there you’ve got to gamble.  Well, I suppose you don’t *have* to, but it’s something that I enjoy.  Naturally, I enjoy black jack since that’s one of the few games in the casino you could actually do well at, providing you know what you’re doing.  For me, it never fails..  I’ll get to some point where I’m actually winning, and ‘up’ a decent amount of money before I forget how I got to that point, and start changing my betting habits, dramatically increasing the amount of bets i’m placing.  Every trip down there, I spend a portion of time way up, just to give most (or all) of it back before I leave, and this trip was no different.  I suppose that’s better than losing money (which I’ve yet to do), but just once I’d like to see my winnings pay for the trip. 🙂

We weren’t there long enough to see many of the shows this year, but we’ve seen most of them already anyway.. A couple years ago, we saw Blue Man group @ Luxor, and IMHO, that is probably one of the best shows in Vegas..  Surprisingly enough, it wasn’t dramatically hot there this time either.  Sure, it was much hotter than it was here in the Seattle area, but it only broke 100 once, and was only ‘warm’ in the evenings..  A dramatic change from late August 2002, when it was regularly >115..

Even with my complaints on the driving, there were still some interesting things to look at.. Like a golf course in the desert.  The mountains you see in Arizona and Utah are much different that what we see here in our area as well.  I even saw a small tumbleweed blow by once..  It was straight out of a cartoon..  Oh, and one more minor thought about speed limits..  The speed limit around here in 60 around the ‘cities’, and 70 everywhere else.. Oregon was similar, except it seemed to be 60/65 instead of 60/70..  All of the other states we drove through were 65/75, and that extra 5mph makes a world of difference..  I remember back in the day, the speed limit was national (granted it was only 55mph)..  All of the changing speed limits were really annoying, particularly on the way back when i had to slow down as I got closer..  And don’t even get me started on road construction..

Anyway..  My next trip will definitely involve a plane..  Even with the added security headaches, it’s still easier than all that driving..

Road Trip!

Like Greg mentioned earlier this week, my birthday is rapidly approaching (oh, happy birthday to Greg too!), so since i rarely get to go on vacation, I decided to take a road trip..

I’ll be gone for about a week.. Will barely have access to a computer, won’t have access to email or anything..  Instead i’ll be in Las Vegas having quite the time..  What Fun!

Moving Day!!!

Hard to believe that in a little less than 20 hours I’ll be moved into our new house.  While the wait between signing the papers to have the house constructed (November of last year) until now has seemed to take eons upon eons to get here, in reality, it hasn’t been that long at all..  And now that the day has finally arrived, and my current house is virtually completely packed (aside from my computer of course), it’s definitely a lot harder to believe than I imagined it would be.

Look at it now!

Amazing how quickly these things happen.  Now, the fun of moving and unpacking begins.  Somehow I think these things will be much less exciting once the move is complete.

Now that the Whidbey Beta is out, what about Managed DirectX?

With the release of the Whidbey (err, I mean Visual Studio.NET 2005) beta a few weeks ago, my thoughts have drifted towards how Managed DirectX may work in this new release.  For those of you who haven’t seen VS2005, or the new CLR, the changes there are magnificent.  Across the board, improvements have been made, and the thing is looking wonderful.

So my thoughts roll over to MDX, and I think to myself, “Self: wouldn’t it be awesome if we took advantage of some of those features?”  Who wouldn’t want to declare the vertex data they’re about to use like:

VertexBuffer vb = null;
IndexBuffer ib = null;

Of course that just scratches the surface of the possibilities that would lie in a VS2005 specific version of Managed DirectX.  Which begs the question, what do you think?

Tampa Bay Lightning – Stanley Cup Champions..

As a sports fan, I’m what you might call a “bandwagon jumper” (a cardinal sin for a ‘true sports fan’ i’m told).  I have my favorite teams just like everyone else, but once they’ve lost, I have no problems with picking a new team to cheer for out of the remaining teams.  In my opinion, sports are purely for entertainment, so as long as i’m entertained, I’m a happy guy.  If ‘my team’ wins, so much the better..  For example, the St Louis Rams are ‘my team’ in football.  Back a few years ago when they won the superbowl, boy, that was awesome.  Two years later, when they *lost* the superbowl to the New England Patriots, that was still a great game.  I was entertained, I was happy.  Once the team I’m rooting for is gone, I promptly switch to the team I think will be the most entertaining to me.  Last year, when the Rams were eliminated from the playoffs by the Carolina Panthers the very next week I was cheering on the Panters to beat the Eagles (which they did)..  I’ve never understood that whole ‘loyalty’ thing with sports teams, but that’s just me.

Anyway, since I rarely watch sports (any sport) outside of the playoffs, it’s always exciting when I finally get around to seeing a game.  I don’t really think there is anything better in sports than a game 7, and a game 7 in the finals for the Stanley Cup.. Well, that is the *best* thing going.  The only thing possibly better is if it went into overtime.  There’s such a finality to it.  Given the last few minutes of the game tonight, I thought this one was going to overtime like the last two.  It would have been ‘poetic’ if it had. In my opinion, Khabibulin should have won the Conn Smythe award because without him, they never would have won this series.  They were way outplayed for long stretches, and he kept them in it.  Sure, the 10/16 points on game winning goals is an awesome stat, but really..

Oh, and i was rooting for the Flames.  After all was said and done though, it was a great game.  I was entertained, that’s all that matters.

Congratulations to the Tampa Bay Lightning. Stanley Cup Champions..  Now, will rooting for the Lakers work out? =)

Time flies when a house is being built..

While in reality it’s only been a few months since I first mentioned I was having a new house built, in my mind it’s been decades.  I’m quite anxious to move into the new place, and all the waiting around is agonizing to say the least.  Aside from the fact that I will be saving about an hour a day on my commute, there is something to be said for actually having the house built that *you* wanted.  Start with nothing, and then end up with a house.  It’s an interesting proposition.

Of course, then you have all of ‘Nothing’.  And you have this ‘nothing’ for what seems like a long time.

Then all of a sudden, you have a foundation down!

So you’d think that with something going on, you’d be happy..  Like, WOOHOO! Something’s going on!  But that’s not really what happens.. Instead you’re thinking “Man, what’s taking so long! Aren’t they done yet?!!“  Maybe that wouldn’t be so bad, but it’s only been 15 minutes since the foundation was down..

Next thing you know, they’re actually building a structure.

Then it becomes maddening.  You can phsyically see the thing there, and you still can’t do anything but wait..  It is quite awesome to see it coming together piece by piece (”Hey, if you imagine a wall right here, I’m gonna put my tv right there!”), and one of the ‘coolest’ experiences i’ve had, but there’s still two months left before it’s done and i’ll be able to move in.

I’m convinced these two months will take at least another 8 years to get here.

So you say that startup time is slow?

One of the first things that people may notice when they’re running managed applications is that the startup time is slower than a ‘native’ application.  Without delving into details, the major cause for this ‘slow down’ is the actual compilation that needs to happen (called JIT – Just in time compiling).  Since the managed code has to be compiled into native code before it’s executed, this is an expected delay when starting the application. Since Managed DirectX is built on top of this system, code you write using the Managed DirectX runtime will have this behavior as well.

Since the JIT compilation can do a lot of optimizations that just can’t be done during compile time (taking advantage of the actual machine the code is running on, rather than the machine it was compiled on, etc.) the behavior here is desired, the side effects (the slowdown) is not.  It would be great if there was a way to have this cost removed. Luckily for us, the .NET Framework includes a utility called NGen (Native Image Generator) which does exactly this.

This utility will natively compile an assembly and put the output into what is called the ‘Native Assembly Cache’, which resides within the ‘Global Assembly Cache’.  When the .NET Framework attempts to load an assembly, it will check to see if the native version of the assembly exists, and if so, load that instead of doing the JIT compilation at startup time, potentially dramatically decreasing the startup time of the application using these assemblies.   The downsides of using this utility are two-fold.  One, there’s no guarantee that the startup or execution time will be faster (although in most cases it will be – test to find out), and two the native image is very ‘fragile’.  There are a number of factors which cause the native images to be invalid (such as a new runtime installation, or security settings changes). Once the native image is invalid, it will still exist in the ‘Native Assembly Cache’, and never be used.  Plus, if you want to regain the benefits, you’ll need to ngen the assemblies once more, and unless you’re watching closely, you may not even notice that the original native assemblies are now invalid.

If you’ve decided you would still like to ngen your Managed DirectX assemblies, here are the steps you would take:

  • Open up a Visual Studio.NET 2003 Command Prompt Window
    • If you do not wish to open that command window, you could simply open up a normal command prompt window, and ensure the framework binary folder is in your path.  The framework binary folder should be located at %windir%microsoft.netframeworkv1.1.4322 where %windir% is your windows folder.
  • Change the directory to %windir%microsoft.netManaged DirectX, where %windir% is your windows folder.
  • Go into the folder for the version of Managed DirectX you wish to ngen from here (the later the version, the more recent the assembly).
  • Run the following command line for each of the assemblies in the folder:
    • ngen microsoft.directx.dll (etc)
    • If you’re command prompt supports it you may also use this command line instead:
      • for /R %i in (*.dll) do ngen %i

If you later decide you did not want the assemblies compiled natively, you can use the ngen /delete command to remove these now compiled assemblies.

  • Note that not all methods or types will be natively compiled by ngen, and these will still need to be JIT’d.  Any types or methods that fall into this category will be output during the running of the ngen executable.