Page 1 of 1

Alpha BG for RenderTarget

Posted: Sun Jun 04, 2017 3:49 am
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);
 

Re: Alpha BG for RenderTarget

Posted: Sun Jun 04, 2017 4:21 am
by kornwaretm
are you using transparent material type?
o->getMaterial(0).MaterialType = EMT_TRANSPARENT_ALPHA_CHANNEL;

Re: Alpha BG for RenderTarget

Posted: Sun Jun 04, 2017 4:25 pm
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