• Advertisement
Sign in to follow this  

[MDX]Draw Surfaces onto other Surface possible?

This topic is 4331 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

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
Advertisement
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
Sign in to follow this  

  • Advertisement