Sunday, February 25, 2007

XNA

I played around with XNA and I must say I'm quite pleased as how it is designed. It is very easy to start a new project and try stuff without having to go the hard route of setting up everything correctly in order just to render a single polygon flat shaded on a Direct3D surface.

Basically, you derive a class from the Game class and you register different GameComponents that will be updated every frame. The game loop is built-in as are all the message dispatching stuff so you don't need to worry about that.

As for me, I started from scratch a new game along with an editor and I found a way to incorporate the editor easily in-game. I just created a GameComponent for it so it will get updated along with my other engine related modules. The best part of my editor though is probably my Entities editor and the beautifully designed standard Windows.Form.PropertyGrid control. All you have to do is define some public Properties in your entity classes and you'll be able to edit them easily in a property grid control. I like how you can have a lot of control and flexibility in C# .

Here's the first screenshot



There is nothing to see yet in the main window as I was working on the entity system along with the editor. Next step will be some rendering :)

Saturday, February 17, 2007

DirectX Managed VS XNA

This one is simple.

DirectX Managed has been left in its current state as of version 1.1 and Microsoft will not provide newer versions as DirectX evolves. Instead, they chose the XNA Framework path so if you're serious about making games or graphic related applications that require advanced techniques, you really should start by either coding in C++ with DirectX unmanaged, or pick C# and XNA. Forget about DirectX Managed, just think it doesn't exists anymore, it is officialy dead. The good news though is that XNA works on the Xbox 360 as well as the Windows platform, so you can easily deploy your app or game on both without too much additional work.

What are the consequences? Well it seems right now the XNA Framework only works with Visual Studio Express edition (which is free btw). It doesn't integrate with Visual Studio Professional or Enterprise at all. It seems there is a version coming for it but they won't announce a release date yet.

C# from a C++ programmer

I like C#, it is overall a well thought out language, but coming from C++, there are some things you should be aware of.

Struct VS Class
C++: There isn't much difference between a struct and a class. Both can be used exactly the same way as the only difference is that a method in a struct is public by default where it is private in a class.

C#: Struct cannot be derived from unlike classes and they are always passed by value instead of by reference. What does this means? it means a lot since having a property in C# which points to a struct cannot return a reference to it but rather will return a copy of the data.

Conversion operators (casts)
C++: You can provides type conversion operators and you can make sure they point to the same memory as the original data easily.

C#: A cast operator will need to create an entire new object of the new type and thus will not reference the same memory. This is why many people advocate not using cast operators at all but instead provide conversion methods like ToMyType() as in ToString() or whatever. Casting different objects around can be very costly in C# if you don't know what you're doing. For more information read about boxing and un-boxing.

There are many other things to consider but I found those to be the 2 major points to take into consideration while switching from one language to the other.