Alpha BG for RenderTarget

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
Arclamp
Posts: 71
Joined: Thu Oct 10, 2013 7:45 pm

Alpha BG for RenderTarget

Post by Arclamp »

Hi,

I'm using the following to write text onto a texture, but having trouble on how to set the bg pixels to transparent!

Cheers

Code: Select all

 
ITexture* rt = driver->addRenderTargetTexture(core::dimension2d<u32>(256, 256), "rt", ECF_A8R8G8B8);
 
driver->setRenderTarget(rt, true, true, video::SColor(0,255,255,255));
 
//if(rt->hasAlpha()){
driver->draw2DRectangle(video::SColor(255, 255, 0, 0), core::recti(0, 100, 200, 200));
IGUIFont *f = env->getBuiltInFont();
f->draw(L"This is some text", rect<s32>(10, 10, 400, 300), SColor(255, 0, 0, 255), 0, 0, 0);
driver->setRenderTarget(0);
 
o->getMaterial(0).setTexture(0, rt);
 
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Re: Alpha BG for RenderTarget

Post by kornwaretm »

are you using transparent material type?
o->getMaterial(0).MaterialType = EMT_TRANSPARENT_ALPHA_CHANNEL;
Arclamp
Posts: 71
Joined: Thu Oct 10, 2013 7:45 pm

Re: Alpha BG for RenderTarget

Post by Arclamp »

Hi, sorry, I thought about this later, I should have mentioned I was saving the texture, however no I was using that, later I swapped to

Code: Select all

 
//o->getMaterial(0).MaterialType=irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL;
o->getMaterial(0).MaterialType=irr::video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
 
and used

Code: Select all

 
driver->makeColorKeyTexture(rt, core::position2d<s32>(0,0));
 
That worked great for the model render, but the save still had black pixels...?


Thanks
Post Reply