Fading Images

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
A.Russell
Posts: 56
Joined: Sun May 15, 2005 2:52 pm

Fading Images

Post by A.Russell »

I want to fade an image.

I have tried changing the alpha value of the scolor variable with no luck. I tried this with both a 24 and 32 bit tga image with alpha channel (and also tried using a black and a white alpha). I cannot make the image transparent:

Code: Select all

		my_driver->draw2DImage(p_magic_book, core::position2d<s32>(screensize.Width/2-256, 25),
		core::rect<s32>(0,0, 512,700),0,video::SColor(255,255,255,changing_this_value_doesnt_do_anything), true); 
Changing the values in the other channels is fine, just not the alpha. I have also set that last flag to both true and flase.

So, how to make an image transparent dynamically? (for fading in and out)

This might be a bug, because from the manual:
color,: Color with wich the image is colored. If the color equals Color(255,255,255,255), the color is ignored. Note that the alpha component is used: If alpha is other than 255, the image will be transparent.
I am using version 1.0
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Yes, it is a bug. I was able to fix it in the DX8 and 9 drivers by passing the correct value as the second parameter to setRenderStates2DMode. It looks like this was done so that compatibility could be maintained with the software renderers.

I believe the OpenGL driver is setting render states incorrectly in setRenderStates2DMode. If that was fixed, it could be made to work with the OpenGL driver also.

Travis
A.Russell
Posts: 56
Joined: Sun May 15, 2005 2:52 pm

Post by A.Russell »

Thanks Travis,

I am using OpenGL as my prefered driver, so I will just have to wait for a bug fix.

Do the developers know about this?
Artenius
Posts: 8
Joined: Wed Aug 31, 2005 4:29 pm
Location: a 3d matrix full of things I don´t understand now.

Post by Artenius »

Maybe you could do as he did and use setRenderStates2DMode for DirectX. Maybe some 'for' looping decrementing the alpha value and you would have your fader.
Guest

Post by Guest »

i did a fading by drawing a 2D black rectangle which has alpha value.
i play over its alpha value, decrementing or incrementing it.
if you're interested, i can give you my class that i wrote
dhenton9000
Posts: 395
Joined: Fri Apr 08, 2005 8:46 pm

Post by dhenton9000 »

Anonymous wrote:i did a fading by drawing a 2D black rectangle which has alpha value.
i play over its alpha value, decrementing or incrementing it.
if you're interested, i can give you my class that i wrote
I'd like to see that, can you post it somewhere? Thanks!!
Guest

Post by Guest »

ok, sorry for the late, i've forget about it, i will post it there:
http://viper.sign.free.fr/transition.zip

but if you want to see this stuff, try
http://viper.sign.free.fr/rpgtest.zip
Guest

Post by Guest »

i'll put the file on line when my little brother will turn on the computer, i'm at work now
Guest

Post by Guest »

Sorry, having pb with my ftp so i put the files here:
http://viper.sign.free.Fr/Transition.cpp
and
http://viper.sign.free.Fr/Transition.h

for rpgtest:
left click = valid
right click = cancel
middle click can be used in the green land

to see the fading effect, go to the fire and left click, it should be ok
Guest

Post by Guest »

i explain a little:

in an event, you use, the transitionObject->cover() or transitionObject->uncover() method.
in your display loop, you put transitionObject->render()

just analyze the code, there isn't be anything hard, i just draw a black panel and i play over its alpha value.

the difficultie is: when stop rendering, is the rendering finished and stuff like that.
for my game, i use this transition when i must go from a 'level' to another.
Post Reply