Archived

This topic is now archived and is closed to further replies.

CrazedGenius

Why are so many people using DirectDraw?

Recommended Posts

This is not meant to be a flame or anything - I''m just curious... I see alot of people using surfaces, locking, etc. and while I can understand the "using what I know" angle, I''m not sure why people are using this when current hardware is very much tuned for 3D and you can use the 3D/texture DirectX stuff for 2D work very easily. If it would help, I could write a gamedev article on using DX8 for 2D...

Share this post


Link to post
Share on other sites
Well, not everybody has a 3d card (!). And 2d programs generally don''t require the same kind of speed as 3d programs (think card games versus first person shooters), so there''s no real need for hardware accelerated everything.


~~~~~~~~~~
Martee
http://www.csc.uvic.ca/~mdill

Share this post


Link to post
Share on other sites
Here''s a couple of reasons I can think of:

1) Everybody''s used to using DirectDraw for 2d, no use in complicating things

2) Not everyone owns the latest 3d cards, and 2d is still supported


Uh, that''s all I can think of right now. Personally, I still use DirectDraw for 2d, but use 3d for certain effects (alpha blending, etc.)




"We are the music makers, and we are the dreamers of the dreams."
- Willy Wonka

Share this post


Link to post
Share on other sites
Ahh...

fair replies. I guess my question was based on an assumption that people were writing games with a long enough development cycle that you could count on there being 3D hardware (pretty much 100% of machines shipped today are 3D accelerated).

As well as the hardware issue, it seems like a bad time to be learning the DX7 stuff that is gone from the API. Just a thought.

About complicating things - IMHO, the D3DX API makes dealing with bitmaps, etc. much easier than DX7.

A final thought - using 3D DX8 calls for 2D would involve VERY little geometry, and therefore your chief constraint should fallback to being fillrate. Therefore, any card that works well for straight 2D (good fillrate) should work well for 2D-done-using-3D. It seems like you would have the advantages of new APIs, support for new hardware, and more than adequate legacy support with no real disadvantages. I'm saying this without any hard data to back it up. Am I missing something?

Edited by - CrazedGenius on June 12, 2001 11:54:11 PM

Share this post


Link to post
Share on other sites
My excuse is... well... I don''t really have an excuse.
One reason is that Microsoft Doesn''t make using DirectX easy for BCB (Borland C++ Builder) and DirectDraw is easier to get running correctly than Direct3D.
The second reason is that I never really thought of using Direct3D for a 2D application.
The third reason is, my computers 3D accelerator sucks (it is non-existant) though I can run most of todays games it is more understandable for me to acknowledge lower system requirements than high end card owners (who tend to assume the, "oh, I thought every one had a card as good as mine" attitude towards developing). Many people go years without upgrading and when they do updrade video is one of the last things to get done.
The fourth reason, I am already well versed in 3D programing, but I am not good at 2D, so I got up one morning and decided to learn.
Finally, it seams like overkill. Direct3D frees up more resources and takes better computers to run. So why make something using more demanding technology when you can make it look exactly the same with less demanding technology.

Ok, that is my input. I might look into Direct3D but I usualy use 3rd party api''s (Genesis3d and Morfit) for 3D and Direct3D is a big step into a much more complicated api.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Keep in mind that while the majority of system will have 3d accelerators in them, the vast majority of these will be built into them (read, low end 3d cards by todays standards - yes lower than a TNT2).

While using Direct3D is good for doing alpha blending for 2d graphics, many of these systems will actually do alpha blending faster in software since there is less overhead. Direct3D still has to ''texture'' the resulting polygon using the current render state where a good assembly level blend rouinte does not have to map pixels to a polygon.

Direct3D also runs into much stricter coding when dealing with texture state changes and sizes.

In the long run, I recommend using DirectX7 if you are writing a game that utilizes a lot of 2d graphics and text. Ideally you would code your engine to use 3d rendering if available where needed.

Share this post


Link to post
Share on other sites
i got fed up with directx after is complexity to draw a simple bitmap which i could never get to work so i switched to opengl and boy whata difference. hell of a lot easier, for me that is. i only gota tnt 1

Share this post


Link to post
Share on other sites
I''d love a tutorial article on using DirectX8 for 2d. The reason I haven''t switched is I remember how much a pain in the ass it was to get a system in place for blting bmp''s to the screen. The sdk help files can be quite cryptic at times. So knock yourself out, at least one person will benefit from your article.


Later,
Eck

Share this post


Link to post
Share on other sites
I just started this process of migrating. I am tired of the limits of DirectDraw and want the full power of Direct3D.

Been looking around for samples and... ouch! Not a lot to pick from. Tons of DD stuff, but D3D is fairly thin right now.

So please.. Write away! I''ll hang on your every word. I can even proof-read it for you if you want.

Share this post


Link to post
Share on other sites
I think a main reason (or at least _my_ reason) is that people have used DDraw for their graphics engines, and not updated their code when DX8 came out.

For me that is the case anyway. I wrote all my GFX routines first, and now I am wrapping things up with mission objectives, mission tree flow, between level linking sequences, etc, so it would be a BIG waste of time to convert the whole engine over to D3D, especially this close to the end of the project (feature creep anyone?)

Also, I can''t remember where, but some guy did a demo that used 200 DDraw sprites and compared that to 200 D3D quads and DDraw was MUCH faster. Just a thought.

Share this post


Link to post
Share on other sites
I personally started programming in DDraw. When I started my new sprite engine with DX7, DX8 had only been out for a little while. I figured it would be hard to write my engine using D3D. So please, enlighten me on how easy it is. I''m sure many people would appreciate an article using DX8 for 2D apps

Share this post


Link to post
Share on other sites
My reasons are:

- low-end compatibility... not much point in making a simple 2d game if it runs like a dead dog on tranquilisers on a system without a 3d card, and there are still such computers out there.

- it seemed to me that it would be faster. Although I had no stats to back it up, I figured that using 3d commands to do 2d would be slower at runtime.

D3DX might make bitmap loading easy, but so does ddutil...
LPDIRECTDRAWSURFACE7 Sprite = DDLoadBitmap("sprite.bmp");

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The idea of using 3d to do 2d operations in DX8 stinks.

I had a requirement a few days back where I had a 2048x64 image and I needed to copy a chunk of it to the screen (128x64). I added this to the code I was working on, ran it and the app dropped 40FPS!!!!!!! from a respectable 80+ on a 1Ghz TBird GeForce2 MX!!! WTF!

After messing around with it for a while, I ended up writing a custom blitter to the frame buffer, optimized it, ran it, whadda ya know, 80+fps!!!

Just goes to show that merging D3D & DX can produce bad results!

Share this post


Link to post
Share on other sites
For a moment I entertained the notion of using Direct3D 8 for 2D, but I ran into a few problems:

1) For straight blitting, it was slower than DDraw, even with HEL DDraw.
2) It was nigh-on impossible to encapsulate a sprite in a class, because of the vertex buffers and other stuff.
3) The restriction of textures with powers of 2 for their dimensions is a ridiculous restriction for 2D work. It wastes memory too.
3) You could not hardware blit a 800x600/640x480 bitmap to the screen.
4) There were too many damn render states.
5) Everything went wrong.
6) It used matrix multiplication for transforming and stuff kept on getting ridiculously over complicated.
7) Sprite data was impossible to load from a file.
8) You had to do ridiculous stuff to get it to color key your files.

And had only the following benefits:
1) Free rotation, scaling and flipping (but you made up for this by making normal blitting stupidly slow)
2) Switching between resolutions and windowed and fullscreen mode was easy peasy.
3) Fewer lines to set up us the bomb/initialisation.

I thought that 8 against 3 wasn''t worth it.

Share this post


Link to post
Share on other sites
A rebuttal to Furby... I think it depends on how you''re doing things...

1. I haven''t seen this. Although, if you are not careful about how you do this, I can see the possibility of bad results.

2. I strongly disagree, I have been doing this for a long time in OpenGL, DX<8 and DX8 and it works really well.

3. Again, it depends on how you do it. You can use one texture for multiple pictures if you are careful about it. And, you should not lock when rendering.

3. Sure you could, if it is a subset of a 1024x1024 texture...

4. For 2D?? Yes, there are alot, but most will not be used/important

5. not a good general observation

6. for 2D, this should not have been an issue

7. I disagree, please elucidate...

8. in DX8, the ridiculous thing is one parameter in the texture creation function.

Yes, yes, much of what I say above is "If you''re careful", and "if you do it right", but remember, the pipelines in graphics cards are becoming extremely 3D focused. I''ve found that using DDraw techniques does make for very slow rendering, but that''s because those techniques make sense less and less. Keep in mind, MS didn''t remove DDraw from DX8 because they are evil, they did it because the hardware is tuned for 3D and you should learn how to use it. I will hopefully get a tutorial together very soon...

Share this post


Link to post
Share on other sites
DX8 has built in sprite routines for 2d stuff, I think it is under the D3DX section. It has support for fading ,alpha blending, rotation (you set the rotation centre), plus other stuff I don''t even know about. When you load the texture you set the color key.

People always talk about how difficult it is to use D3D for 2d stuff but it''s so easy to use the D3DXSprite interface, even easier than DirectDraw. Also it is not slow, under DirectDraw you could never get all the effects with the same speed as a D3DXSprite and even if you don''t want these effects it is still incredibly fast. It seems there is stuff on ths all the time but why has no one ever used D2DXSprite?

P.S. It is very easy to use I''m still a newbie and manage just fine. Please comment on what I''ve said.


Share this post


Link to post
Share on other sites
Why am I using DirectDraw?
1)It''s simple.
2)For anything I would do DD would be sufficient.
3)My 3D modeling program doesn''t save stuff as .x files.
If it weren''t for that last one I''d probably work with D3D a little. What''s a good 3D modeling tool for that anyway?

"A man can''t just sit around." ''Lawn Chair'' Larry Walters (1982)

Share this post


Link to post
Share on other sites
I would like to see the tutorial, mostly as a good way to start doing 3d apps (I''ve never done anything 3d runtime) but I will stick with DDRAW, because it is not supposed to be easy, is supposed to allow you to do things in windows like you used to in DOS, like accessing the video memory and such, (remember writting to memory location 0xA000 anyone?), sure I remember Turbo C++ having a graphic interface library, but it was not as fast as directlly writting to the video memory area.
I donr know why they want to leave ddraw out of the picture or integrate it with D3D, my favorite PC game of all times is Starcraft, followed by Dune 2 (DOS) I dont remember seeing polygon there.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I''ve always wondered why 3d hardware accelerated as 2d is "better" than straight 2d. 2d _should_ use less transistors, therefore take less time, (or how ever it works) so why whould you use 3d for 2d?

It seems like using D3D for 2d is like using a forklift to raise your computer chair.

Share this post


Link to post
Share on other sites
Quite frankly, the only good reason i can think of not using 3d for 2d, is that you are used to usual 2d technics and don''t want to make the effort to learn 3d.

I am currently working on a 2d space shooter. The more i advance, the more happy i am with my choice of using OpenGL instead of DDraw. I can''t really speak of D3D but well..

- the 3d rendering code is amazingly small (around 200 lines, grouped in a single renderer class), a lot smaller than what would have been needed if using DDraw. All the other classes are independant of the API.

- you get free rotations, translations, scaling, but also alpha-blending or transformations (for animations). I can''t understand how some of you guys are not more interested in these effects! Have you tried doing alpha-blending in DirectDraw? That''s horribly slow!

- the speed issue: i don''t have a very fast computer (P200 + Vaudoo2), but let me tell you that using hardware acceleration is *a lot* faster than 2d. Can''t say for fast machines though. Maybe hardware dependant.

Y.

Share this post


Link to post
Share on other sites
The flipcode tutorial is decent, but it concentrates more in 2D geometry (lines, etc.) and less on the D3D equivalent to a "blit", which is really the point of contention here...

Share this post


Link to post
Share on other sites
Simply Because:

1. 2D sprites (3D prerendered ones) LOOK SO MUCH BETTER then 3D realtime rendered images esp IF u are talking about many units (100+ or so) like in a RTS or a RPG... even a sidescroller is/looks better in 2D

I agreee FPS is allways better in 3D because this type of game
generated the 3D movement after all. Also fly simulators (plane etc) are better in 3D (can not even think to do them in 2D)

Many super succes games are 2D: Starcraft/Broodwar, Age of Empires, Comand & Conquer, Comandos, Desperados,Baldurs Gate,Diablo1/2 etc

GFX on this games is briliant and seameless...as opposed to 3D games where (most of them) show seams and pixelate like images when zoomed/looked closer.

Usually 2D games have nuch powerfull AI compared to their 3D counterparts.

2D code is ussually much easy to convert to other OS (linux) using simple framebuffers ...of course unless u are using OpenGL but this war (D3D vs OpenGL) is another issue


2. Not all games require 3D, this is a today "mode" because of hardware sales etc...but there are a lot of games that are better in 2D like: teris(c), arkanoid(c) etc

Not to forget the problems of navigateing a 3D world ...this can ruin a RTS game dynamics . RTS is a big part of the game industry and IMHO is not good to move it to 3D.

Thats why me an my team are doing a RTS in 2D using DirectDraw, and very little (up to none 3D acceleration)

Forceing games into 3D is not allways a good thing...its only good for advertise and hardware sales I belive BOTH 2D and 3D can make very FUNNY and PLEASNT games if they are given the chance and if programmers/artists/designers etc do thei job ok.

I belive it is a bad thing 2D is not better supported by DX8 and today video cards...then there whould be not so many questions about :

-Why the hell my super 3D card CAN NOT do a SIMPLE 2D Alpha Blending? (actually all 3D card are 2D accelerators... because they fill 2D triangles, minus the ones that do just some little T&L)

Answer is: because THEY dont want u you to!
(but the video board can do it actually)

Also i find it stupid that 3D cards use and enforce a single algorithm for 3D render: scanline triangle fill variations

Raytraceing and eventually some backface culling should be also supported ... or at least developed by software until they become more popular/evolved...

but NO THEY will not let you use 2D at full speed (u need that for testing new algorithms)






Edited by - bogdanontanu on June 15, 2001 7:34:46 PM

Edited by - bogdanontanu on June 15, 2001 7:40:47 PM

Share this post


Link to post
Share on other sites
> even a sidescroller is/looks better in 2D

What the hell? Why would 3d rendered images look any less good than 2d ? Assuming no streching is applied, you''ll get the exact same quality. I don''t hear a lot of pple saying Diablo2 or BG2 look like crap, yet they use the 3d accelerator.

> I agreee FPS is allways better in 3d

Are you talking of the kind of view, or the technic used to display the sprites? I thought we were talking of the second one...

> Thats why me an my team are doing a RTS in 2D using DirectDraw, and very little (up to none 3D acceleration). Forceing games into 3D is not allways a good thing...its only good for advertise and
hardware sales.

.. or you can use hardware for special effects. There is a thread on another board of a guy trying to improve his Ddraw alpha-blending function. Blending the whole screen he''s getting 1 fps. Make your life easier! Use 3d, and have the pleasure to see your program run at 150 fps!

> Why the hell my super 3D card CAN NOT do a SIMPLE 2D Alpha Blending? Answer is: because THEY dont want u you to!

What sort of answer is that? Even 4 or 5 years old cards such as a Vaudoo can do many alpha blending functions at light speed (compared to software).

> actually all 3D card are 2D accelerators.

Agreed, so what''s the point of developping your own software routines?

To me, unless you are doing something extremely specific, this is as programming a software 3d engine only, while everything can be hardware 3d accelerated.

> Also i find it stupid that 3D cards use and enforce a single algorithm for 3D render: scanline triangle fill variations

Well, you are right. If you want to write a raytracer, it''ll be faster with your own functions, but this is an extreme case. I couldn''t think of any commercial 2d game (you mentionned a few ones) that wouldn''t benefit from hardware acceleration.

Y.

Share this post


Link to post
Share on other sites