setalpha
BlitzMax Forums/BlitzMax Beginners Area/setalpha
| ||
how do you use setalpha? ive tried using the alphablend thing but everything goes funny coloured and slow, is there any way to use it for realtime stuff? |
| ||
Have you got any example code as it works in realtime for me OK. Basically, setblend alphablend setalpha 0.8 Have you tried by gl and dx drivers? |
| ||
nah will have a look, been trying to get it to work in me game unfortunately its rather large :D |
| ||
I don't quite get what you're asking for. This is an example of using alphablend... Graphics 640,480 image=LoadImage("max.png") SetClsColor 100,100,100 alpha#=0.8 While Not KeyHit(key_escape) Cls SetBlend alphablend SetAlpha alpha DrawImage image,MouseX(),MouseY() If KeyHit(key_up) alpha=alpha+0.1 If KeyHit(key_down) alpha=alpha-0.1 Flip Wend End but I'm sure you could have tested that it works OK in that situation. |
| ||
The alpha value ranges from 0.0 to 1.0 for each pixel. If you use SetAlpha 0.5, then any alpha values in your image that are brighter than `half` will determine which pixels are masked in/out when using it for SetBlend MASKEDBLEND. Usually, pixels in your alpha channel will be either 1.0 or 0, where 1.0 means include the pixel and 0 means exclude it, so by setting the value at 0.5 (the default) it would only include the 1.0 pixels. You can set the level higher or lower so that you mask in/out different levels of color. You could effectively have a loop ranging from 0 to 0.5 or whatever which would gradually dissolve the image in. |
| ||
as an idea wouldnt it be better to internally set Alphablend within setalpha when the value is below 1.0 and use maskedblend if the alpha value is at 1.0. Would save all the Blendmode silliness. |
| ||
wouldn't be of any use. You have to set the blend before drawing the image so there is no use if it has been set "hours" before while it has been set to other blendmodes before. |
| ||
It would be faster to do a solidblend but probably not a masked blend as masking actually uses the same kind of code, modes and tests that alpha blending using. |