Skip to main content
gamedev.net
🔒 Locked

Render Target ,how to....

Started by Aragon Jan 1, 2003 at 3:49 PM 2 replies 450+ views
Original Post
Aragon
Aragon
its me and my problem again... a lot of people here say i have to render to an texture than copy backbuffer to an texture( what i never get to run) now i try to use setrendertarget and use some code of the cubemap demo of sdk 8.1 and there is my problem how can i render to an single (not cube) texture can you give me a little example, because i dont know where to start like void createtexture(void) { ...create texture ...create depth stencil.. return; } void rendertotexture(void) { ..lalala i dont know what to write here m_d3ddevice->BeginScene(); RenderScene(); m_d3ddevice->EndScene(); return; (to main loop) } if in main rendering scene this texture work i will be happy
Drakkor
Drakkor
Well it sounds like you are trying to render a scene to a texture... if so this is how I do it...

1. Create a texture using CreateTexture(...)
2. Get the surface level of the texture using (GetSurfaceLevel(...)
3. Set the render target to that surface level using SetRenderTarget(...)
4. BeginScene()
5. RenderScene()
6. EndScene()
7. Set the render target back to your back buffer using SetRenderTarget(...) again

Now whatever you rendered will be on the texture and you can apply it to a primitive like normal.

D
Aragon
Aragon
thx for the
i find some
intresting code at the water demo
on the sdk,

there is only one what i didnt understand:

the texture i get looks like large x lines

like this
__ _ _ _____ _ \___ ___ _ _ _
__ _ _ _ _ - \ _ - -- -_- ---
--_ _-- _-- - _ \ -- - _ - - -
- -- - _ _ -- - _ \_-- - - _ _ _


i take the same code like the water demo
(texture creation section
& drawing section
BeginScene...
->(using my own graphics in the middle)
EndScene
Aragon
Aragon
now i see clear what the texture try to show me,

it look''s like hundrets of samples of my
other game textures (some in mipmap lines)


very strange...

Topic Locked

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

Sign in to reply to this topic.