Direct3D for everything?

My journey started simply enough, I just wanted to add alpha-blending to a DirectDraw application I'm working on.  Much to my suprise, I learned that DirectDraw doesn't do alpha blending.  I found a C routine that worked, but slowly.  I found an inline assembler routine that used MMX and was faster, but not fast enough.

My next batch of research said that I could use Direct3D to render an alpha blended texture in hardware to my DirectDraw surface.  Not only could I alpha blend, but I could use other goodies supported by most hardware nowadays.

I once considered moving to DirectX8 but someone told me that DirectX8 completely depricated DirectDraw and that I should stick to DirectX7 for non 3D apps.  So, here's what I need to know...

Is it becoming the standard to use Direct3D even if you do not need all of its 3D capabilities?  Is it preferred now to use Direct3D but to define all your objects as flat surfaces?  Are there any drawbacks to using DirectDraw for 90% of my stuff, but delegate my alpha blending to Direct3D?  Should I completely get rid of DirectX7 and go to 8?

I've come a long way in a short time, but there are so many variations of this one technology out there that it is difficult to know which to use.  

Thanks in advance.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

cybermike3dConnect With a Mentor Commented:
Definately use Directx8 for your development. There are various ways of achieving the same results, cos DX8 seems to incorporate the best of both worlds. As for as alpha blending is concerned, you can do alpha blending by using the material alpha, lighting alpha or, you can use an alpha bitmap. Take the DXTEX.exe utility that comes with the DX8 sdk. Take your standard texture map. Duplicate it, monochrome it, set the areas u want as transparent black, opaque, white, and semi see through ... grey. From dxtex, load the .bmp which is you base texture, and then assign the second(opacity) bitmap to the alpha channel of the image ... then save the bitmap back to disk as a .dds file. This format is recognised by DX8 as having 4 channels, red, green, blue, alpha (32 bits) for each pixel. DX8 also supports specular mapping and bump mapping.

Yep, my opinion (for what its worth) use DX8, it supports all the functions ... u dont neeed to go anywhere else.

Best regards

If you are just wanting to do alpha blending, I would recommend just writing the functions yourself.  If your just using a 2d surface it shouldn't be any problem to look at the pixel values and modify the new overlayed pixels according to those upon which they were placed.  You could write the function(s) one time and use them over and over.  Do you really need to learn a new API?
l99057jAuthor Commented:
smitty, I've already written the functions but even using MMX features it is too slow.  

I am pretty close to having the Direct3D workaround in place and am going to use it for this project but intend to go to DX8 for future programs.

Cybermike, I'm going to award you the points since you answered first and your answer addressed my needs.  But I'd like to leave this question open a day or two longer to give others the opportunity to chime in with any useful information.

Also, I checked out your website.  I understand that your game is written in VB6?!?  I'm a loooong time vb programmer and usually the one to run to VB's defense when somebody says "you can't do that in VB."  But to be honest, I haven't been able to get the performance I want out of VB where games are concerned.  The screenshots looked awesome, congratulations on what looks to be a promising game.  
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Thanks for the kind comments ... Been actively working away full time at the code for about six months now. I did a lot of testing, and on a AMD 750 / P3 733 with riva card, Using full fx, lighting, specularity, alpha, and relatively high poly count meshes, I am achieving a frame rate of 45 fps. I loaded the system as far as I could, to see what level I could go to, before I reached my minimum acceptable frame rate of 15 fps.  I put in 20 craft, each with a weapon capable of firing 20 rounds/missiles, as well as sound and joystick support ... DX8 handles over 400 meshes, with animated texture maps, the world, fogging, lighting, and framerates varied between 12 and 18 fps, depending on whether there was music on, and the complexity of the AI, screen size ... I am quite satisfied that the VB6 / DX8 will do the jobe quite adequately. With the Athlon 1333Mhz, I can draw 1000 (all in motion) meshes at a consistent frame rate of around 17 frames per second. (the game board caters for a max of 1000 pieces)  The performance difference between VB and C does seem to have shrunk ... dont u think.
In short, YES the performance difference has shrunk, but only because both are having to tear through the red tape of Windows.  You said you did 1000 meshes at 17fps.  How many polygons are we talking about per mesh?
The craft, fighters, bombers, tanks etc use a default mesh of about 256 faces, (the fighter is 264) but I cheat a little. I use progressive meshes, ie, I have a smoothed mesh of 1060 poly's for closeups (0 - 50 meters), then, the 260 poly mesh for 50 to 500 meters, after that, I use a low poly mesh, 20 faces. The lasers, explosions, bullets etc are texture mapped onto a single polygon (square). An explosion for example will have 15 texture maps, the afterburner will have 4 texture maps, A lot of the 3D stuff is pre rendered in MAX and then, the animation is played on the texture map of a single square. At any given time, there are fewer than 10 Hi poly meshes being drawn. Attacking hordes for example, the alien mesh is about 500 polys, but, there are 10 pre rendered texture maps which are rotated on a single polygon. U cant tell the difference. Adaptive degradation and all. So, the total scene will consist of about 20 or so hi def meshes, and about 900 single polygon meshes, which will just be repeats, ie .. the attacking alien soldier, only has 10 texture maps, which are repeated over and over ... like a forrest. Only when it gets within 50 meters ... does the software substitute the higher polygon mesh .... likewise, the textures are mipmapped. Yes, one has to optimise all over ... drawing a thousand, 500 polygon meshes ... that will grind the system to a virtual standstill. even if it is an athlon 1333. So, the software caters for 128 models, each with 16 bitmaps. and each model having a max of 16 alternative meshes. (under construction, active, damaged, destroyed, closeup, normal, far etc, etc. ) One must bear in mind of course, the Field of vision, ... I dont draw objects that are outside the camera's field of vision ... waste of time that ... so, at any given time, u are looking at about 10 x 260 poly meshes, 2 or 3 1000 poly meshes and about 100 - 200 single poly meshes with revolving texture maps providing the animation. Anyway, pop into my site from time to time and check out the progress. I hope to have a pre release demo available in about 3 months time ... then u can check it out and let me know what u think.
Best , mike.  
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.