Blitting Transparent Bitmaps

Started by
0 comments, last by don 17 years, 10 months ago
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?
Georgia Wallhttp://www.fiercekitten.com/
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.

This topic is closed to new replies.

Advertisement