Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


#ActualStarkman

Posted 11 January 2013 - 08:40 AM

hi

i want to capture my Backbuffer into LPDIRECT3DSURFACE9 and then copy the surface into IDirect3DTexture9 finally use texture as my 3dobject skin . i wrote the codes but just received black pixels.it seems im wrong way on filling texture by surface .

 

Thanks for your help

 

 

IDirect3DTexture9* texture;
LPDIRECT3DSURFACE9 pd3dsBack = NULL;
 
void init() 
{
 
D3DXCreateTexture(g_pd3dDevice,640,480,D3DUSAGE_DYNAMIC,
0,D3DFMT_X8R8G8B8,D3DPOOL_DEFAULT,&texture);
 
}
 
void render() 
{
 
//scene (1)
g_pd3dDevice->BeginScene();
 
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 
                         D3DCOLOR_COLORVALUE(0.0f,1.0f,0.0f,1.0f), 1.0f, 0);
 
//my 3d objects codes for draw into scene (1) .
 
g_pd3dDevice->EndScene();
 
//now try to get back-buffer into surface
 
g_pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pd3dsBack)  ;
 
//i add this Save section to ensure the backbuffer data received complete and work.(it was ok and save complete true picture of Scene(1) ).
D3DXSaveSurfaceToFileA("BackbufferImage.BMP", D3DXIFF_BMP,pd3dsBack, NULL, NULL);
 
 
//this line fill the surface into texture ; if u think this way is false please give me a simple code to fill texture by surface.thanks 
 
texture->GetSurfaceLevel(0, &pd3dsBack);
 
pd3dsBack->Release();//release my surface
 
 
//scene(2)
    g_pd3dDevice->BeginScene();
 
     g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 
                         D3DCOLOR_COLORVALUE(1.0f,0.0f,0.0f,1.0f), 1.0f, 0);
 
//now render my scene(2) and useing the texture object for draw it as skin of my 3d     object
g_pd3dDevice->SetTexture( 0, texture );
 
g_pd3dDevice->EndScene();
 
 
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
 
}

#1Starkman

Posted 11 January 2013 - 08:36 AM

hi

i want to capture my Backbuffer into LPDIRECT3DSURFACE9 and then copy the surface into IDirect3DTexture9 finally use texture as my 3dobject skin . i wrote the codes but just received black pixels.it seems im wrong way on filling texture by surface .

 

Thanks for your help

 

 

IDirect3DTexture9* texture;
LPDIRECT3DSURFACE9 pd3dsBack = NULL;
 
void init() 
{
 
D3DXCreateTexture(g_pd3dDevice,640,480,D3DUSAGE_DYNAMIC,
0,D3DFMT_X8R8G8B8,D3DPOOL_DEFAULT,&texture);
 
}
 
void render() 
{
 
g_pd3dDevice->BeginScene();
 
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 
                         D3DCOLOR_COLORVALUE(0.0f,1.0f,0.0f,1.0f), 1.0f, 0);
 
//3d objects scene (1) codes for draw.
 
g_pd3dDevice->EndScene();
 
//now try to get back-buffer into surface
 
g_pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pd3dsBack)  ;
//i add this Save section to ensure the backbuffer data received complete and work.(it was ok and save complete true picture of Scene(1) ).
 
D3DXSaveSurfaceToFileA("BackbufferImage.BMP", D3DXIFF_BMP,pd3dsBack, NULL, NULL);
//this line put surface into my texture ; if u think this way is false please give me a simple code to fill texture by surface.thanks 
 
texture->GetSurfaceLevel(0, &pd3dsBack);
 
pd3dsBack->Release();//release my surface
 
 
//scene(2)
    g_pd3dDevice->BeginScene();
 
     g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 
                         D3DCOLOR_COLORVALUE(1.0f,0.0f,0.0f,1.0f), 1.0f, 0);
 
//now render my scene(2) and useing the texture object for draw it as skin of my 3d     object
g_pd3dDevice->SetTexture( 0, texture );
 
g_pd3dDevice->EndScene();
 
 
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
 
}

 


PARTNERS