Skip to main content
GameDev.net gamedev.net
🔒 Locked

Problem with D3DXSaveTextureToFile

Started by pcostasgr Jan 17, 2008 at 1:21 PM 2 replies 3.1k views
Original Post
pcostasgr
pcostasgr
I am trying to create a post effect, and I have to following problem ,if I use D3DXSaveSurfaceToFile I have the correct screenshot of the screen but when I use D3DXSaveTextureToFile nothing is rendered the code is the following //create texture and surface D3DXCreateTexture( gd3dDevice, screen_w/2, screen_h/2, 1, D3DUSAGE_DYNAMIC , D3DFMT_A16B16G16R16, D3DPOOL_DEFAULT, &g_PreTexture ); g_PreTexture->GetSurfaceLevel( 0, &g_pPreSurface ); ..render code gd3dDevice->BeginScene(); .. // I call a function which is doing the grabs the render target RenderPost(gd3dDevice); gd3dDevice->EndScene(); then in RenderPost(IDirect3DDevice9* device){ device->GetRenderTarget(0, &g_pPreSurface); D3DXSaveSurfaceToFile("imageSurf.jpg",D3DXIFF_JPG,g_pPreSurface,NULL,NULL); //OK D3DXSaveTextureToFile("imageTex.jpg",D3DXIFF_JPG,g_PreTexture,NULL) //show strange thing -artefacts Any ideas I am really stuck ,I think that the problem has to do with the flags in the texture creation .I have to mention that I used it before when I needed to create a shadow map and it worked without problems!!! Any help appreciated
Dave Hunt
Dave Hunt
GetRenderTarget is replacing your g_pPreSurface pointer with a pointer to the render target surface, so it's no longer associated in any way with your texture. Why do you need the texture if saving the surface works anyway?
pcostasgr
pcostasgr
greedings and thanks for the answer .The point with the texture is that I want to pass it to a shader and I need to know what was captured by the surface pointer.
Thanks
ET3D
ET3D
I think that Dave Hunt is right on the money. Try saving without GetRenderTarget. Or, better yet, try using SetRenderTarget to make sure you're rendering to the texture's surface.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.