diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 3834a22c7..3d9eb5021 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.3: +- Added -g option to control gamma correction, from chmmravatar - Restored the CondBank to actually use condition variables properly (resolves a race condition under OpenBSD) - Removed aspects of the legacy graphics code that are never used or that diff --git a/sc2/src/sc2code/libs/graphics/gfx_common.h b/sc2/src/sc2code/libs/graphics/gfx_common.h index 76b73f687..a1d85a899 100644 --- a/sc2/src/sc2code/libs/graphics/gfx_common.h +++ b/sc2/src/sc2code/libs/graphics/gfx_common.h @@ -61,6 +61,7 @@ extern int FrameRateTickBase; void TFB_FlushGraphics (void); // Only call from main thread!! +void TFB_SetGamma (float gamma); // Unknown Stuff extern int ScreenWidth; diff --git a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c index b1aae5741..b3e410530 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c +++ b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c @@ -641,4 +641,17 @@ TFB_FlushGraphics () // Only call from main thread!! BroadcastCondVar (RenderingCond); } +void +TFB_SetGamma (float gamma) +{ + if (SDL_SetGamma (gamma, gamma, gamma) == -1) + { + fprintf (stderr, "Unable to set gamma correction.\n"); + } + else + { + fprintf (stderr, "Gamma correction set to %1.4f.\n", gamma); + } +} + #endif diff --git a/sc2/src/starcon2.c b/sc2/src/starcon2.c index 81b9e953c..94d9303ab 100644 --- a/sc2/src/starcon2.c +++ b/sc2/src/starcon2.c @@ -88,6 +88,7 @@ main (int argc, char *argv[]) int vol; int val; char contentdir[1000]; + float gamma = 1.0; enum { @@ -116,6 +117,7 @@ main (int argc, char *argv[]) {"audioquality", 1, NULL, 'q'}, {"nosubtitles", 0, NULL, 'u'}, {"music", 1, NULL, 'm'}, + {"gamma", 1, NULL, 'g'}, // options with no short equivalent {"cscan", 1, NULL, CSCAN_OPT}, {"menu", 1, NULL, MENU_OPT}, @@ -137,7 +139,7 @@ main (int argc, char *argv[]) strcpy (contentdir, "content"); #endif - while ((c = getopt_long(argc, argv, "r:d:foc:spn:?hM:S:T:m:q:u", long_options, &option_index)) != -1) + while ((c = getopt_long(argc, argv, "r:d:foc:spn:?hM:S:T:m:q:ug:", long_options, &option_index)) != -1) { switch (c) { case 'r': @@ -225,6 +227,9 @@ main (int argc, char *argv[]) long_options[option_index].name)) != -1) optWhichMusic = val; break; + case 'g': + sscanf(optarg, "%f", &gamma); + break; case CSCAN_OPT: if ((val = Check_PC_3DO_opt (optarg, OPT_PC | OPT_3DO, @@ -275,6 +280,7 @@ main (int argc, char *argv[]) printf(" -c, --scale=mode (bilinear, biadapt or biadv, default is none)\n"); printf(" -s, --scanlines (default off)\n"); printf(" -p, --fps (default off)\n"); + printf(" -g, --gamma=CORRECTIONVALUE (default 1.0, which causes no change)\n"); printf(" -n, --contentdir=CONTENTDIR\n"); printf(" -M, --musicvol=VOLUME (0-100, default 100)\n"); printf(" -S, --sfxvol=VOLUME (0-100, default 100)\n"); @@ -314,6 +320,7 @@ main (int argc, char *argv[]) init_xform_control (); TFB_InitGraphics (gfxdriver, gfxflags, width, height, bpp); + TFB_SetGamma (gamma); TFB_InitSound (snddriver, soundflags); TFB_InitInput (TFB_INPUTDRIVER_SDL, 0);