Jump to content
  • Advertisement
Sign in to follow this  
bioM

integrate 3D window in another 3D window?

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

i am planing to integrate a 3D window as a part of another 3D screen window. My solution is that i use a texture in the target window to receive drawed data from the source window and invalidate it to the target window. My problem is that i don't know to to get the last texture from the source window before present to screen so that i can copy buffer to buffer and present to the target window. Any body can help me or having a better solution in this case?

Share this post


Link to post
Share on other sites
Advertisement
Let's see if I've got this right:

You want your scene that you are rendering in 3D to appear on a texture (eg. a in-game television or a surveillance-camera) If that is the case: take a look at SetRenderTarget in the IDirect3DDevice9 interface.

1. Change your render-target to a direct3d surface / texture
2. render your scene
3. change your render-target to the backbuffer
4. render the scene again

Share this post


Link to post
Share on other sites
thanks, some questions:
1. Change your render-target to a direct3d surface / texture
2. render your scene
3. change your render-target to the backbuffer
4. render the scene again

my understand from your comment is that at TASK 3, if i want to render the texture/surface to another 3D Window , i will copy this texture and render to coppied texture in the target window?

Share this post


Link to post
Share on other sites
i have tried your comment, it work but only with 2D quad, not with 3D object, meaning that i already drawed 3D object to the renderred texture but not appeared in when render the texture.
this is my code:
HRESULT hr;
hr = pd3dDevice->SetRenderTarget(0,pRenderSurface); //set new render target

//Begin drawing
pd3dDevice->BeginScene ();

pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );

pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

// check to make sure we have a valid Direct3D Device
if( NULL == pd3dDevice )
return;

// Clear the backbuffer to a blue color
//pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );

m_3dObject.UpdateTransform(0,0,0,1,0,0,0);
m_3dObject.Render();

RECT rDest;

rDest.top = 0;
rDest.bottom = 50;
rDest.left = 0;
rDest.right = 50;

int static rotateAngle =0;
rotateAngle=45;
Blit(textureTest, &rDest,rotateAngle*3.14/180);

//End drawing
pd3dDevice->EndScene ();



//render scene with texture
hr = pd3dDevice->SetRenderTarget(0,pBackBuffer); //set back buffer

//pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_COLORVALUE( 0.0f, 0.0f, 0.0f, 1.0f ), 1.0f, 0 );
pd3dDevice->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0);
pd3dDevice->BeginScene();


RECT rect;rect.left =50;rect.top =50;rect.right=400,rect.bottom = 300;
Blit(pRenderTexture, &rect,0.0f);

pd3dDevice->EndScene();

// Present the backbuffer contents to the display
pd3dDevice->Present( NULL, NULL, NULL, NULL );

Share this post


Link to post
Share on other sites
Hi there bioM,
How are you doing?

The Problem
How to render to texture?

The Solution
If you want a reference to work from, although not c++ it's a tutorial I wrote for the managed directx world and the same priniciples apply.

Render to Texture Tutorial.

What Metus has said is correct. So I would follow his advice for a general overview and the nitty, gritty stuff can be referenced using my tutorial.

Note:
1) You don't have to clear the target twice in your code as you are doing now.
Think of the target as a piece of paper. Once it's cleared it will stay cleared until you have rendered(Drawn) unto it.

2)What you might want to do is. Save the original back buffer in a surface. Then set your new render target (Texture) and render into that... Reset your back buffer to the original... etc...

I hope this helps buddy. Take care.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Another alternative would be to render to mulitple viewports, this will simiulate multiple cameras in your scene it will then work for a 3d object as well i get the impression this is what you want this would give you another view of you scene in a smaller (or larger viewport) depending on what you set the viewports parameters too. You could then encapsulate this into a camera class for easier management. this is info in the directx docos regarding this technique

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!