AlphaBlend and BlendFunction - dynamic opacity

This is a discussion on AlphaBlend and BlendFunction - dynamic opacity within the Windows Programming forums, part of the Platform Specific Boards category; I've got the formula working and the debugger is showing that I have the correct values each time. Trouble is, ...

  1. #1
    Math wizard
    Join Date
    Dec 2006
    Location
    USA
    Posts
    575

    AlphaBlend and BlendFunction - dynamic opacity

    I've got the formula working and the debugger is showing that I have the correct values each time. Trouble is, the transparency is not working.

    What I'm trying to do is get a color fade dependent on the current and maximum HP. At 50% remaining HP, the text is yellow. At 0% remaining HP, the text is red. For values between these, the text fades from red to yellow as HP increases (it's white above 50%). To accomplish this, I have it so that the red text is drawn first. The yellow text is drawn on top and it's the yellow text that has varying opacity. Both versions of the text uses a 32-bit TGA image and a custom-made font of my own (which leaves out TrueType fonts). I'm using AlphaBlend to do the drawing in all cases. This means I need the "BlendFunction" struct, of which I have filled out. The red text is drawn normally at full opacity. The problem comes from the yellow text. If I directly set the "SourceConstantAlpha" to 153 (to simulate 30% HP remaining), the text is still drawn as if it still was at 255.

    My question is, how do I get this fade effect without creating extra versions of the font for more colors? A simulation screenshot I made earlier shows what the effect should be like (note the bottom right corner).

    Edit: never mind, I found the problem - it was a copy/paste mistake causing the text to yellow in both cases instead of a separate yellow and red one. It's now working as I expected it.
    Last edited by ulillillia; 11-19-2009 at 05:00 AM. Reason: Problem solved - copy/paste error
    High elevation is the best elevation. The higher, the better the view!
    My computer: XP Pro SP3, 3.4 GHz i7-2600K CPU (OC'd to 4 GHz), 4 GB DDR3 RAM, X-Fi Platinum sound, GeForce 460, 1920x1440 resolution, 1250 GB HDD space, Visual C++ 2008 Express

Popular pages Recent additions subscribe to a feed

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21