#include <irrlicht.h>
#include "TTFontManager.h"
#include "CGUITTFont.h"
using namespace irr;
using namespace irr::core;
using namespace irr::video;
using namespace irr::scene;
using namespace irr::gui;
#pragma comment( lib, "irrlicht.lib" )
#pragma comment( lib, "freetype221MT.lib" )
int main()
{
//获取设备对象,驱动类型dx9
IrrlichtDevice *device = createDevice(EDT_DIRECT3D9, dimension2d<s32>(640, 480), 16, false, false, false, 0);
if(!device)
return 1;
device->setWindowCaption(L "你好 世界!"); //设置窗体标题
IVideoDriver *driver=device->getVideoDriver(); //与纹理有关
ISceneManager *smgr=device->getSceneManager(); //获取场景管理器对象
IGUIEnvironment *guienv=device->getGUIEnvironment(); //获取GUI环境对象(和界面相关)
IGUIStaticText *guitxt=guienv->addStaticText(L "Hello World.",rect< int>(10,10,200,20), true);
new TTFontManager( driver );
TTFontManager *ttmgr=TTFontManager::GetSingletonPtr();
IGUIFont *font=ttmgr->getFont( "simsun.ttc",24);
ISceneNode *cubeNode=smgr->addCubeSceneNode(100.0f); //添加立方体
ITexture *tex=driver->getTexture( "texture.jpg"); //获取贴图纹理
cubeNode->setMaterialTexture(0,tex); //为立方体设置贴图纹理
cubeNode->setMaterialFlag(EMF_LIGHTING, false); //设置贴图与光源无关
//cubeNode->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);//设置半透明Alpha通道
ICameraSceneNode *camera=smgr->addCameraSceneNode(0,vector3df(100,100,-100),vector3df(0,0,0));
//游戏循环Game Loop
while(device->run())
{
driver->beginScene( true, true,SColor(255,200,200,255)); //[[Begin
smgr->drawAll(); //全部绘制
guienv->drawAll(); //绘制界面元素
font->draw(L "这是一段中文,字体为宋体!",rect< int>(0,200,200,30),SColor(255,0,0,0));
//font->draw(L"中文字体Chinese华文形楷--字体文件3M!", rect<s32>(200,340,800,600),SColor(255,255,255,0) );
driver->endScene(); //End]]
}
font->drop(); //删除字体对象
delete ttmgr; //删除字体管理器对象
device->drop(); //删除设备对象
return 0;
}