XNA UK User Group

A helping hand for bedroom coders throughout the land.
in

This Blog

Syndication

RandomChaos

C++ hmmmm.....

Not that many of you will be interested in ANY C++ code, BUT, I have started to play with some C++ and DirectX9. At first so I can get a better understanding of what is going on under the XNA layer and it has made me appreciate just how much XNA does for us.

I have been a C++ developer in the past, but never really done much GUI stuff, I tended to use stuff like VB for my front ends and do all my number crunching in C/C++ dll's so even though I know the language, the whole Win32 API in C++ as well as some of the data types are new to me. I have found a couple of sites invaluable to me in this endeavour however, I started off with Riemers one and only C++ tutorial, a great place to start. Another site FULL of info is the ToyMaker, I think I have mentioned it in old posts, but this site is a great mine of information if you are an C# XNA or C++ DX developer, I highly recommend it.

I am blogging my adventures in C++ at my old blog, so if you want to check it out you can find it here. I am intending to port ALL my XNA code over to C++.

Here is a clip of were I am up to at the  moment.... http://www.youtube.com/v/3b28vdmBVlQ <p><a href="http://www.youtube.com/v/3b28vdmBVlQ">http://www.youtube.com/v/3b28vdmBVlQ</a></p>

http://www.youtube.com/v/1YkzS3frR9A <p><a href="http://www.youtube.com/v/1YkzS3frR9A">http://www.youtube.com/v/1YkzS3frR9A</a></p>

Published Oct 27 2008, 09:31 PM by Nemo Krad
Filed under:

Comments

 

Mahdi Khodadadi Fard said:

Why don't you work with Managed DirectX ? it is same as DirectX but uses C# instead of C++.

October 29, 2008 7:01 AM
 

Nemo Krad said:

Having used XNA I thought it would be another string to my bow if you like to have some DirectX C++ samples up too.

I guess at some point I will look at Managed DirectX, but at the moment can't see the advantage of this over XNA. Not that I think C++ is an advantage over XNA and C# but it is at the very least a different language.

I guess C++ is also what the industry wants and if at any point I decided to look for work in the industry having C++ samples too would help I think.

October 29, 2008 8:56 AM
 

Peter said:

I think that if will be great to compare FPS from the same terrain with C++ and C#? Do you have results like that?

October 30, 2008 4:27 PM
 

Nemo Krad said:

Yes, in my current C++ implementation I get about 52 FPS and the C# XNA version is running at 47 FPS.

BUT, the C++ version is pretty raw, it is a single class, no hierarchy and runs in a very simple UserInput.Update, Camera.Update, then Terrain.Draw , the C# XNA version inherits from DrawbleGameComponent and runs in the XNA game loop.

Also the C++ implementation is ~5% faster than C# I am actually surprised there is only a difference of 5 FPS. To be honest, for the extra 5 FPS I would rather use the XNA solution as it is much easier to implement, take a look at my C++ blog and see how you have to set up a graphics device....

October 30, 2008 7:36 PM
 

Jeremy said:

YAY! Charles has finally seen the light ;) and remember that the 5FPS is in an empty world with nothing in it but the terrain ;)

Nice demo man.  Keep up the good work :)

November 6, 2008 1:40 PM
 

Nemo Krad said:

lol, yes but there is all the overhead in XNA.... that is totally absent in C++ (well you have to write it your self) that you need, like fixed time step, (did remove it in this test though) but you still have the draw order sort for drawable game components as well as update storting.... To be honest for all the bells and whistles you get with XNA I would have to go for that and accept a ~5% drop in speed... unless my XNA game runs at 25 FPS then I may post over to C++, but then I can't run it on the Xbox then....

Anyway, it's bad news for me, I now have 2 powerful addictions, at least they are in the same area...

November 6, 2008 3:03 PM
 

Jeremy said:

I agree for the most part ;) The performance gain is totally not worth it for a fun, self imposed project.  I love XNA for quick prototyping of any concept I want to use for my school projects.  I know all about the addiction choices though :) I wish my prof would let me use XNA for my homework assignments :p Keep up the amazing work.

Later,

Jeremy

November 7, 2008 5:40 PM

Leave a Comment

(required)  
(optional)
(required)  
Add

About Nemo Krad

Have been a professional developer since 1995. My skill set ranges from C/C++, VB6,MSSQL, Java Script, VB Script, HTML/ASP, Java, C#, ASP.NET as well as others. I started 3D and games development when the first release of XNA came out in December 2006 and have become addicted to it.