Archived

This topic is now archived and is closed to further replies.

Asim

Rendering to textures

Recommended Posts

Asim    122
I know this sort of thing has been asked plenty of times before but I still can''t seem to get it working. I''m trying to render to a texture but it doesn''t draw anything - I can clear the texture to any colour I want but can''t draw anything. Here''s the code I''m using. First create the texture and get a pointer to it''s surface... pDirect3DDevice->CreateTexture(256, 256, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &pTexture, NULL); pTexture->GetSurfaceLevel(0, &pTexSurface); I''m also using the following TSS... pDirect3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); pDirect3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); pDirect3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); pDirect3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_DISABLE); Then my render function contains... pDirect3DDevice->SetRenderTarget(0, pTexSurface); pDirect3DDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,0), 1.0f, 0); pBall->setMaterial(pDirect3DDevice); // set the material for the ball pObjectMesh->DrawSubset(0); // the ball''s mesh Later on in the function I use pDirect3DDevice->SetTexture(0, pTexture) to try to map the texture on to a cube but all I get is the colour I cleared the texture surface to and nothing else. What am I doing wrong? Asim

Share this post


Link to post
Share on other sites
Asim    122
Thanks for the tips (although they didn''t work!)

I''ve managed to solve my problem now - I couldn''t get it to work in the end so I just cheated and drew on a new surface and then used StretchRect to copy from that surface to the texture surface.

As long as it works...and don''t nobody start about efficiency, I''m working to a tight deadline here

Asim

Share this post


Link to post
Share on other sites