Wednesday, October 29, 2003

I was doing a little book research on Sprites in DirectX when I came across Kevin Harris' CodeSampler.com website.  He has a TON of samples in C++ there, the DirectX 9 samples being located here.  On that page, you will find a sample titled "Creating 2D Sprites with D3DXSprite"  It's one of those simple DX samples that gets right to the point, but still gives you something "meaty" to tinker with (as are most of his samples).  Anyway, the challenge is that none of his samples use Managed DirectX.  I took a few hours last night (plus 30 minutes today to have Tom Miller correct my errors :-) ) to rewrite the app in Managed DirectX and C#.  You can get the code here (csd3dxsprite.zip (44.07 KB) all set up for VS 2003).  There's a few points to keep in mind:

  • The code was rewritten to heavily leverage the event model in .NET windows forms.  Overall, it should be very understandable, but you can clearly see the difference between the C++ and C# version in this area.
  • The code is about 1/3 smaller than the C++ version.
  • The code is not an example of stellar "defensive programming".  I just wanted to do a fast conversion.  Feel free to criticize, fix it, make it prettier, etc. 
  • Finally, those of you familiar with DX will notice two things:
    • The "main loop" lingers inside the OnPaint event, triggering a "this.Invalidate()" at the end, effectively forcing OnPaint to be raised again.  Tom Miller claims that this is a more effective mechanism to work inside the eventing model but still follow the basics of a "game loop".  He wrote the Managed DirectX code, so who am I to argue? :-)
    • The code uses the new DX9 Sprite class, which is unrelated to DirectDraw sprites (they are basically textured quads).

Anyway...enjoy!

10/29/2003 8:14:43 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [3]  |  Trackback

In case you're missing out on the big events at PDC, don't worry!  Most of the presentations can be found here.  Keep an eye out for webcasts and extra things coming over the next couple of weeks.  There's a LOT of stuff coming from Microsoft now regarding our next revision of our developer tools and languages (Whidbey), our next gen database (Yukon), and our next major platform (Longhorn and the supporting API, WinFx).

As a guy who used to do a lot of Ada programming, I've always missed the "generics" that were found in that language.  One really cool thing is that the next version of C# will incorporate a strongly-typed generic mechanism.  While not as complex as Ada generics (thankfully!), it will definitely lead up to some higher-performance applications.  The nice thing about generics in C# is that they provide stronger type binding, eliminating (or reducing) the need for Object casting and boxing/unboxing, which is an expensive operation during execution.

Ironically, this is almost the opposite effect that you will get in Java generics (coming in the 1.5 release), which appears to force boxing in many cases when using generics (in fact, I heard one Sun person at JavaOne mention that boxing was introduced specifically to "make generics work right").  This potentially means the performance gap between Java and C# virtual machines will get wider.  Only time will tell, but I've clearly made my bets.  Of course, the big advantage of Java still remains: You can make an application run slowly and not take advantage of the underlying platform anywhere at anytime :-)

P.S. -- Peter Drayton is back!  Let's hope it's for good this time!  I always enjoyed reading his blog.  Much easier than walking down two flights of stairs to just talk to him :-)

10/29/2003 12:07:45 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [3]  |  Trackback
Saturday, October 25, 2003

I had the chance to read both Al Franken's "Lies and the Lying Liars Who Tell Them: A Fair and Balanced Look at the Right" as well as Michael Moore's "Dude, Where's My Country?"  as I was winging back from NY to Seattle.  I enjoyed them both, but found Al's book more enjoyable.  I have always enjoyed Michael's biting attacks on Corporate America and our Government, but felt he was trying too hard in this book to state the obvious: That the people running our country right now are lying to us on multiple levels, EXCEPT about who they have sex with.  Of course, you can disagree with me (that's what the comments section is for), and I don't mind.  Hell, sometimes I find myself disagreeing with myself :-)  And I must admit that I don't agree with everything Michael says (he sometimes seems overly eager to stretch facts to make a point)... but you have to admire his principles.  Most folks, for instance, are only familiar with his controversial acceptance speech at the 75th Academy Awards, but I would encourage you to watch his Red Carpet Q&A session (click on "Documentary Feature") that was done immediately after his award.  It's quite interesting (even if you disagree with his viewpoints).

OK, enough politics, this is also supposed to be a little technical.  For those of you wanting to learn more about Managed DirectX, I would encourage you to look at Craig Andera's tutorials on the managed (.NET) verison of Direct3D.  If you want to get a quick overview of some the features of Managed DirectX and why you might want to consider using it, have a peek at this slide deck, primarily written by Tom Miller, Managed DirectX - IGDA.ppt (1.16 MB).  And for those of you wanting to see a simple deck on what it takes to be a Game Programmer, check this one out: Game Development.ppt (73 KB) (It needs some updating, but I need to finish my book first).

Oh, stay tuned for really cool posts this coming week on all sorts of new technologies coming from Microsoft.  PDC kicks off tomorrow and we will FINALLY be able to start talking about some of the new innovation we've been working on over the last few years!

10/25/2003 1:53:04 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [2]  |  Trackback
Sunday, October 19, 2003

Well, I'm heading to NYC for a one week trip to explain the New and Improved MSJVM Gospel.  If you see a disheveled, 6'1 guy in a rumpled suit and a war-torn look on his face: that's me (come to think of it, that could be any guy in the financial section of Manhattan at 4pm).  Speaking of the MSJVM, I gotta give credit to Sun, they're doing a pretty decent job of trying to help people move from the MSJVM to the Sun JRE.  They even have an "upgrade site" aimed at helping people move from the MSJVM to the Sun JRE.  Of course, many of the remaining MSJVM-dependent applications use Microsoft-specific libraries, which won't run inside Sun's (or BEA's, or IBM's) JRE.  Sun is promising an upgrade tool that will detect (but apparently not automatically correct) dependencies on Microsoft-specific libraries.  Microsoft already has a tool that will convert many of the dependencies, the Java Language Conversion Assistant (JLCA).  Of course, die-hard Java advocates will point out that the JLCA only converts to C#, but if you're already wanting to take advantage of Microsoft-specific libraries, and you want to avoid the performance and development problems of Swing, the JLCA is the best way to go.

Doug Purdy introduced me to The Gospel of Supply-Side Jesus.  I'm looking forward to reading Al Franken's book on the flight to NY.  I should be writing my own book, but it's tough to write a book when you're packed into the middle seat in the coach section.  Speaking of my book, the Amazon link to it is now down.  I think they put it up too early (and considering the delays I'm having because of work-related trips like this to NYC, maybe that was the right thing to do :-( ).  For a while, I've been worried that I've been so buried in my book writing that I would miss out on some major, incredible peice of news.  Then I heard that the Cubs really were NOT going to to the world series, so I guess everything is normal.

Time to sign off, I gotta go buy a vacuum cleaner.  The one I have sucks.  Well, technically, that's what it's NOT doing :-)

10/19/2003 11:13:25 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]  |  Trackback
Tuesday, October 14, 2003

Amazon has finally listed my book, Beginning .NET Game Programming in C#.  Of course, they have just about everything except the ISBN and author names wrong :)  In any case, I'm really excited about getting this thing done!

Oh, Kill Bill rocked.  I wish it hadn't been split in two though.

10/14/2003 9:01:38 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [5]  |  Trackback
Monday, October 06, 2003

CNET is reporting the Jan 2, 2004 deadline for the Microsoft Java Virtual Machine has been extended to Sept 30, 2004.  That should give everybody plenty of time to migrate to .NET now :-)

10/6/2003 10:50:30 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]  |  Trackback

What fun.  Time for everybody to change their web pages if you use Applets or ActiveX controls.  More details here.

 

10/6/2003 6:43:58 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]  |  Trackback
Sunday, October 05, 2003

Almost two months since my last post. No, I'm not dead.  Just reborn.

No, I didn't suddenly discover religion (Not likely -- proud member of the Skeptic's Society :-) ).  I've made a huge number of changes in my life, some personal and some professional.  Since the beginning of August, I've pretty much been knee-deep in writing a book, which has devoured all my personal time.  I know I'm going to be one of those authors that will constantly haunt the review pages on Amazon to see what people think of the hard work I've done (correction, "am doing").  I'll probably be scarred for life at the first "1 star review", so be gentle on me  :-)

Oh, the book will be an entry level book about game programming with C# published by Apress.  Should be out in time to put under the Christmas tree (hint hint).

As you can clearly see, I've also switched ISPs and blogging tools.  I'm now chugging along with DasBlog and hosted at webhost4life.

Anyway, I promise to post more often now!

10/5/2003 5:19:29 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [1]  |  Trackback

Theme design by Jelle Druyts

Pick a theme: