Sign in to follow this  
CLoudius

[MDX]Draw Surfaces onto other Surface possible?

Recommended Posts

Is it possible in Direct3d to draw a surface onto another surface? I want to fake transparancy in Direct3d and I hope this is possible this way. I have tried using something like this. It works but is slow. protected Texture FromBitmap(Device device, Bitmap bitmap) { Texture texture = new Texture(device, bitmap.Width, bitmap.Height, 1, Usage.Dynamic, Format.A8R8G8B8, Pool.Default); GraphicsBuffer a = texture.Lock(0, new Rectangle(0,0,bitmap.Width, bitmap.Height), LockFlags.None); int pitch = a.Pitch; //Microsoft.DirectX.GraphicsStream a = texture.LockRectangle(0, LockFlags.None, out pitch); System.Drawing.Imaging.BitmapData bd = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); unsafe { byte* to = (byte*)a.DataBufferPointer; byte* from = (byte*)bd.Scan0.ToPointer(); for (int y = 0; y < bd.Height; ++y) for (int x = 0; x < bd.Width * 4; ++x) to[pitch * y + x] = from[y * bd.Stride + x]; } texture.Unlock(0); bitmap.UnlockBits(bd); return texture; } Please help me.. Greetz, Cloudius

Share this post


Link to post
Share on other sites
You need to make sure that your destination surface is a render target. Than you can use SetRenderTarget to select this surface and draw anything you want to it.

To create a render target surface you can use the CreateRenderTarget method or in the case you need this surface later as a texture you have to use D3DUSAGE_RENDERTARGET as usage flag. Remember that all render targets need to create in the default pool.

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