Jump to content
  • Advertisement
Sign in to follow this  
toan1982

Get a texture and paste to a buffer

This topic is 4630 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 render 3d object on a window (have animation for object and use DirectX SDK). 1.i want to get a texture from render at a point the app was running. 2.after that i want to copy this texture to a buffer (have type is BITE) 3.load this buffer to graphic card. How to do those task? Thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
I think you might be referring to Render-To-Texture.
Render to texture basically is rendering of a scene (your object) to a render target (texture). You can then use this texture after you have rendered to it to display it or save it or do whatever you want with.


The simple steps to follow.
C# and Managed DirectX Example (for readability)
1) Create a Surface and Texture to render to
i.e.

private Surface surface;
private Texture texture;



2) You will then create your render target and get the surface level of the
texture
i.e.

texture = new Texture(renderer.Device, 128, 128, 1, Usage.RenderTarget,
Format.X8R8G8B8, Pool.Default);
surface = texture.GetSurfaceLevel(0);



3) You are now ready to render to texture and it's very simple.
All you need to do is save the old render target (backbuffer), set the new
one
(yours) and render the scene. You will then replace the old backbuffer
i.e.

Surface oldRenderTarget = renderer.Device.GetRenderTarget(0);
renderer.Device.SetRenderTarget(0, surface);
renderer.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black.ToArgb(), 1.0f, 0);
//render your scene (BeginScene, EndScene)
renderer.Device.SetRenderTarget(0, oldRenderTarget);



4) Now you can use that texture where ever you want.

I hope this helps.
Take care.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!