I use
if(FAILED(g_pd3dDevice->CreateTexture(512 , 512 , 1 , D3DUSAGE_RENDERTARGET , D3DFMT_A8R8G8B8 , D3DPOOL_DEFAULT , &g_pRenderTexture , 0)))
to create a texture, then render the scene to it.
windows is:
HWND hWnd = CreateWindow("Render to Texture" , "Render to Texture"
, WS_OVERLAPPEDWINDOW , 0 , 0 , 640 ,480 , GetDesktopWindow()
, 0 , wndClass.hInstance , 0);
But the result is wrong.The scene is not rendered right.
But if I change the texture's width and hight to 256,256,
or increase window's width and hight more than 512 ,for example 1024,560,
the result is right.
How to explain this?
Render to texture
What do you mean it's "wrong"? Can we get a screenshot?
What size is your backbuffer in your D3DPRESENT_PARAMETERS?
What size is your backbuffer in your D3DPRESENT_PARAMETERS?
your depth buffer surface has to be same size (or larger) as your render target!
i bet that you are using default depth buffer:
witch creates default depth buffer with size: 640x480
create another depth buffer surface and use it along with your rt:
i bet that you are using default depth buffer:
PresentParams.EnableAutoDepthStencil = TRUE;
witch creates default depth buffer with size: 640x480
create another depth buffer surface and use it along with your rt:
dev->SetRenderTarget(0, yourRT);dev->SetDepthStencilSurface(yourNewDepthBuffer);dev->Clear(...);
when testing your projects always enable d3d debugging:
and use dx control panel.
#define D3D_DEBUG_INFO // define at top...#include <d3d9.h>#include <d3dx9.h>#pragma comment (lib, "d3d9.lib")#pragma comment (lib, "d3dx9d.lib")
and use dx control panel.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement