Jump to content
  • Advertisement
Sign in to follow this  

Render to texture

This topic is 2925 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 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?

Share this post

Link to post
Share on other sites
your depth buffer surface has to be same size (or larger) as your render target!
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);

Share this post

Link to post
Share on other sites
when testing your projects always enable d3d debugging:

#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.

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!