Skip to content

Instantly share code, notes, and snippets.

@matthewjberger
Created April 4, 2016 00:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewjberger/6c2a4c04a26a3788efffb8c86ee10d3e to your computer and use it in GitHub Desktop.
Save matthewjberger/6c2a4c04a26a3788efffb8c86ee10d3e to your computer and use it in GitHub Desktop.
SDL_MessageBox Example
const SDL_MessageBoxButtonData buttons[] = {
{ /* .flags, .buttonid, .text */ 0, 0, "no" },
{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "ok" },
};
const SDL_MessageBoxColorScheme colorScheme = {
{ /* .colors (.r, .g, .b) */
/* [SDL_MESSAGEBOX_COLOR_BACKGROUND] */
{ 255, 0, 0 },
/* [SDL_MESSAGEBOX_COLOR_TEXT] */
{ 0, 255, 0 },
/* [SDL_MESSAGEBOX_COLOR_BUTTON_BORDER] */
{ 255, 255, 0 },
/* [SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND] */
{ 0, 0, 255 },
/* [SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED] */
{ 255, 0, 255 }
}
};
string msg = "Couldn't load image %s.\nIMG_Error: " + path + IMG_GetError();
const SDL_MessageBoxData messageBoxData = {
SDL_MESSAGEBOX_INFORMATION, /* .flags */
NULL, /* .window */
"Error", /* .title */
msg.c_str(), /* message */
SDL_arraysize(buttons), /* .numbuttons */
buttons, /* .buttons */
&colorScheme /* .colorScheme */
};
int buttonid;
SDL_ShowMessageBox(&messageBoxData, &buttonid);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment