Sign in to follow this  

[.net] Direct3D Surface Transparency

This topic is 3861 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'm using a surface to render my cursor and I obviously want transparency. Here's my loading code:
Quote:
Cursor_Background = device.CreateOffscreenPlainSurface(100, 40, Manager.Adapters[0].CurrentDisplayMode.Format, Pool.Default); SurfaceLoader.FromFile(Cursor_Background, "cursor.bmp", Filter.None, Color.White.ToArgb());
My rendering function:
Quote:
public void DrawCursor() { Surface backbuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono); device.StretchRectangle(Cursor_Background, new Rectangle(0, 0, 16, 17), backbuffer, new Rectangle(mouse_x, mouse_y, 16, 17), TextureFilter.None); backbuffer.Dispose(); }
As you can see I want white to be transparent. Every tutorial I've found on this uses something called a ColorKey, which doesn't exist in my project or Surface class so I'm guessing its a DirectDraw version of the class. Any help or suggestions would be great, thanks!

Share this post


Link to post
Share on other sites
Well since CurrentDisplayMode.Format likely doesn't have any alpha channel your colorkey probably isn't doing anything.

I'm guessing you're coming from something similar to DirectDraw. In Direct3D drawing raw surfaces directly to the backbuffer isn't the best practice. You should look into using an orthograhic matrix along with the sprite interface and using textures to store images, it would definately be faster then your current method.

Share this post


Link to post
Share on other sites
I used sprites before and I ran into a serious problem when there were only a few on the screen, so I switched to surfaces instead. Can I change the format and have it allow alpha?

Share this post


Link to post
Share on other sites

This topic is 3861 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.

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