Hey everyone =)
I just started using the Irrlicht engine yesterday, so I have a lot to learn.
I have a transparent texture that I have to render as 2D (draw2DImage), but I cannot figure out how to make it render it with the transparency.
I tried to make a color key for the texture, but of course this doesn't work anywhere near optimally, since the transparent parts aren't a single color.
Thanks for your help,
Rasmus Larsen
2D texture transparency
From what I know:
1) Have your source image be able to support an alpha channel (i.e. PNG or TGA). Make sure the alpha channel is properly set oon the image
2) OR designed a specific color to be transparent(I use 255,0,255(rgb).
For this make sure all parts of your image that you want transparent use this color. Make sure the pixel at 0,0 is using your transparent color.
3) Next load the image using getTexture()
a) You are doing step 2. call makeColorTexture using 0,0 as your alpha color..(The other call which uses color r,g,b values may not work properly because your source image may have had colors changed upon load..for different bit depths etc.)
check the API reference of draw2DImage:
virtual void irr::video::IVideoDriver::draw2DImage ( video::ITexture * texture,
const core::position2d< s32 > & destPos,
const core::rect< s32 > & sourceRect,
const core::rect< s32 > * clipRect = 0,
SColor color = SColor(255, 255, 255, 255),
bool useAlphaChannelOfTexture = false
)
Make sure you last parameter is true.
Funny ..alpha transparency using an alpha channel work with Software2 renderer but doesn't seem to work with the default Software render.
1) Have your source image be able to support an alpha channel (i.e. PNG or TGA). Make sure the alpha channel is properly set oon the image
2) OR designed a specific color to be transparent(I use 255,0,255(rgb).
For this make sure all parts of your image that you want transparent use this color. Make sure the pixel at 0,0 is using your transparent color.
3) Next load the image using getTexture()
a) You are doing step 2. call makeColorTexture using 0,0 as your alpha color..(The other call which uses color r,g,b values may not work properly because your source image may have had colors changed upon load..for different bit depths etc.)
check the API reference of draw2DImage:
virtual void irr::video::IVideoDriver::draw2DImage ( video::ITexture * texture,
const core::position2d< s32 > & destPos,
const core::rect< s32 > & sourceRect,
const core::rect< s32 > * clipRect = 0,
SColor color = SColor(255, 255, 255, 255),
bool useAlphaChannelOfTexture = false
)
Make sure you last parameter is true.
Funny ..alpha transparency using an alpha channel work with Software2 renderer but doesn't seem to work with the default Software render.
Check the driver you are using...
When I use the default software one, transparency seem broken...
When I use the apel(wacha macallit one) software renderer...trasprencies are fine..
Works with directx, opengl as well..
Could be a driver issue with specific cards...not sure? Only have about 2 more days on you with Irrilicht...with my 2D game conversion...so far..not so good..well i got to refactor my code..clean up the stupid stuff I did in my game a 2 months ago..
When I use the default software one, transparency seem broken...
When I use the apel(wacha macallit one) software renderer...trasprencies are fine..
Works with directx, opengl as well..
Could be a driver issue with specific cards...not sure? Only have about 2 more days on you with Irrilicht...with my 2D game conversion...so far..not so good..well i got to refactor my code..clean up the stupid stuff I did in my game a 2 months ago..
Yeah, well, I've written my own engine before, and it worked perfect there. I am using OpenGL device currently, but it doesn't work with ANY device.
In my engine I loaded images with the Corona library, and then simply drew them. All I had to do to make transparency work was enabling GL_BLEND and setting glBlendFunc. This, unfortunately, doesn't work here.
Anyone?
In my engine I loaded images with the Corona library, and then simply drew them. All I had to do to make transparency work was enabling GL_BLEND and setting glBlendFunc. This, unfortunately, doesn't work here.
Anyone?