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

Render a mesh on a texture

Started by BlueChip Jun 10, 2003 at 10:04 AM 4 replies 750+ views
Original Post
BlueChip
BlueChip
Hi to all... Someone can tell me how can I render a mesh on a texture? I think that I must do in this way:
LPDIRECT3DTEXTURE9 destTex; 
LPDIRECT3DSURFACE9  destSup;
LPDIRECT3DSURFACE9  ts2=NULL;

D3DXCreateTexture (device,h,w,0,D3DUSAGE_RENDERTARGET,D3DFMT_UNKNOWN,D3DPOOL_DEFAULT,&destTex);
destTex->GetSurfaceLevel(0,&destSup);
m_pd3dDevice->SetRenderTarget(0,destSup);
Then?? I should do 1)render the mesh on destSup.... 2)Set old render target... 3)to use my new texture destTex.. I''ve forgot something? and can you teach me how do I do?
S1CA
S1CA
That looks ok.

Depending on what the texture represents, you might also want to change the current projection and view matrices as well as the current viewport (if the texture has different dimensions to your back buffer).

Also you''ll probably want to Clear() the render target surface before you render to it.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
BlueChip
BlueChip
I would test a Yann L. idea (perhaps this idea isn''t of Yann, but I''ve read it in his post)...

I want change 3D trees in 2D billboards when they are far...
but I wouldn''t use same 2d sprite, but a snapshot of the far tree...

In this last hours I''ve try ... and I''ve write this code:


LPDIRECT3DTEXTURE9 tex;
LPDIRECT3DSURFACE9 surfaceMaps;
LPDIRECT3DSURFACE9 stencil,old;

m_pd3dDevice->GetRenderTarget(0,&old);
m_pd3dDevice->GetDepthStencilSurface(&stencil);

D3DXCreateTexture (m_pd3dDevice,256,256,0,D3DUSAGE_RENDERTARGET,D3DFMT_UNKNOWN,D3DPOOL_DEFAULT,&tex);
tex->GetSurfaceLevel(0, &surfaceMaps);
m_pd3dDevice->SetRenderTarget(0, surfaceMaps);

m_pd3dDevice->BeginScene();
m_pCMeshtree->Render(); <---- =) this is my mesh
m_pd3dDevice->EndScene();

m_pd3dDevice->SetRenderTarget(0, current);
stencil->Release();
surfaceMaps->Release();
current->Release();


but this give me 2 problem:
1)The texture is black o_O
If I understand it, I''ll use it for shadow ^__^
2)The texture is drawed.... but there isn''t the command
m_pd3dDevice->SetTexture( 0, tex);

Can you help me ??? =)
Thanks ....

Now I go to do other test =)
byezzzzzzzzzzzzzzzzzzzz
BlueChip
BlueChip
Noone have these problems?
or had these problems?


BlueChip
BlueChip
No... this is the same code that I use with other textures...

Topic Locked

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

Sign in to reply to this topic.