I'm having trouble drawing a font with a开发者_运维知识库n alpha channel:
gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont();
font->draw(L"C'mon, be transparent, PLEASE!!!",
core::rect<s32>(130,10,300,50),
video::SColor(127,255,255,255));
As you can see, the text should have an alpha value of 127... but it doesn't.
How can I draw transparent text?
I found out that if I use SOFTWARE driver instead of OPEN_GL or DirectX, I also get your problem. But with OpenGL or DirectX it works fine. So if it is an option you can one of these drivers below:
video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
video::E_DRIVER_TYPE driverType = video::video::EDT_DIRECT3D8;
video::E_DRIVER_TYPE driverType = video::video::EDT_DIRECT3D9;
Solution is simple. Use StaticText. Just like this:
m_pText = m_pGUIEnvironment->addStaticText(
"C'mon, be transparent, PLEASE!!!",
rect<s32>(130,10,300,50)
);
// Set your desired color with alpha value as OVERRIDE one.
m_pText->setOverrideColor(SColor(127,0,0,0));
// And don't forget to enable it!
m_pText->enableOverrideColor(true);
Voela, now you have semi-transparent text. By the way, I also think that you were trying to use a white-colored text within white environment. Look at your color - transparency is useless as long as you don't use different colors for text and background. In any case, try using my example, if everything else fails.
精彩评论