• Advertisement

Archived

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

2D in DX

This topic is 5156 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I need to know how to do 2D graphics in DirectX. There is no DirectDraw any more (even in the docs), so do I do it with D3D? Why did Microsoft abandon DDraw, 2D graphics are used a lot?

Share this post


Link to post
Share on other sites
Advertisement
They didn''t get rid of it per se. They folded it into Direct3D. Now you create quads and texture them with your sprite and then display them on the screen.

If you want you can always use the DX7 interfaces with the latest SDK, but not if you are going to use the D3D interface, MS recommends not mixing and matching different version of the interfaces.

Share this post


Link to post
Share on other sites
It's not abandoned. It's just deprecated. The ddraw.lib file still ships with directX 9 for backwards compatibility. You can use it, but D3D does have some functions built in that are similar to DirectDraw, even easier than DirectDraw. I would recommend using them. I'm at work right now or I would provide some further details, I'll try when I get home. In the mean time, look up information on using Sprites(ID3DXSprite) and surfaces in D3D.

Good luck,
Chris

[edited by - Supernat02 on January 13, 2004 3:23:33 PM]

Share this post


Link to post
Share on other sites
Building on Chris''s statement. I am sorry thought you just wanted a small answer. But if you are going to use what he stated look up.

D3DXCreateTextureFromFile(...)
D3DXCreateSprite(...)

This will have you blitting to the screen. They are helper functions part of the D3DX library that exists outside of DX but I find them helpful, so long as you are not making a top of the line Doom3 killer game. Also I believe it only supports JPG, BMP, TGA, PNG, and DDS you will have to look in the docs to get a more accurate list.

Hope this helps you some more!

Share this post


Link to post
Share on other sites
you can still get documentation for directdraw in the MSDN library archive... it''s way at the bottom of the list in the MSDN library.

what I did was surf around Microsoft''s website for like a whole half-hour looking for the DX7 SDK just so I could get the docs on my harddrive and not be at the mercy of MSDN. The best I could do was the DX7a SDK but that''s good enough. You can get it here.

Share this post


Link to post
Share on other sites
quote:
Original post by TempusElf
you can still get documentation for directdraw in the MSDN library archive... it''s way at the bottom of the list in the MSDN library.

what I did was surf around Microsoft''s website for like a whole half-hour looking for the DX7 SDK just so I could get the docs on my harddrive and not be at the mercy of MSDN. The best I could do was the DX7a SDK but that''s good enough. You can get it here.

The DX9 Extras download includes docs for DX7.



Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
quote:
Original post by DrunkenHyena

The DX9 Extras download includes docs for DX7.




oh cool... good to know... I hope they keep providing the docs for DD

related question:
if I use only directdraw but compile with the libs and header files that came with DX9, what''s the runtime requirement for my game, DX7 or DX9?

Share this post


Link to post
Share on other sites
thanks for being helpful, guys
i''m not familiar with D3D, but i dont like the fact that a simple 2d sprite that should get blitted has to be treated as a texture, applied to a 3d quad. why do MS always make simple thing boring to write, and we always have to write like a hundred lines of init just to do a BitBlt.
whatever

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
the answer lies with the hardware, not really with microsoft.

In the days when DD was introduced, 2D cards had blitting engines. Now, they are built around vertices and textures. Yes, the API could hide that from you, but why?

the blitter paradigm doesn''t really mesh well with the idea of alpha blending, polygonal regions, overlapping z values, etc. etc. etc. Overall, it''s better for you if they don''t try to shoehorn old concepts on top of new capabilities.

Share this post


Link to post
Share on other sites
quote:
Original post by TempusElf
if I use only directdraw but compile with the libs and header files that came with DX9, what''s the runtime requirement for my game, DX7 or DX9?


You''ll be linking with the DX7 libraries and including the DX7 headers, so you''re game will require DX7.


Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
Just because DirectDraw isn''t in development still, that doesn''t mean you can''t use it. Since DircetX uses the COM architecture, you''ll always be able to use it by making calls to DirectDraw7. (Even if you''re using DirectX 9 or 8 or whatever you can still use functions from DirectX 7.)

Share this post


Link to post
Share on other sites
You said you didn''t like having to use the 3D stuff when you could just use the 2D stuff, but in my humble opinion, once you see the difference (i.e. 1000 lines of code to initialize directdraw, 50 lines of code to initialize Direct3D, and very simple interfaces to use once you get the hang of it), I think you''ll be whistling a different tune. Give it a try, you''ll probably like it!

Chris

Share this post


Link to post
Share on other sites
quote:
Original post by Supernat02
1000 lines of code to initialize directdraw,


you must be exaggerating? My function that initializes DD is only 70 lines long and most of that is the standard windows init stuff. It takes only 30 lines for me to init DD, set up the primary surface and back buffer and that includes empty space lines, comments, and lines that only have braces on them.

the other thing that requires a lot of code is loading images. But that''s only because I opt not to use helper functions. I don''t think that should count toward initializing lines because I''ve noticed that without helper functions, it also takes a lot of code to load images/textures in Direct3D and OpenGL.

Share this post


Link to post
Share on other sites
I''m exagerrating to an extent, but I''m also including checking device capabilities, setting up a clipper, changing the display mode to what the user requests, catching errors, resetting everything when the window loses focus, and other things that would be required in a game, all of which is implemented in a modular way...so it is a lot of code for me.

When I was doing direct draw, there was no load from file function included (that I could find). There was no copy from here to there included (that I could find). All of that was manual, without downloading third party functions, which I just don''t like to do. So that affects part of what I consider as more code. I should have said direct draw in general, not just the initialization.

I''m just thinking back when I used direct draw before and realizing that it is indeed easier to use D3D now. That''s my only point, whether it takes a thousand lines of code or not doesn''t matter much. It is easier to me, and I think Vic will find it easier in the long run. It will help him get into D3D, which he''ll probably start to work with afterwards anyway.

Good luck,
Chris

*Life is like the rock in a sling-shot. Pick a good target, take good aim, and get there as soon as possible!*

Share this post


Link to post
Share on other sites
Its not so much what is easier or what is better, but what your wanting the requirements to be for your application.

If your targeting low end systems, because your application will not use any 3d or the effects that using D3D can give 2d engines, then you should definately use DirectDraw.

However, if you want your application to be only useable to those with 3d accel, then its better to move on with technology and get used to doing everything graphical 2d and 3d in Direct3D (DirectGraphics).

As for ease of use, I find both very easy to use, especially if you use the file ddutil.cpp and ddutil.h. It encapsulates the whole DirectDraw thing, or you can make your own like I did.

I dont believe you can use both DirectDraw and Direct3D in the same app, so keep that in mind.

Share this post


Link to post
Share on other sites

  • Advertisement