我需要设置SDL窗口的亮度,但到目前为止,我只有一种解决方法,即在所有图形的顶部渲染具有所需alpha值的黑色纹理。有没有更好的方法来实现窗口的亮度?
可悲的是,SDL_SetWindowBrightness设置了整个显示器的亮度,这不是我的环境的选择。
到目前为止,我的代码是:
// first create a rectancle with the brightness factor
SDL_FillRect(MyBrightnessSurface, NULL, SDL_MapRGBA(MyBrightnessSurface->format, 0, 0, 0, MySWBrightness));
SDL_SetSurfaceAlphaMod(MyBrightnessSurface, MySWBrightness)
然后总是在上面绘制矩形:
// redraw the whole screen
...
//blit the brightness surface on the screen
SDL_BlitSurface(MyBrightnessSurface, NULL, MyScreen, NULL);
SDL_RenderPresent(MyRenderer);