'Is there a way to position the SDL2 message box from the SDL2 library in C++?

I am using the SDL_ShowMessageBox(...) function from the SDL2 library. This is my current code:

const SDL_MessageBoxButtonData buttons[] = {
    {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 0, "OK"},
};

const SDL_MessageBoxColorScheme colorScheme = {
    {{255, 0, 0},
    {0, 255, 0},
    {255, 255, 0},
    {0, 0, 255},
    {255, 0, 255}}};

char _score[10];

sprintf(_score, "%d", score);
char text[50] = "Game over\nYour Score: ";
strcat(text, _score);
const SDL_MessageBoxData messageboxdata = {
    SDL_MESSAGEBOX_INFORMATION,
    NULL,
    "You lost",
    text,
    SDL_arraysize(buttons),
    buttons,
    &colorScheme};

int buttonid;
if (SDL_ShowMessageBox(&messageboxdata, &buttonid) < 0)
    SDL_Log("error opening window");

exit(0);

I need to position the window on my display. I can't find anything about positioning in the documentation or through other sources on the internet. Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source