[GTK3] Make rgb_encode() big endian compatible
This commit is contained in:
parent
9044189a95
commit
b976938be8
12
gtk3/main.c
12
gtk3/main.c
@ -372,7 +372,16 @@ static gint handle_local_options(GApplication *app, GVariantDict *options, gpoin
|
||||
}
|
||||
|
||||
static uint32_t rgb_encode(GB_gameboy_t *gb, uint8_t r, uint8_t g, uint8_t b) {
|
||||
uint32_t color = 0xFF000000 | (b << 16) | (g << 8) | r; // abgr
|
||||
// We use GL_RGBA and GL_UNSIGNED_BYTE for our texture upload,
|
||||
// so OpenGL expects pixel data in RGBA order in memory.
|
||||
#ifdef GB_LITTLE_ENDIAN
|
||||
// ABGR
|
||||
uint32_t color = 0xFF000000 | (b << 16) | (g << 8) | r;
|
||||
#else
|
||||
// RGBA
|
||||
uint32_t color = (r << 24) | (g << 16) | (b << 8) | 0xFF;
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
@ -394,6 +403,7 @@ static void update_window_geometry() {
|
||||
GB_get_screen_height(&gb) * 2
|
||||
);
|
||||
|
||||
// Setup our image buffers
|
||||
if (image_buffers[0]) free(image_buffers[0]);
|
||||
if (image_buffers[1]) free(image_buffers[1]);
|
||||
if (image_buffers[2]) free(image_buffers[2]);
|
||||
|
Loading…
Reference in New Issue
Block a user