gfx_mode_select_filter(3)
π gfx_mode_select_filter π
okay bestie, so this one lives in the Allegro manual (section 3, the library functions girlies) and it's literally the most extra version of the graphics mode selection dialog. like, the one with the filter. the main character one. β¨
π SYNOPSIS π
#include <allegro.h>
int gfx_mode_select_filter(int *card, int *w, int *h, int *color_depth,
int (*filter)(int, int, int, int));
πΈ DESCRIPTION πΈ
So. Even more extended version of the graphics mode selection dialog β and when I say more extended I mean she lets the programmer customize the actual contents of the dialog, AND lets the user pick the color depth on top of the resolution and the hardware driver. full package. π
Here's the tea on filter: it gets handed (card, w, h, color_depth) quadruplets, and it has to return 0 to let that specific quadruplet get added to the list of displayed modes. return anything else and she's filtered out, bye. π¦
Same energy as gfx_mode_select though: the values sitting at the addresses you pass in get used as suggestions for the initial selections in the dialog. and if those values aren't found anywhere? it just defaults to the first entry in each list. no drama. π
π‘ pro tip bestie: if you want to be certain the initial selection for each list is the first entry, initialize the data at those addresses to0or-1. works every time, no cap.
And if the dialog gets OK'd, she stores the selections right back at the addresses you passed in. slay.
Example usage, copy it, it's cute:
ret = gfx_mode_select_filter(&card, &w, &h, &color_depth, user_filter);
if (ret) {/* User okayed dialog or user_filter removed all modes */
if (card == GFX_NONE) {
// No modes available
*card = 0;/* Make sure not to leave *card == GFX_NONE */
return -1;
}
/* Handle changing to new mode here... */
} else {/* User cancelled dialog or there was an error (unlikely) */
if (card == GFX_NONE) {
/* Error, probably out of memory */
*card = 0;/* Make sure not to leave *card == GFX_NONE */
return -2;
}
/* Carry on in current graphics mode if that is acceptable */
}
β¨ RETURN VALUE β¨
- Returns zero if the user cancelled the dialog, or if an error happened. π and in the error case,
*cardgets assigned the valueGFX_NONE. - Returns non-zero if the user actually made a selection OR if all the modes got filtered out. π«Ά
- And in that "all the modes were filtered out" situation,
*cardalso gets assigned the valueGFX_NONE.
π¨ GIRLIE LISTEN. Because of all that, you should NOT initialize*cardto the value ofGFX_NONEβ it could interfere with determining the proper return value. it's giving chaos. don't do it. periodt. π
π SEE ALSO π
okay that's the whole page, you ate it, you're welcome. π this was Allegro version 4.4.3, and the page itself is dated with that same version. go forth and pick your graphics mode, bestie π§β¨π
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms