[solved] Render to a texture
How do I render the scene to a texture?
[Edited by - ReaVeR-Andrey on July 25, 2005 7:54:09 AM]
What is it you're really trying to do? Do you really need to render to a texture, or are you thinking that's the way to accomplish something specific? Maybe there is another way to do it.
Although, rendering to a texture does sound kind of cool
Although, rendering to a texture does sound kind of cool
1) Create a texture that can be used as a render target:
LPDIRECT3DTEXTURE9 texture = NULL;
pd3dDevice->CreateTexture(size.x, size.y, 1, D3DUSAGE_RENDERTARGET, A8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
2) Set that texture as render target:
pd3dDevice->SetRenderTarget(0, texture);
3) Render something (shaders or fixed function)
You can then restore the original "default" render target by passing null to SetRenderTarget and you can then set "texture" as a source texture for future renderings.
Hope this helps
- Kasper
LPDIRECT3DTEXTURE9 texture = NULL;
pd3dDevice->CreateTexture(size.x, size.y, 1, D3DUSAGE_RENDERTARGET, A8R8G8B8, D3DPOOL_DEFAULT, &texture, NULL);
2) Set that texture as render target:
pd3dDevice->SetRenderTarget(0, texture);
3) Render something (shaders or fixed function)
You can then restore the original "default" render target by passing null to SetRenderTarget and you can then set "texture" as a source texture for future renderings.
Hope this helps
- Kasper
Ah, sorry - you cannot restore the original render targets by passing NULL (this is only the syntax I've used for my own wrapping of D3D). You have to get a hold of the current render target before setting the texture render target:
LPDIRECT3DSURFACE9 primarySurface;
pd3dDevice->GetRenderTarget(0, &primarySurface);
Then re-set "primarySurface" once you're done rendering into the texture
- Kasper
LPDIRECT3DSURFACE9 primarySurface;
pd3dDevice->GetRenderTarget(0, &primarySurface);
Then re-set "primarySurface" once you're done rendering into the texture
- Kasper
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement