Jumping into DirectX

by Administrator 19. May 2005 03:32

I have never done DirextX programming before, as I mentioned my graphics experience is in 2D software drawing APIs (ie, line/pixel/arc drawing) and OpenGL.  Tonight I got some paying work done and needed to dabble in something so I got the latest and greatest Managed DirectX download from MSDN, dated April 2005.  I have mostly been messing around with the sample programs tonight, and just started combining some of the samples to do something more than hello, world.  "Hello World" in graphics land is drawing a shaded triangle, by the way.

A few observations from an hour of messing around:

The Good

Things have come a long way since I last did anything with graphics.  Creating a drawing device can be done in as little as 2-4 lines of code.  Its fairly easy to get to the point where you can start messing around and see something on the screen.  Microsoft has also included some Intellisense documentation, which was missing when I played with DirectShow a while back.

                PresentParameters presentParams = new PresentParameters();
                presentParams.Windowed=true;
                presentParams.SwapEffect = SwapEffect.Discard;
                _device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);

... then draw away.

The Bad

Performance from Managed code does not look like its going to be pretty.  I'm thinking it should be able to draw the simple scene shown above more than 42 times per second.  Also, many of the examples included in this release of the SDK do not compile or work.  The most annoying thing I encountered is the code included for drawing text to the Direct3D device did not compile.  It looks like MSFT has been tweaking the managed API and has not updated all the samples.  For what its worth, I got the "GraphicsFont" to work with minor code changes, and I'm including the file here for download on the off chance anyone else is having issues. 

GraphicsFont.cs.rename (22.61 KB)

More observations as I get time to make them.

Tags:

Comments (5) -

Zman
Zman
5/20/2005 6:40:13 PM #

42fps is indeed terrible, but its not the MDX API or managed code. All the samples run at 99%ish of the unmanged code. Managed DirectX is a very thin layer.

I'm also a little confused as to why the samples didn't compile - what exactly did you have to rename? Maybe you were somehow running against an older version since they did tweak that API at some point (I think between Dec and Feb releases) [I have the Feb -> Apr changes documented here http://www.thezbuffer.com/articles/184.aspx)

Reply

Damon Payne
Damon Payne
5/20/2005 7:00:06 PM #

It looked like some of the types of some private member variables had to be changed.  For example TextureState --> TextureStateManager, RenderStates --> RenderStates --> RenderStateManager.  Since my code does run now I assumed this was due to some API tweaks thtat didn't make it into the April 2005 SDK release?

Reply

Damon Payne
Damon Payne
5/20/2005 7:10:29 PM #

Also: on the computer I'm developing this on now, I have never installed an older Version of the MDX API: April 2005 was the first MDX this machine has seen, so I don't think I could have been accidently using an older version.

Reply

Zman
Zman
5/24/2005 3:25:50 AM #

Which sample is that file from - there is no Graphicsfont.cs in the april SDK, nor a file called D3Dfont.cs

And what are your managed DirectX plans? ANything worth me posting about on thezbuffer?

Reply

Damon Payne
Damon Payne
5/24/2005 2:29:08 PM #

I'm going to have to clean this machine, I think.

My plans are to make a simple "Scorched Earth" style tank game to get a handle on some basic physics and AI.  After that, my goal is to do some realistic modeling of explosions and explosion shockwaves.  I could ping you when I come up with something other people might find interesting.

Reply

Pingbacks and trackbacks (563)+

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading


About the author

Damon Payne is a Microsoft MVP specializing in Smart Client solution architecture. 

INETA Community Speakers Program

Month List

Page List

flickr photostream