How to change text fonts
-
[ds] Swift
- Posts: 20
- Joined: Sun Nov 14, 2004 1:57 am
- Location: Rochester, New York, USA
depends on how you are displayling your font really.
using IGUIStaticText this is how you would do it:
declare a pointer and create your text:
Example:
next to change the color you need to enable the color override
then set your override color to the text
change the alpha, red, green, blue in the code to integers from 0 - 255. if you need a guide on what colors different combinations make, open up MS Paint and goto Colors | Edit Colors | Define Custom Colors and pick your color and copy the RGB settings on the right into your program.
obviously you could also make an image and use draw2DImage.
you could also get fancy and make textured 3D text models
using IGUIStaticText this is how you would do it:
declare a pointer and create your text:
Example:
Code: Select all
IGUIStaticText *text = guienv -> addStaticText( L"hi", rect<s32>( 10, 10, 200, 22 ) );Code: Select all
text -> enableOverrideColor( true );
Code: Select all
text -> setOverrideColor( irr:video::SColor( alpha, red, green, blue ) );
obviously you could also make an image and use draw2DImage.
you could also get fancy and make textured 3D text models
Last edited by [ds] Swift on Mon Nov 29, 2004 4:06 am, edited 1 time in total.
There's a crack in everything -- That's how the light gets in.
-
[ds] Swift
- Posts: 20
- Joined: Sun Nov 14, 2004 1:57 am
- Location: Rochester, New York, USA
Complete example
Here is a program that displays colored text on the screen.
Hope it helps 
Code: Select all
/* irrlicht includes */
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#pragma comment( lib, "Irrlicht.lib" )
/* program start */
int main() {
IrrlichtDevice *device = createDevice( EDT_SOFTWARE, dimension2d<s32>( 640, 480 ), 128, false, false, false, 0 );
device->setWindowCaption( L"NaNoCrON software - Irrlicht Test" );
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
/***********************/
/* TEXT WORK DONE HERE */
IGUIStaticText *text = guienv -> addStaticText( L"Hi", rect<s32>( 10, 10, 200, 22 ) );
text -> enableOverrideColor( true );
text -> setOverrideColor( SColor( 0, 255, 0, 0 ) );
/***********************/
while( device->run() ) {
driver->beginScene( true, true, SColor( 0, 200, 200, 200 ) );
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
}There's a crack in everything -- That's how the light gets in.