Special Effects

In my game, I want the buttons to do something cool when the user puts his/her mouse over it. I can make seperate buttons that are different, but then I have a texture for the normal button, mask for the normal button, texture for the mouse over button, mask for the mouse over button. That can add up really quickly as I am trying to keep the size as small as possible. So here is my question (finally!): is there any cool effect that OGL can render to a texture on the spur of the moment? I hope I made sense in all that

The easiest way I've found to do this is to use some sort of blending effect to accomplish what I want to do. For instance, when I was making my tetris game, I wanted a completed line to glow briefly before fading out of existance, but didnt want to make glowing textures for every block type if I could avoid it, so I made one texture, and when a block was supposed to glow, I overlaid that texture over the block and used blending to make it appear to glow.

Depending on what you are trying to accomplish, you could use something similar to make your buttons do something, simply write code which does the effect, and overlay it on your buttons whenever the mouse is over them, and don't draw the effect when it isnt. Nothing about the buttons themselves will change.

Well, actually, I cheated a bit. What I was doing in that example was so simple that I didnt even need a texture, I just drew a solid color poly with the right alpha set to give the effect I was looking for. Later I changed it slightly to include a second rectangle that met the first in the center of the effect, but in both cases, I simply used the blending of a quad with the block in question.

So, you could use either a texture with the alpha set, or programmatically draw a solid poly in place with the alpha you needed, but in either case, blending is what gives you the special effect.

Related to the glowing part above, you can also have an alpha value that sort of rotates around the corners of the "glowing" polygon.

In other words the alpha value at one corner is at 1.0 while the other three are at 0.0, then an adjacent corner to the 1.0 corner starts incrementing its alpha value while the other decreases. Once the alpha value has shifted over to the other corner, you move on to the next one.

In this way it will look like a light is rotating around the corners of your button texture, and it's relativly simple to do.

A trick we are using with the current SQ interface screen is to draw the button at, say 75% opacity, then on mouseover it simply displays the button at 100% opacity, making it appear to "light up." Actually the graphics are kind of bright/shiny in their natural state, so when at 75% opacity they appear properly dimmed. Nothing to do with OpenGL or anything, and not a very cool effect, but cheap relative to disk space :-) And we are ditching that in our next release and just using completely new "mouseover" graphics, though I am hoping to still use some fade effects to make it look cool.

Quote:Originally posted by DaFalcon A trick we are using with the current SQ interface screen is to draw the button at, say 75% opacity, then on mouseover it simply displays the button at 100% opacity, making it appear to "light up." Actually the graphics are kind of bright/shiny in their natural state, so when at 75% opacity they appear properly dimmed. Nothing to do with OpenGL or anything, and not a very cool effect, but cheap relative to disk space :-) And we are ditching that in our next release and just using completely new "mouseover" graphics, though I am hoping to still use some fade effects to make it look cool.

That sounds like a pretty good idea. Kinda combine it with the post before and have the alpha values rise so that it appears to "fade-in" or even pulse I never even thought to use the alpha value! Thanks to all who helped me out!

Quote:Originally posted by David glColor4f(1.0,1.0,1.0,0.4); would be better than glColor4f(0.0,0.0,0.0,0.4); for what you're trying to do I think

I have tried both of those and both display the texture, but no matter what alpha value I give, it NEVER become semi-transparent! Does a special blending have to be enabled? Should I put this code before I draw the mask, or the texture? Should I put it after I bind the texture, or before?