Link to home
Start Free TrialLog in
Avatar of l99057j
l99057j

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of cybermike3d
cybermike3d

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of smitty1276
smitty1276

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?
Avatar of l99057j

ASKER

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.  
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.