| Summary: | SDL_SetWindowBrightness() sets gamma for entire monitor, not window! | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Waxhead <waxhead> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | ASSIGNED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | CC: | adam, waxhead |
| Version: | HG 2.1 | ||
| Hardware: | x86 | ||
| OS: | Windows (XP) | ||
|
Description
Waxhead
2013-10-13 22:16:25 UTC
That's correct, the brightness is implemented using the device gamma ramp which affects the whole monitor. If you implement your own 3D renderer you can implement brightness as a separate composition pass, but that's more performance intensive. (In reply to Sam Lantinga from comment #1) > That's correct, the brightness is implemented using the device gamma ramp > which affects the whole monitor. If you implement your own 3D renderer you > can implement brightness as a separate composition pass, but that's more > performance intensive. The documentation states "Use this function to set the brightness (gamma correction) for a window." https://wiki.libsdl.org/SDL_SetWindowBrightness?highlight=%28\bCategoryAPI\b%29|%28SDLFunctionTemplate%29 Since when was a Window synonymous with a monitor?! This is not obvious for the programmer and I suggest either updating the documentation or renaming the function to something a bit more accurate. It is obvious that it does not set the brightness for the window as one might expect. Also regardless if this function was renamed SDL_SetOutputGamma() or something else there is still a bug, if you move the window to another monitor the gamma is not restored on the monitor it was moved from and the monitor the window is moved to does not inherit the gamma. E.g. the monitor that the window was opened on still has a higher gamma and the other monitor no adjustments made. It is terribly unintuitive, and the . I would personally vote for the functions to be deprecated in favor of SDL_GetDisplayBrightness(int displayIndex) and SDL_SetDisplayBrightness(int displayIndex, float brightness). Temporary macro and wrapper functions called SDL_SetWindowBrightness could prevent breaking existing code (and also emit a compiler warning about the functions being deprecated). But I would understand if policy stated that SDL 2.0 APIs must never break backwards compatibility. In the mean time, I've updated the documentation. What about SDL_GetWindowGammaRamp and SDL_SetWindowGammaRamp? Do those have the same problems? Also, do the functions support brightnesses outside the range of 0 to 1? Could it be set to 1.5, for instance? (In reply to Adam M. from comment #3) > It is terribly unintuitive, and the . I would personally vote for the > functions to be deprecated in favor of SDL_GetDisplayBrightness(int > displayIndex) and SDL_SetDisplayBrightness(int displayIndex, float > brightness). Temporary macro and wrapper functions called > SDL_SetWindowBrightness could prevent breaking existing code (and also emit > a compiler warning about the functions being deprecated). > > But I would understand if policy stated that SDL 2.0 APIs must never break > backwards compatibility. In the mean time, I've updated the documentation. Speaking for myself I am happy with the changes to the documentation as it clearly states how the function works (no one would like a function called DeleteFile() to nuke a directory right?), however the bug that I mentioned is still there to my best knowledge. I don't use Windows anymore :) so I can't test any potential fixes. SDL_SetWindowBrightness() is implemented using SDL_SetWindowGammaRamp(), so it has the same issue. You can set the brightness to any valid gamma correction value. Typical values are in the range of 0.2 to 5.0. I've updated the documentation for SDL_Get/SetWindowGammaRamp as well, then. Marking for review for SDL 2.1 |