通常の ttf レンダリング関数はテキストに const char* を使用しますが、レンダリングする TTF_RenderUNICODE_Solid() 関数は const Uint* を使用します。
この構造を使用して、ASCII 文字を操作しながら ttf サーフェスからテクスチャを作成しました。
Text = TTF_RenderText_Solid(times, title.c_str(), MakeColor(255, 0, 255));
ButtonTexture = SDL_CreateTextureFromSurface(renderer, Text);
.
そして、ユニコードで作業したいときは、これを試しました:
Text = TTF_RenderUNICODE_Solid(times, title.c_str(), MakeColor(255, 0, 255));
ButtonTexture = SDL_CreateTextureFromSurface(renderer, Text);
.
title.c_str() は const char* であり、関数は const Uint16 を必要とするため、テクスチャを作成できません。
これは私がタイトルを渡す方法です:
MenuButtons[0] = new CreateButton("TEXT");
void CreateButton(string title)
{
Text = TTF_RenderText_Solid(times, title.c_str(), MakeColor(255, 0, 255));
ButtonTexture = SDL_CreateTextureFromSurface(renderer, Text);
//or
Text = TTF_RenderUNICODE_Solid(times, title.c_str(), MakeColor(255, 0, 255));
ButtonTexture = SDL_CreateTextureFromSurface(renderer, Text);
}
質問: 文字列を Uint16 に変換するにはどうすればよいですか?