Jump to content
  • Advertisement
Sign in to follow this  
Pianka

[.net] Direct3D Surface Transparency

This topic is 4076 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!