我写了一个小函数来改变我的显示器的伽玛值,但不幸的是它改变了错误显示器的伽玛值,我不需要它。
我几乎尝试了所有方法,但找不到任何可行的解决方案 - 它总是错误的显示器。
我如何正确告诉它应该更改伽玛值的显示器?
另一个奇怪的是,ScreenCount() 总是返回 1。
这个函数应该是损坏的 SDL_SetGamma() 的解决方法,它在 Linux 上不起作用,或者至少在 ATi 卡上不起作用。我libXxf86vm.so
在运行时加载,所以它是一个可选功能,不需要链接到应用程序中。
如果有人可以向我解释一下,我可以如何使用该命令更改第二台显示器的伽玛值,那就太好了xgamma
,因为该命令发生的情况完全相同。
#include <X11/Xlib.h>
typedef struct {
float red; /* Red Gamma value */
float green; /* Green Gamma value */
float blue; /* Blue Gamma value */
} XF86VidModeGamma;
typedef Bool (*XF86VidModeSetGamma)(Display*, int, XF86VidModeGamma*);
int changegamma(float red, float green, float blue)
{
void *lib;
XF86VidModeSetGamma f;
int screen;
Display *display;
XF86VidModeGamma gamma;
lib = dlopen("libXxf86vm.so", RTLD_LAZY);
if(!lib) goto error;
f = (XF86VidModeSetGamma)dlsym(lib, "XF86VidModeSetGamma");
if(!lib) goto error;
gamma.red = red;
gamma.green = green;
gamma.blue = blue;
display = XOpenDisplay(NULL);
if(!display) goto error;
screen = DefaultScreen(display);
if(!f(display, screen, &gamma)) goto error;
XCloseDisplay(display);
dlclose(lib);
return 0;
error:;
if(lib) dlclose(lib);
return SDL_SetGamma(red, green, blue);
}