做一个"假的"在没有模式集的SDL2中的全屏窗口,您可以使用类似的东西创建无边框,最大化窗口。
int idx = SDL_GetWindowDisplayIndex(g_displayWindow);
SDL_Rect bounds;
SDL_GetDisplayBounds(idx, &bounds);
//SDL_SetWindowResizable(g_displayWindow, SDL_FALSE);
SDL_SetWindowBordered(g_displayWindow, SDL_FALSE);
SDL_SetWindowPosition(g_displayWindow, bounds.x, bounds.y);
SDL_SetWindowSize(g_displayWindow, bounds.w, bounds.h);
对于不可调整大小的窗口,这非常有效。在使用SDL_WINDOW_RESIZABLE创建的窗口上,屏幕的底部和右边缘(在窗口上)有一个恼人的灰色边框。不幸的是,没有SDL_SetWindowResizable函数(从SDL 2.0.4开始)。如何在不重新创建窗口的情况下摆脱调整大小的边界?
SDL_WINDOW_FULLSCREEN_DESKTOP和SDL_WINDOW_FULLSCREEN都做了一个我想要避免的模式集 - 它需要更长的时间,更难以使用alt-tab,如果游戏在调试器中遇到断点,它可以锁定整个系统
答案 0 :(得分:3)
这就是我提出的 - 经过测试并在Windows上运行。
void SDL_SetWindowResizable(SDL_Window *win, SDL_bool resizable)
{
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
SDL_GetWindowWMInfo(g_displayWindow, &info);
#if WIN32
HWND hwnd = info.info.win.window;
DWORD style = GetWindowLong(hwnd, GWL_STYLE);
if (resizable)
style |= WS_THICKFRAME;
else
style &= ~WS_THICKFRAME;
SetWindowLong(hwnd, GWL_STYLE, style);
#endif
}