bate's blog

調べたこと実装したことなどを取りとめもなく書きます。

FTGLを使って日本語入力

そこそこ簡単だが、固定パイプラインを使うので気持ち悪い。

// グローバル
#define FONT_FILE "C:\\Windows\\Fonts\\msgothic.ttc"
FTPixmapFont* g_Font = NULL;

// 初期化
g_Font = new FTPixmapFont(FONT_FILE);
if(g_Font->Error()) {
   exit(EXIT_FAILURE);
}
g_Font->FaceSize(32);
g_Font->CharMap(ft_encoding_unicode);

// 描画
glDisable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, g_WindowWidth, g_WindowHeight, 0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glRasterPos2f(32, 32);
g_Font->Render(L"こんにちわ, FTGL");