Jump to content
  • Advertisement
Sign in to follow this  
georgiaw

Blitting Transparent Bitmaps

This topic is 4550 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 have tried searching all over for a solution to this problem. I know it has been said several times that surfaces cannot be transparent, only textures, but here's the issue I'm running into: My tool's rendering is done in DirectX 9.0, so no DirectDraw, etc etc. I've been using the ID3DXSprite object up until now to draw the map texture and other widgets as needed, because I know I can keep track of them. The next portion of the tool I need to work on is painting areas. Right now developers are using Photoshop to paint these solid areas and export the information for the server from there. They want to use my tool, however, to expand their development options and management of the areas in a zone. The plan *was* to just blit a transparent bitmap of a circle in a solid color to simulate a 2D Brush, but when I saw I couldn't just draw these fake brushes with transparency without using the ID3DXSprite function, I panicked, because there's simply no way I could keep track of every drag of the mouse to make sure to redraw all of these at each frame. Is there a way to make the sprite draw to perhaps another backbuffer that *isn't* cleared each frame, that way it can persist in memory without me having to keep track of each circle drawn with the mouse movement?

Share this post


Link to post
Share on other sites
Advertisement
The back buffer won't be cleared each frame if you don't call Clear. You'll also want to make sure D3DSWAPEFFECT_DISCARD isn't set (I'm assuming you're running in windowed mode?).

You can also draw these brush strokes to an offscreen render target texture, then blend this with the back buffer as textured quad (or probably that D3DX sprite thing you're using). The texture should have an alpha channel and be initialized with an alpha of zero so that untouched pixels will be transparent when you blend this to the contents of the back buffer. See the docs for SetRenderTarget.

You should consider some sort of tracking of the drawing operations, if for nothing more than being able to reverse the effect of a drawing operation. I've never met an artist that could live without some sort of "undo" capability.

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!