fixup! WIP - use gamma_correction instead of brightness

display-gamma-wip
Pavol Rusnak 1 year ago
parent 6757108baf
commit 6af5ad6a01
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -18,6 +18,7 @@
*/
#include <SDL.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
@ -31,7 +32,7 @@
#include "memzero.h"
extern void main_clean_exit();
extern int GAMMA_CORRECTION_PERCENTAGE;
extern float DISPLAY_GAMMA;
void __attribute__((noreturn)) __shutdown(void) {
printf("SHUTDOWN\n");
@ -148,14 +149,12 @@ static int SDLCALL emulator_event_filter(void *userdata, SDL_Event *event) {
display_save("emu");
return 0;
case SDLK_LEFT:
GAMMA_CORRECTION_PERCENTAGE -= 1;
printf("GAMMA_CORRECTION_PERCENTAGE: %d\n",
GAMMA_CORRECTION_PERCENTAGE);
DISPLAY_GAMMA = fmaxf(0.0f, DISPLAY_GAMMA - 0.05f);
printf("DISPLAY_GAMMA: %0.2f\n", DISPLAY_GAMMA);
return 0;
case SDLK_RIGHT:
GAMMA_CORRECTION_PERCENTAGE += 1;
printf("GAMMA_CORRECTION_PERCENTAGE: %d\n",
GAMMA_CORRECTION_PERCENTAGE);
DISPLAY_GAMMA = fminf(8.0f, DISPLAY_GAMMA + 0.05f);
printf("DISPLAY_GAMMA: %0.2f\n", DISPLAY_GAMMA);
return 0;
}
break;

@ -70,7 +70,7 @@ static SDL_Surface *PREV_SAVED;
static int DISPLAY_BACKLIGHT = -1;
static int DISPLAY_ORIENTATION = -1;
int GAMMA_CORRECTION_PERCENTAGE = 55;
float DISPLAY_GAMMA = 0.55f;
int sdl_display_res_x = DISPLAY_RESX, sdl_display_res_y = DISPLAY_RESY;
int sdl_touch_offset_x, sdl_touch_offset_y;
@ -98,11 +98,9 @@ uint16_t gamma_correct(uint16_t c) {
float fg = g / 63.0;
float fb = b / 31.0;
float gamma = GAMMA_CORRECTION_PERCENTAGE / 100.0;
fr = pow(fr, gamma);
fg = pow(fg, gamma);
fb = pow(fb, gamma);
fr = pow(fr, DISPLAY_GAMMA);
fg = pow(fg, DISPLAY_GAMMA);
fb = pow(fb, DISPLAY_GAMMA);
r = (int)round(fr * 31.0);
g = (int)round(fg * 63.0);

Loading…
Cancel
Save