AMFP Enhanced
C++ reference: the code this unofficial fork added
Loading...
Searching...
No Matches
SoftwareGamma.h File Reference

gamma (Options > Gamma) when the display cannot do it. More...

#include <cmath>

Go to the source code of this file.

Functions

float SoftwareGammaExponent (float afGamma)
 The exponent applied to each colour channel (SDL_CalculateGammaRamp: 1 / gamma).
bool SoftwareGammaNeeded (bool abHardwareGammaWorks, float afGamma)
 Draw the pass this frame: hardware gamma failed and gamma is not (about) 1.
float SoftwareGammaApply (float afValue, float afGamma)
 One channel through the curve, 0..1 (what the shader does; for tests and references).

Variables

static const char *const kSoftwareGammaVS
static const char *const kSoftwareGammaFS

Detailed Description

gamma (Options > Gamma) when the display cannot do it.

The game sets gamma with SDL_SetWindowBrightness, a hardware gamma ramp. SDL3 (under sdl2-compat on macOS, and on Wayland) has no gamma ramps, so the call fails and the slider did nothing. Then the last thing drawn each frame is a full-screen pass with the same curve SDL's ramp used: out = in ^ (1 / gamma). Gamma 1 costs nothing. Pure, unit tested in tests/cpp/test_software_gamma.cpp.

Definition in file SoftwareGamma.h.

Function Documentation

◆ SoftwareGammaExponent()

float SoftwareGammaExponent ( float afGamma)
inline

The exponent applied to each colour channel (SDL_CalculateGammaRamp: 1 / gamma).

Definition at line 14 of file SoftwareGamma.h.

◆ SoftwareGammaNeeded()

bool SoftwareGammaNeeded ( bool abHardwareGammaWorks,
float afGamma )
inline

Draw the pass this frame: hardware gamma failed and gamma is not (about) 1.

Definition at line 22 of file SoftwareGamma.h.

◆ SoftwareGammaApply()

float SoftwareGammaApply ( float afValue,
float afGamma )
inline

One channel through the curve, 0..1 (what the shader does; for tests and references).

Definition at line 28 of file SoftwareGamma.h.

Variable Documentation

◆ kSoftwareGammaVS

const char* const kSoftwareGammaVS
static
Initial value:
=
"void main() { gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = gl_Vertex; }\n"

Definition at line 37 of file SoftwareGamma.h.

◆ kSoftwareGammaFS

const char* const kSoftwareGammaFS
static
Initial value:
=
"uniform sampler2D tex; uniform float exponent;\n"
"void main() { vec3 c = texture2D(tex, gl_TexCoord[0].st).rgb;\n"
" gl_FragColor = vec4(pow(max(c, vec3(0.0)), vec3(exponent)), 1.0); }\n"

Definition at line 39 of file SoftwareGamma.h.