SDL假的全屏模式在双显示器设置下linux [英] SDL fake fullscreen mode on dual monitor setup under linux
问题描述
使用SDL 1.3我想在linux下创建假的全屏SDL_Window。如果我只有一个显示器很容易。
我刚刚得到当前显示模式并创建了一个窗口。
SDL_GetDesktopDisplayMode(0,& mode);
SDL_Window * win = SDL_CreateWindow(my window,
0,0,mode.w,mode.h,
SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS);
但是当我有两个显示器时,事情变得复杂。窗口跨多个监视器。
我使用此代码测试了 code> int num = SDL_GetNumVideoDisplays();
for(int i = 0; i{
SDL_Rect displayRect;
SDL_GetDisplayBounds(i,& displayRect);
std :: cout
<< display<< i<< :x,y,w,h(
<< displayRect.x<<,
<< displayRect.y<<,
}
输出:
display 0:x,y,w,h(0,0,2960,1050)
但我有两个显示器(1680x1050和1280x1024)。
如何强制窗口只保留一个(假设主)显示?
src / video / x11 / SDL_x11modes.c
检查一些有趣的 #define
s:
SDL_VIDEO_DRIVER_X11_XINERAMA
SDL_VIDEO_DRIVER_X11_XRANDR
SDL_VIDEO_DRIVER_X11_XVIDMODE
您可以检查 include / SDL_config.h
您的副本正在关注。用 X11MODES_DEBUG
定义的重建也可能是有成效的。
编辑:尝试 test / testvidinfo。
c $ c>内置视频驱动程序:x11,dummy X11MODES_DEBUG
在我的系统上显示
视频驱动程序:x11
显示数量:1
显示0:2646x1024 at 0,0
当前模式:2646x1024 @ 0Hz,32位每像素
红色掩码= 0x00ff0000
绿色掩码= 0x0000ff00
蓝色掩码= 0x000000ff
检测到X11 X11天线:
xinerama 0:1366x768 + 0 + 0
xinerama 1:1280x1024 + 1366 + 0
XRANDR:XRRQueryVersion:V1.3
XRANDR:mode = 0 [0],w = 1366,h = 768,rate = 60
XRANDR:mode = 1 [0],w = 1360,h = 768,rate = 60
XRANDR:mode = 2 [0],w = 1024,h = 768,rate = 60
XRANDR:mode = 3 [0],w = 800,h = 600,rate = 60
XRANDR:mode = 3 [1],w = 800,h = 600,rate = 56
XRANDR:mode = 4 [0],w = 640,h = 480,rate = 60
Xinerama已启用
XRandR已启用
全屏视频模式:
模式0:2646x1024 @ 0Hz,32位每像素
红色遮罩= 0x00ff0000
绿色遮罩= 0x0000ff00
蓝色遮罩= 0x000000ff
模式1:1366x768 @ 60Hz,32位每像素
红色遮罩= 0x00ff0000
绿色遮罩= 0x0000ff00
蓝色遮罩= 0x000000ff
模式2:1366x768 @ 0Hz,32位每像素
红色遮罩= 0x00ff0000
绿色掩码= 0x0000ff00
蓝色掩码= 0x000000ff
模式3:1360x768 @ 60Hz,32位每像素
红色掩码= 0x00ff0000
绿色掩码= 0x0000ff00
Blue Mask = 0x000000ff
模式4:1024x768 @ 60Hz,每像素32位
红色遮罩= 0x00ff0000
绿色遮罩= 0x0000ff00
蓝色遮罩= 0x000000ff
模式5:800x600 @ 60Hz,32位每像素
红色遮罩= 0x00ff0000
绿色遮罩= 0x0000ff00
蓝色遮罩= 0x000000ff
模式6:800x600 @ 56Hz,32位元每像素
红色遮罩= 0x00ff0000
绿色遮罩= 0x0000ff00
蓝色遮罩= 0x000000ff
模式7:640x480 @ 60Hz,32位每像素
红色面具= 0x00ff0000
绿色面具= 0x0000ff00
蓝色面具= 0x000000ff
当前分辨率:2646x1024
您可以看到SDL已经查询Xinerama并获得了我的两个显示器,但似乎没有以有用的方式回传给客户端。
可悲的是,它看起来像你需要发布到邮件列表或提交一个错误:(
Using SDL 1.3 I want to create fake fullscreen SDL_Window under linux. It is easy if i have only one display. I just got current display mode and created a window.
SDL_GetDesktopDisplayMode(0, &mode);
SDL_Window *win = SDL_CreateWindow("my window",
0,0,mode.w, mode.h,
SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS );
But when i have two displays, things get complicated. The window spreads across multiple monitors. SDL sees only one, double sized virtual display.
I tested it with this code
int num = SDL_GetNumVideoDisplays();
for( int i=0; i < num; i++ )
{
SDL_Rect displayRect;
SDL_GetDisplayBounds( i, &displayRect );
std::cout
<< "display " << i << ": x,y,w,h("
<< displayRect.x << ", "
<< displayRect.y << ", "
<< displayRect.w << ", "
<< displayRect.h << ")"
<< std::endl;
}
output:
display 0: x,y,w,h(0, 0, 2960, 1050)
But i have two displays (1680x1050 and 1280x1024).
How to force the window to stay on only one (assume main) display?
src/video/x11/SDL_x11modes.c
checks some interesting #define
s:
SDL_VIDEO_DRIVER_X11_XINERAMA
SDL_VIDEO_DRIVER_X11_XRANDR
SDL_VIDEO_DRIVER_X11_XVIDMODE
You might check include/SDL_config.h
to see which path(s) your copy is following. Rebuilding with X11MODES_DEBUG
defined may also be productive.
EDIT: Tried test/testvidinfo.c
on my system with X11MODES_DEBUG
and got this:
Built-in video drivers: x11, dummy
Video driver: x11
Number of displays: 1
Display 0: 2646x1024 at 0,0
Current mode: 2646x1024@0Hz, 32 bits-per-pixel
Red Mask = 0x00ff0000
Green Mask = 0x0000ff00
Blue Mask = 0x000000ff
X11 detected Xinerama:
xinerama 0: 1366x768+0+0
xinerama 1: 1280x1024+1366+0
XRANDR: XRRQueryVersion: V1.3
XRANDR: mode = 0[0], w = 1366, h = 768, rate = 60
XRANDR: mode = 1[0], w = 1360, h = 768, rate = 60
XRANDR: mode = 2[0], w = 1024, h = 768, rate = 60
XRANDR: mode = 3[0], w = 800, h = 600, rate = 60
XRANDR: mode = 3[1], w = 800, h = 600, rate = 56
XRANDR: mode = 4[0], w = 640, h = 480, rate = 60
Xinerama is enabled
XRandR is enabled
Fullscreen video modes:
Mode 0: 2646x1024@0Hz, 32 bits-per-pixel
Red Mask = 0x00ff0000
Green Mask = 0x0000ff00
Blue Mask = 0x000000ff
Mode 1: 1366x768@60Hz, 32 bits-per-pixel
Red Mask = 0x00ff0000
Green Mask = 0x0000ff00
Blue Mask = 0x000000ff
Mode 2: 1366x768@0Hz, 32 bits-per-pixel
Red Mask = 0x00ff0000
Green Mask = 0x0000ff00
Blue Mask = 0x000000ff
Mode 3: 1360x768@60Hz, 32 bits-per-pixel
Red Mask = 0x00ff0000
Green Mask = 0x0000ff00
Blue Mask = 0x000000ff
Mode 4: 1024x768@60Hz, 32 bits-per-pixel
Red Mask = 0x00ff0000
Green Mask = 0x0000ff00
Blue Mask = 0x000000ff
Mode 5: 800x600@60Hz, 32 bits-per-pixel
Red Mask = 0x00ff0000
Green Mask = 0x0000ff00
Blue Mask = 0x000000ff
Mode 6: 800x600@56Hz, 32 bits-per-pixel
Red Mask = 0x00ff0000
Green Mask = 0x0000ff00
Blue Mask = 0x000000ff
Mode 7: 640x480@60Hz, 32 bits-per-pixel
Red Mask = 0x00ff0000
Green Mask = 0x0000ff00
Blue Mask = 0x000000ff
Current resolution: 2646x1024
You can see SDL has queried Xinerama and gotten both of my monitors but doesn't seem to communicate that back to the client in a useful manner.
Sadly it looks like you need to post to the mailing list or file a bug :(
这篇关于SDL假的全屏模式在双显示器设置下linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!