mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-19 10:31:08 +00:00
gl_vidsdl.c: use SDL_SetGamma() instead of SDL's GammaRamps api.
see: http://hg.libsdl.org/SDL/rev/3665bc284271 http://bugzilla.libsdl.org/show_bug.cgi?id=1979 git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@861 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
00bb0e814c
commit
c7de779229
2 changed files with 29 additions and 1 deletions
|
@ -104,6 +104,9 @@ cvar_t vid_gamma = {"gamma", "1", CVAR_ARCHIVE}; //johnfitz -- moved here from
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
|
#define USE_GAMMA_RAMPS 0
|
||||||
|
|
||||||
|
#if USE_GAMMA_RAMPS
|
||||||
static unsigned short vid_gamma_red[256];
|
static unsigned short vid_gamma_red[256];
|
||||||
static unsigned short vid_gamma_green[256];
|
static unsigned short vid_gamma_green[256];
|
||||||
static unsigned short vid_gamma_blue[256];
|
static unsigned short vid_gamma_blue[256];
|
||||||
|
@ -111,6 +114,7 @@ static unsigned short vid_gamma_blue[256];
|
||||||
static unsigned short vid_sysgamma_red[256];
|
static unsigned short vid_sysgamma_red[256];
|
||||||
static unsigned short vid_sysgamma_green[256];
|
static unsigned short vid_sysgamma_green[256];
|
||||||
static unsigned short vid_sysgamma_blue[256];
|
static unsigned short vid_sysgamma_blue[256];
|
||||||
|
#endif
|
||||||
|
|
||||||
static int vid_gammaworks;
|
static int vid_gammaworks;
|
||||||
|
|
||||||
|
@ -123,8 +127,20 @@ static void VID_Gamma_SetGamma (void)
|
||||||
{
|
{
|
||||||
if (draw_context && vid_gammaworks)
|
if (draw_context && vid_gammaworks)
|
||||||
{
|
{
|
||||||
|
#if USE_GAMMA_RAMPS
|
||||||
if (SDL_SetGammaRamp(&vid_gamma_red[0], &vid_gamma_green[0], &vid_gamma_blue[0]) == -1)
|
if (SDL_SetGammaRamp(&vid_gamma_red[0], &vid_gamma_green[0], &vid_gamma_blue[0]) == -1)
|
||||||
Con_Printf ("VID_Gamma_SetGamma: failed on SDL_SetGammaRamp\n");
|
Con_Printf ("VID_Gamma_SetGamma: failed on SDL_SetGammaRamp\n");
|
||||||
|
#else
|
||||||
|
float value;
|
||||||
|
|
||||||
|
if (vid_gamma.value > (1.0f / GAMMA_MAX))
|
||||||
|
value = 1.0f / vid_gamma.value;
|
||||||
|
else
|
||||||
|
value = GAMMA_MAX;
|
||||||
|
|
||||||
|
if (SDL_SetGamma(value,value,value) == -1)
|
||||||
|
Con_Printf ("VID_Gamma_SetGamma: failed on SDL_SetGamma\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,8 +153,13 @@ static void VID_Gamma_Restore (void)
|
||||||
{
|
{
|
||||||
if (draw_context && vid_gammaworks)
|
if (draw_context && vid_gammaworks)
|
||||||
{
|
{
|
||||||
|
#if USE_GAMMA_RAMPS
|
||||||
if (SDL_SetGammaRamp(&vid_sysgamma_red[0], &vid_sysgamma_green[0], &vid_sysgamma_blue[0]) == -1)
|
if (SDL_SetGammaRamp(&vid_sysgamma_red[0], &vid_sysgamma_green[0], &vid_sysgamma_blue[0]) == -1)
|
||||||
Con_Printf ("VID_Gamma_Restore: failed on SDL_SetGammaRamp\n");
|
Con_Printf ("VID_Gamma_Restore: failed on SDL_SetGammaRamp\n");
|
||||||
|
#else
|
||||||
|
if (SDL_SetGamma(1, 1, 1) == -1)
|
||||||
|
Con_Printf ("VID_Gamma_Restore: failed on SDL_SetGamma\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,6 +180,7 @@ VID_Gamma_f -- callback when the cvar changes
|
||||||
*/
|
*/
|
||||||
static void VID_Gamma_f (cvar_t *var)
|
static void VID_Gamma_f (cvar_t *var)
|
||||||
{
|
{
|
||||||
|
#if USE_GAMMA_RAMPS
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
|
@ -168,7 +190,7 @@ static void VID_Gamma_f (cvar_t *var)
|
||||||
vid_gamma_green[i] = vid_gamma_red[i];
|
vid_gamma_green[i] = vid_gamma_red[i];
|
||||||
vid_gamma_blue[i] = vid_gamma_red[i];
|
vid_gamma_blue[i] = vid_gamma_red[i];
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
VID_Gamma_SetGamma ();
|
VID_Gamma_SetGamma ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +203,11 @@ static void VID_Gamma_Init (void)
|
||||||
{
|
{
|
||||||
vid_gammaworks = false;
|
vid_gammaworks = false;
|
||||||
|
|
||||||
|
#if USE_GAMMA_RAMPS
|
||||||
if (SDL_GetGammaRamp (&vid_sysgamma_red[0], &vid_sysgamma_green[0], &vid_sysgamma_blue[0]) != -1)
|
if (SDL_GetGammaRamp (&vid_sysgamma_red[0], &vid_sysgamma_green[0], &vid_sysgamma_blue[0]) != -1)
|
||||||
|
#else
|
||||||
|
if (SDL_SetGamma(1, 1, 1) != -1)
|
||||||
|
#endif
|
||||||
vid_gammaworks = true;
|
vid_gammaworks = true;
|
||||||
|
|
||||||
Cvar_RegisterVariable (&vid_gamma);
|
Cvar_RegisterVariable (&vid_gamma);
|
||||||
|
|
|
@ -28,6 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#define VID_CBITS 6
|
#define VID_CBITS 6
|
||||||
#define VID_GRADES (1 << VID_CBITS)
|
#define VID_GRADES (1 << VID_CBITS)
|
||||||
|
|
||||||
|
#define GAMMA_MAX 3.0
|
||||||
|
|
||||||
// moved here for global use -- kristian
|
// moved here for global use -- kristian
|
||||||
typedef enum { MS_UNINIT, MS_WINDOWED, MS_FULLSCREEN } modestate_t;
|
typedef enum { MS_UNINIT, MS_WINDOWED, MS_FULLSCREEN } modestate_t;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue