While normal ttf render functions take const char* for the text they're gonna render TTF_RenderUNICODE_Solid() function takes const Uint*.
I used this structure to create textures from ttf surfaces while working with ASCII characters:
Text = TTF_RenderText_Solid(times, title.c_str(), MakeColor(255, 0, 255));
ButtonTexture = SDL_CreateTextureFromSurface(renderer, Text);
.
And when I wanted to work with unicode I tried this:
Text = TTF_RenderUNICODE_Solid(times, title.c_str(), MakeColor(255, 0, 255));
ButtonTexture = SDL_CreateTextureFromSurface(renderer, Text);
.
Because title.c_str() is const char* and the function wants const Uint16 I can't create the texture.
This is how I pass the title:
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);
}
Question: How can I convert my string to Uint16?
titlein the second case? If it's not Unicode, why are you using the Unicode function? - Alan Stokestitlecome? Is it utf-8, ascii or e.g. latin-1 text? - HelloWorld