• Advertisement

Archived

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

Mixing DD and D3D

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

Is it perfectly ''legal'' to use DD functions like BltFast and Blt on a D3D rendering surface between the BeginScene and EndScene function calls when working with D3D IM? I''m using BltFast to draw a fullscreen background and then I am using DrawIndexedPrimitive to draw polygons over it. It seems kinda strange at first, but it works. Rasta

Share this post


Link to post
Share on other sites
Advertisement
Yes, you can use them together just fine. But I think there is somewhere in D3D that lets you setup a default background, so that you dont have to use ddraw for just that. But I don''t remember where it is

One person said that the games industry is "a transfer of funds from the rich to the lucky"

Share this post


Link to post
Share on other sites
I''ve read somewhere that it''s legal. I''m blitting a sea/sky background, overlaid by 3d terrain, then a 2d cockpit blit in my flight sim attempt. This back buffer is then flipped to the foreground surface. BTW surfaces are nothing more than bitmap images (non-inverted).

Share this post


Link to post
Share on other sites
I was just wondering if this is the standard way of putting up
a fullscreen 640x480 background, or am I in trouble of corrupting
the D3D rendering pipeline somehow?

Actually, I did try putting it up as a texture at first, but
I quickly found out the dimensions of textures need to be in
powers of 2 (is this correct?) and the background came out
looking pretty bad.

Just now, I took the blitting of the background part out of
the BeginScene and EndScene section, and placed it immediately
before it and it still works.

Rasta

Share this post


Link to post
Share on other sites
Yeah, they need to be powers of 2. I wouldn''t use textures because as the size gets bigger (around 256x256), D3D starts slowing down.

"When people tell you they want to hear the truth, you know that their lying."

Share this post


Link to post
Share on other sites
I found this bit of advice on another site:

Typically your main loop for an individual render target should be:

Clear Z Buffer/Render target (if required)
Any background 2D
Begin Scene
3D Rendering
End Scene
Any foreground 2D
Flip

Which seems like a good way to set things up in my case.

Rasta

Share this post


Link to post
Share on other sites
In Awsome Power of Direct3D it says that it is forbidden operation to blit between the BeginScene and EndScene functions calls.

Gandalf the White

Share this post


Link to post
Share on other sites
The loop above works fine for me. The APofD3D (page 340) simply says to complete the 3D layer before overlaying 2D - it doesn''t preclude mixing 2D and 3D. It also indicates that you can access a surface as a window using GetDC() and Lock(), etc. I''ve used this to overlay text and a few simple graphics from the windows GUI.

Share this post


Link to post
Share on other sites
I''ve had trouble using blits with direct3d. I tried it in tons of different places, and never seemed to work. I''ll have to go back and take another look at it.

The blits would go through without an error, but nothing would show up, and it used to work fine before I converted to D3D. But I must''ve set something up wrong.

Share this post


Link to post
Share on other sites
I experimented with this quite a bit when I was working on the D3D tiles article. The loop described by Rasta was the one I found that worked reliably. A word of warning, though - if you load bitmaps into system memory, there are sometimes some odd effects when you are using D3D''s texture management system. D3D isn''t as smart as it could be, sometimes!

Share this post


Link to post
Share on other sites
Potsticker, I've had the same problem, but only in windowed mode. No matter where call the Blt or BltFast function (usually after the map is drawn and endscene is called), it never shows on screen (although I believe that the Blt functions actually return a fail code). If I switch to fullscreen mode, both Blt and BltFast work great.

For anyone who has gotten this to work in windowed mode, I'd really appreciate it if you could send me some source code, so I can see where my mistake may be.

Houdini
rgeiman@flashcom.net

Edited by - Houdini on 3/17/00 2:02:32 PM

Share this post


Link to post
Share on other sites
!!
In DirectxSDK there is said, that for performance reasons you should avoid mixing 2d and 3d operations, so rendering two triangles at near z clipping distance with cockpit image as a texture should generally be much faster. if you need any changing graphics ( gauges, stuff like that) try creating texture as a system memory surface, render cockpit image on it, and then as a last operation before closing the scene render 2triangles. It should still be faster than blt. in SDK there is also info how to get precise texel-pixel mapping, so every texel covers one pixel on render target.
(i havent tried blt on d3d render target myself, so i dont know if its really any faster or not, but im using aforementioned technique to get half-transparent cockpit)

-kertropp

Share this post


Link to post
Share on other sites
I think you''re right about that Kertropp, but it gets tricky when you need big surfaces/textures. I''ve heard that D3D gets a big performance drop with any textures bigger than 256x256. Not that I notice it, but I do have a Geforce card too...

I''m going to use a DirectDraw tile function to draw a map and D3D to create effects like fog, explosions, clouds and so on. I''m just worried it won''t be such a good combination. But using D3D drawing tiles would be hard, since my tile surfaces are 640x480, they won''t make good textures.

============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown

Share this post


Link to post
Share on other sites
If the worst comes to the worst, use TLVERTEX (ie. ones in which you specify the final destination) rather than messing with the Z value to place your D3D triangles. Textures above 256x256 (or even around that) cause problems - but nothing stops you from splitting the image into more than one texture if its reasonably static. For that matter, with modern rendering speeds, you might as well use a few trianges to include all the elements of your UI.

Share this post


Link to post
Share on other sites
I don''t know much about D3D yet, but I believe that is exactly why the D3D render target is also a DirectDraw surface -- so you can treat it as both a render target and a drawing surface. There may be a few IDirectDrawSurface function calls that you have to watch out for while you''re in the BeginScene()/EndScene() functions.

Although I''m a beginner, I wouldn''t think there''s anything to worry about -- rendering 3D is a one-way operation. After it''s plotted the pixels, D3D doesn''t care what you do with the surface. It uses math to figure out where to place things and how to shade; D3D doesn''t need to read the pixel data of a surface to see how it turns out. (That''s your job )

Check out the SDK for the functions you want to use -- if there''s a NOTE: Cannot use certain D3D functions while... or an DDERR_CANNOTUSED3DWHILE... or something obvious like that, I wouldn''t use it then. If you look hard, and there isn''t an obvious note in there, I''d use it. The SDK writers wouldn''t leave out something that important!

Good Luck!


- null_pointer

Share this post


Link to post
Share on other sites

  • Advertisement