Sets the gamma correction value
| 2988 | |
| 2989 | // Sets the gamma correction value |
| 2990 | void d3d_SetGammaValue(float val) { |
| 2991 | D3D_preferred_state.gamma = val; |
| 2992 | |
| 2993 | if (!d3d_CanGamma) |
| 2994 | return; |
| 2995 | |
| 2996 | mprintf(0, "Setting gamma to %f\n", val); |
| 2997 | |
| 2998 | DDGAMMARAMP rampvals; |
| 2999 | |
| 3000 | for (int i = 0; i < 256; i++) { |
| 3001 | float norm = (float)i / 255.0; |
| 3002 | |
| 3003 | float newval = powf(norm, 1.0f / val); |
| 3004 | |
| 3005 | newval *= 65535; |
| 3006 | |
| 3007 | newval = std::min(65535, newval); |
| 3008 | newval = std::max(0, newval); |
| 3009 | |
| 3010 | rampvals.red[i] = newval; |
| 3011 | rampvals.green[i] = newval; |
| 3012 | rampvals.blue[i] = newval; |
| 3013 | } |
| 3014 | |
| 3015 | HRESULT rval = lpGammaControl->SetGammaRamp(0, &rampvals); |
| 3016 | mprintf(0, "Gamma return val is %d (%x) (%s)\n", rval, rval, d3d_ErrorString(rval)); |
| 3017 | } |
| 3018 | |
| 3019 | // Gets the current state of the renderer |
| 3020 | void d3d_GetRenderState(rendering_state *rstate) { memcpy(rstate, &D3D_state, sizeof(rendering_state)); } |
no test coverage detected