mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-01-03 16:33:47 +00:00
corresponding gamma change for sdl1
This commit is contained in:
parent
792ad5ccff
commit
d1fcff0a08
@ -155,6 +155,11 @@ static SDL_mutex *frame_buffer_lock = NULL;
|
||||
#define LOCK_FRAME_BUFFER SDL_LockMutex(frame_buffer_lock)
|
||||
#define UNLOCK_FRAME_BUFFER SDL_UnlockMutex(frame_buffer_lock)
|
||||
|
||||
// Previously set gamma tables
|
||||
static uint16 last_gamma_red[256];
|
||||
static uint16 last_gamma_green[256];
|
||||
static uint16 last_gamma_blue[256];
|
||||
|
||||
// Video refresh function
|
||||
static void VideoRefreshInit(void);
|
||||
static void (*video_refresh)(void);
|
||||
@ -1363,9 +1368,36 @@ void SDL_monitor_desc::set_palette(uint8 *pal, int num_in)
|
||||
{
|
||||
const VIDEO_MODE &mode = get_current_mode();
|
||||
|
||||
// FIXME: how can we handle the gamma ramp?
|
||||
if ((int)VIDEO_MODE_DEPTH > VIDEO_DEPTH_8BIT)
|
||||
if ((int)VIDEO_MODE_DEPTH > VIDEO_DEPTH_8BIT) {
|
||||
// handle the gamma ramp
|
||||
uint16 red[256];
|
||||
uint16 green[256];
|
||||
uint16 blue[256];
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
red[i] = pal[i*3 + 0] << 8;
|
||||
green[i] = pal[i*3 + 1] << 8;
|
||||
blue[i] = pal[i*3 + 2] << 8;
|
||||
}
|
||||
|
||||
bool changed = (memcmp(red, last_gamma_red, 512) != 0 ||
|
||||
memcmp(green, last_gamma_green, 512) != 0 ||
|
||||
memcmp(blue, last_gamma_blue, 512) != 0);
|
||||
|
||||
if (changed) {
|
||||
int result = SDL_SetGammaRamp(red, green, blue);
|
||||
|
||||
if (result < 0) {
|
||||
printf("SDL_SetGammaRamp returned %d, SDL error:", result, SDL_GetError());
|
||||
}
|
||||
|
||||
memcpy(last_gamma_red, red, 512);
|
||||
memcpy(last_gamma_green, green, 512);
|
||||
memcpy(last_gamma_blue, blue, 512);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
LOCK_PALETTE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user