Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Set gamma properly and increase terminal size
  • Loading branch information
Justin Crawford authored and Justin Crawford committed Mar 17, 2014
1 parent 7b297e4 commit 359b5ff
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/client/cl_console.c
Expand Up @@ -73,7 +73,8 @@ cvar_t *con_debug;
cvar_t *con_conspeed;
cvar_t *con_notifytime;

#define DEFAULT_CONSOLE_WIDTH 78
//#define DEFAULT_CONSOLE_WIDTH 78
#define DEFAULT_CONSOLE_WIDTH 255 // People in 2014 have much larger monitors. - Justasic

vec4_t console_color = {1.0, 1.0, 1.0, 1.0};

Expand Down
1 change: 1 addition & 0 deletions src/qcommon/cmd.c
Expand Up @@ -816,6 +816,7 @@ Cmd_Init
void Cmd_Init(void)
{
Cmd_AddCommand("cmdlist", Cmd_List_f);
Cmd_AddCommand("help", Cmd_List_f);
Cmd_AddCommand("exec", Cmd_Exec_f);
Cmd_AddCommand("vstr", Cmd_Vstr_f);
Cmd_AddCommand("echo", Cmd_Echo_f);
Expand Down
7 changes: 6 additions & 1 deletion src/renderer/tr_image.c
Expand Up @@ -2769,7 +2769,12 @@ void R_SetColorMappings(void)

if(glConfig.deviceSupportsGamma)
{
GLimp_SetGamma(s_gammatable, s_gammatable, s_gammatable);
ri.Printf(PRINT_ALL, "[renderer] Setting Gamma to new values: %.1f\n", s_gammatable);
// Gamma on SDL is different.
uint16_t *val;
CalculateGamma(s_gammatable, val);
GLimp_SetGamma(val, val, val);
//GLimp_SetGamma(s_gammatable, s_gammatable, s_gammatable);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/sdl/sdl_gamma.c
Expand Up @@ -106,6 +106,6 @@ void GLimp_SetGamma(unsigned char red[256], unsigned char green[256], unsigned c
}
}
}

SDL_SetGammaRamp(table[0], table[1], table[2]);
}
17 changes: 16 additions & 1 deletion src/sdl/sdl_glimp.c
Expand Up @@ -574,6 +574,20 @@ static void GLimp_InitExtensions(void)

}

void CalculateGamma(double gamma, Uint16 *ramp)
{
int i, value;

gamma = 1.0 / gamma;
for ( i=0; i<256; ++i ) {
value = (int)(pow((double)i/256.0, gamma)*65535.0 + 0.5);
if ( value > 65535 ) {
value = 65535;
}
ramp[i] = (Uint16)value;
}
}


void GLimp_Init(void)
{
Expand All @@ -582,7 +596,8 @@ void GLimp_Init(void)
ri.Error(ERR_FATAL, "GLimp_Init() - could not load OpenGL subsystem\n");

//glConfig.deviceSupportsGamma = SDL_SetGamma(2.0f, 2.0f, 2.0f) >= 0;
glConfig.deviceSupportsGamma = SDL_SetGamma(0.7f, 0.7f, 0.7f) >= 0;
// Make sure we can set gamma?
glConfig.deviceSupportsGamma = SDL_SetGamma(1.0f, 1.0f, 1.0f) != -1;

if(!glConfig.deviceSupportsGamma)
ri.Printf(PRINT_ALL, "Failed to set gamma: %s\n", SDL_GetError());
Expand Down

0 comments on commit 359b5ff

Please sign in to comment.