-
-
Notifications
You must be signed in to change notification settings - Fork 212
GB_set_rgb_encode_callback
Lior Halphon edited this page Nov 30, 2024
·
4 revisions
typedef uint32_t (*GB_rgb_encode_callback_t)(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b);
void GB_set_rgb_encode_callback(GB_gameboy_t *gb, GB_rgb_encode_callback_t callback);
In display.h
Sets an encoding function that will convert red, green, and blue triplets to a single uint32_t
value supported by your frontend. For example:
/* Assuming Little Endian */
static uint32_t encode_rgba(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b)
{
return (r << 0) | (g << 8) | (b << 16) | 0xFF000000;
}
static uint32_t encode_bgrx(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b)
{
return (r << 16) | (g << 8) | (b << 0);
}
You must either call this function with a valid function pointer or GB_set_rendering_disabled with true
before first calling GB_run
.
If callback
is not NULL, GB_set_rgb_encode_callback
is thread-safe and can be called from any thread and context. Otherwise, it must not be called if the instance is being run in another thread, but may be called from the current one (via a callback).