Archived

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

SikCiv

D3DX 3d objects over a DDraw 2D background possible?

Recommended Posts

Ive implemented D3DX in my proggy, with 2D drawing the backgrounds. but when i blit 3D objects/sprites, it wipes the 2D background because the 3D side clears the screen. Im sure there is a way to use both for each frame, how do i do it? Im thinking I need to blit all the 2D stuff to a single surface, then blit that surface as a 3D sprite, but doing this slows down the frame rate as blitting a whole 640480x16 3D sprite takes alot of fire power. Maybe i need to tell D3DX somewhere not to clear the 3D rendering surface? Is there a good tutorial on D3DX somewhere?

Share this post


Link to post
Share on other sites
What do you mean with 'the 3D side clears the screen'?

It shouldn't be a problem to do this:



RenderFrame()
{
pD3DXContext->Clear(D3DCLEAR_TARGET/D3DCLEAR_ZBUFFER);


// Do some 2D blitting


hr = pD3DDevice->BeginScene();
if( SUCCEEDED(hr) )
{
// Render the 3D part


pD3DDevice->EndScene();
}


// Show the whole frame
pD3DXContext->UpdateFrame( 0 );
}


(I have removed some of the error testing to make it easier to read)

Edited by - Spellbound on 4/3/00 3:12:16 AM

Share this post


Link to post
Share on other sites

hiya

i guess ur problem is that u call D3DX.Clear... try not to clear the render target, just the Z Buffer... or u can can call Device7.Clear that accepts a list of dirty rectangles.

hope that helps

Paco

Share this post


Link to post
Share on other sites
Just an added note, and you all may know this anyway but for anyone else''s sake: D3D docs state you should not mix 2D and 3D processing. Or better said "manually" blitting such as you do in Direct Draw with vertices and such that you do in D3D. If you want to emulate things like flat 2D backgrounds, HUDs, or whatever try doing it with D3DTLVERTEX. That will allow you to define where on the screen your quasi 3D background will be. Also other "flat" objects in 3D space are easy, check out MS''s Billboard demo in the 7.0 SDK. Its a great example.

The cost of not using 3d vertices to do your 2d stuff is a large performance penalty. The exact reason behind this is a little beyond my current expertise (perhaps someone here can enlight us more on that) but as I understand it going to 2D causes the driver/video card to have to change state/processing/whatever to accomdate the request. The resulting change causes a flush of all the data hence bad performance. I even read a suggestion going as far as recommending you make your mouse cursor a 3d object (a flat one of course).

Sieggy

Share this post


Link to post
Share on other sites