HUD Alpha Question
by Jackie Hayes · in Torque Game Engine · 08/23/2003 (8:46 am) · 12 replies
Does anyone know what the best approach would be to adjust the alpha channel "in code" for HUD graphics? I was looking at dglDrawBitmapStretchSR function in dgl.cc. This seems to be the end function that is called every time you blit a bitmap. The section glColor4ub seems to be where the RGBA is set. I want to pass an alpha value so i can be able to adjust the transparency on the fly.
Any help would be appreciated!
Thanks....
Any help would be appreciated!
Thanks....
#2
Thanks Phil..
08/23/2003 (9:15 am)
I want to be able to pass the alpha value to this control or create a similar control to accept the alpha value I pass to it. If I just pass the alpha value to glColor4ubwould that override what ever, if any, alpha channel that was saved with the bitmap? Also is the value 0.0 to 1.0 or 0 to 255?Thanks Phil..
#3
You know, now i think of it, I cant remember in OGL if alpha values in the glColour attribute have any effect if youre using the image alpha. I'm guessing they do. I'll try it out in a second.
If you wanted, you could use glColour4f and use floats from 0->1 if you preferred, it works the same.
You would just need to make it so that you can set that particular value from your code or script (if I remember right, its set to glColour4ub(255,255,255,255); right now isnt it?
I'll go try out that alpha value now.. see what happens.
Phil.
08/23/2003 (9:26 am)
That value is an unsigned byte, so its an int between 0 and 255You know, now i think of it, I cant remember in OGL if alpha values in the glColour attribute have any effect if youre using the image alpha. I'm guessing they do. I'll try it out in a second.
If you wanted, you could use glColour4f and use floats from 0->1 if you preferred, it works the same.
You would just need to make it so that you can set that particular value from your code or script (if I remember right, its set to glColour4ub(255,255,255,255); right now isnt it?
I'll go try out that alpha value now.. see what happens.
Phil.
#4
If you have alpha blending on, then the glColour4ub is basically the "source colour" value for the blend funcs.
So if I read this right, depending on the blending your using for your alpha, this value with effect the opacity in general.
Hmm, maybe time to re-read the old redbook :)
Phil.
08/23/2003 (9:32 am)
Hmm, thats not what I expected, but I guess it makes sense.If you have alpha blending on, then the glColour4ub is basically the "source colour" value for the blend funcs.
So if I read this right, depending on the blending your using for your alpha, this value with effect the opacity in general.
Hmm, maybe time to re-read the old redbook :)
Phil.
#5
08/23/2003 (9:37 am)
If you do not specify an alpha channel and use a jpg instead would that allow to set it in code?
#6
I'll put it online later tonight. It might help someone and it should definitely help me visualise whats happening with some of my other code when looking at blending..
Gimme a couple of hours.
Phil.
08/23/2003 (9:55 am)
Hmm, I tell you what.. I'm going to write a little app thats just the torque gui, with my effect controls, which have parameters for bitmap, blend funcs and whatnot.I'll put it online later tonight. It might help someone and it should definitely help me visualise whats happening with some of my other code when looking at blending..
Gimme a couple of hours.
Phil.
#7
08/23/2003 (10:01 am)
Thanks Phil..I certainly appreciate it!
#8
Hope this helps.
- Eric
08/23/2003 (10:33 am)
Not sure exactly what you're trying to do, but the dglSetBitmapModulation function is probably exactly what you want. I use a dglSetBitmapModulation(ColorF(1.0, 1.0, 1.0, alpha)) in a little slide show control I made that fades several pictures in and out by varying the alpha value. (I just paint two bitmaps one on top of the other and change the alpha modulation when drawing the top bitmap). Also, you'll want to use dglClearBitmapModulation() or it will affect everything else drawn after that call.Hope this helps.
- Eric
#9
I'll have a look.
Phil.
08/23/2003 (11:10 am)
Hmm.. now there's a point.. Ive just put some of my control code into a build with some of the re-skinning code someone posted as a resource and it doesnt look like it used to. I guess it could be that :)I'll have a look.
Phil.
#10
Anyway, i got a recent version of head, built it, stripped off what I could, copied my gui stuff across and put it on the webbie.
www.stormchaserstudios.com/download/tgui.zip
Its just a pretty simple interface using my guibitmapeffect control and the skinnable interface resource posted a while back.
The bit you should look at, is the guibitmapeffect, its got parameters you can change in the gui editor (F10) to alter the blend modes. Try different modes to see what they do to the images. Try out jpg's and png's for example.
I'll add the colorf value into the editable params and upload a newer version tommorow night.
Phil.
08/23/2003 (1:33 pm)
Hahaha, it was screwy because I forgot to copy a bitmap from my old build :)))Anyway, i got a recent version of head, built it, stripped off what I could, copied my gui stuff across and put it on the webbie.
www.stormchaserstudios.com/download/tgui.zip
Its just a pretty simple interface using my guibitmapeffect control and the skinnable interface resource posted a while back.
The bit you should look at, is the guibitmapeffect, its got parameters you can change in the gui editor (F10) to alter the blend modes. Try different modes to see what they do to the images. Try out jpg's and png's for example.
I'll add the colorf value into the editable params and upload a newer version tommorow night.
Phil.
#11
Do you place it before or after dglClearBitmapModulation()?
Thanks for ALL your help guys!
08/23/2003 (1:34 pm)
Eric. What you just explained is exactly what I am trying to do:) On the dglClearBitmapModulation() where do you place it? The following is a section of my onRender function:if (mTextureHandle)
{
dglClearBitmapModulation();
RectI rect(offset, mBounds.extent);
dglDrawBitmapStretch(mTextureHandle, rect);
}Do you place it before or after dglClearBitmapModulation()?
Thanks for ALL your help guys!
Torque 3D Owner Phil Carlisle
What exactly is it you are wanting to do?
Phil.