Irrlicht で文字列を描画する
IRRLICHT は,C 言語ベースの3次元エンジンです. IRRLICHT は,画像(カラー,モノクロ)の描画、2次元グラフィックス、3次元グラフィックス,イベント処理(マウス,キーボード等)の機能をもったゲームエンジンの決定版です. 文字の描画 (unicodeも可), 画像ファイル読み書きの機能もありますし,スライダやボタンなどのGUI部品もあるので,困ることはありません.
【関連する外部ページ】: http://lesson.ifdef.jp/index.html ・・・ Irrlicht プログラム集
【関連する外部ページ】 http://www.zgock-lab.net/irrlicht/tut01.htm
【関連する外部ページ】 https://irrlichtstg.ifdef.jp/
【関連する外部ページ】 http://www.realintegrity.net/~irr/index.php?FrontPage
前準備
- Windows の場合
Irrlicht のインストールが終わっていること.
- Linux の場合
Irrlicht のインストールが終わっていること.
Irrlicht で文字列を描画するプログラム例
#ifdef WIN32
#include<windows.h>
#endif
#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")
#ifdef WIN32
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main()
#endif
{
const int width = 640;
const int height = 480;
// start up an engine
video::E_DRIVER_TYPE driverType;
#ifdef WIN32
driverType = video::EDT_DIRECT3D9;
#else
/* driverType = video::EDT_OPENGL; */
driverType = video::EDT_SOFTWARE;
/* driverType = video::EDT_SOFTWARE2; */
#endif
static IrrlichtDevice *device = createDevice( driverType,
/* windowSize */ core::dimension2d<u32>(width, height),
/* bits */ 16,
/* fullscreen */ false,
/* stencilbuffer */ false,
/* vsync */ false,
/* IEventReceiver */ 0
);
if (device == 0)
return 1;
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* scenemgr = device->getSceneManager();
gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
gui::IGUIFont* font = guienv->getBuiltInFont();
device->setWindowCaption(L"simple test");
// draw everything
while(device->run() && driver) {
driver->beginScene(true, true, video::SColor(255,0,0,255));
font->draw( /* text */ L"Hello", /* position */ rect<s32>(/* x */ 10, /* y */ 10, /* x2 */ 280, /* y2 */ 30), /* color */ SColor(255,255,0,100), /* hcenter */ false, /* vcenter */ false, /* clip */ NULL);
/* scenemgr->drawAll(); */
driver->endScene();
}
// delete device
device->drop();
return 0;
}
Ubuntu でのコンパイル操作の手順例
g++ -I/usr/include/irrlicht hoge.cc -lIrrlicht
