Sign in to follow this  

Get a texture and paste to a buffer

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
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

private Surface surface;
private Texture texture;

2) You will then create your render target and get the surface level of the

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
(yours) and render the scene. You will then replace the old backbuffer

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this