• Advertisement

Archived

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

Using both Direct3D and DirectDraw together

This topic is 5489 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

Hello, I want to render my world in Direct3D, but I want to draw my inventory, map, etc in DirectDraw (it''s all 2D). Is it possible (like DirectDraw drawing a map on top of Direct3D) and if so, can anyone point me in the right direction about how to do it. If not, could someone suggest another route to check?

Share this post


Link to post
Share on other sites
Advertisement
By the mere knowledge that you are referring to Direct3D and DirectDraw in the same sentence, I''m presuming you''re using DirectX 6 or 7. Knowing that, I can help you.

Look at your initialization code. A Direct3D "device" simply renders to the DirectDraw "Backbuffer" surface. All you have to do is do your own standard DirectDraw blitting to that same backbuffer.

Keep in mind, under DX7, that you can get some interesting and undefined behaviour if you forget to Device->BeginScene() and Device->EndScene(). However, you can do your DirectDraw blitting at any point in time, in or out of the Begin/EndScene block.

Share this post


Link to post
Share on other sites
quote:
However, you can do your DirectDraw blitting at any point in time, in or out of the Begin/EndScene block.


Really? But in the DirectX7 SDK they mention this:

quote:
Do not attempt to call GDI functions on DirectDraw surfaces, such as the render target or textures, while a scene is being rendered (between BeginScene and EndScene calls). Attempts to do so can prevent the results of the GDI operations from being visible. If your application uses GDI functions, be sure that all GDI calls are made outside the scene functions


And isn''t DirectDraw, especially in windowed mode, a wrapper for the GDI?

I hope I''m wrong, since that would make my life a lot
easier. Since my game is using Direct3D to render blended
particles in a 2D environment.

Thanks in Advance,
Tristan

Share this post


Link to post
Share on other sites
hes right -- just make use of the direct draw surface you already have
ddraw and d3d were coupled back before they spawned dxgraphics

Share this post


Link to post
Share on other sites
I guess I should have said the version hehe

Im planning on using Direct3D 8 and DirectDraw.

Does it still apply?

Share this post


Link to post
Share on other sites
Hey,

Don''t bother with DDraw, it is too old. Just use the SPRITES. There are a host of cool functions in D3DX such as D3DXCreateSprite. Have a look through the MSDN for the related functions.

I used it for my sidepanels in an RTS and it looks great.

Doolwind

Share this post


Link to post
Share on other sites
Cool thanks

If I have any other questions, I''ll post back.

This could work

Share this post


Link to post
Share on other sites
quote:
Keep in mind, under DX7, that you can get some interesting and undefined behaviour if you forget to Device->BeginScene() and Device->EndScene(). However, you can do your DirectDraw blitting at any point in time, in or out of the Begin/EndScene block.


But not on a scene capture card (e.g. any of the PowerVR range) which will define the "NO2DDURING3DSCENE" cap flag to tell you that doing this is BAD. On scene captre cards you get things like square blocks instead of textured polygons, missing blits etc if you try to do that.

Mixing 2D blits which went to the same destination as the 3D in the same frame was bad on MOST cards anyway because all the drivers only expect to be doing one thing or the other, not mixing them.


quote:
And isn''t DirectDraw, especially in windowed mode, a wrapper for the GDI?


NO, DirectDraw isn''t a wrapper for ANYTHING apart from the device driver for the video card. Most of GDI is actually software based rather than accelerated. There are parts of GDI which also talk direct to the video card driver. And DirectDraw has to be aware of what GDI is up to, but they''re not linked at all.


At the end of the day though I''d say: if you need to mix 2D and 3D, do your 2D in Direct3D unless you have a *very* good reason not to. Hardware manufacturers haven''t payed any attention to the 2D side of their chips for years now - 3D is all that matters, so on some chips you''ll find that what you think is 2D is really **emulation** taking place in the driver and your 2D blits are really actually textured polygons. Examples: "haloes around colour keying because the driver is really using bilinear filtered quads with alpha blending", "blurred stretch blits, again because the driver is really using bilinear filtered quads"...

Doing the textured polygons yourself means you have more control over what gets done AND more cool features to play with.


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites

  • Advertisement