SDL2 切换假全屏SDL_WINDOW_RESIZABLE状态
SDL2 toggle SDL_WINDOW_RESIZABLE state for fake fullscreen
要在 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出来,如果游戏在调试器中遇到断点,它可以锁定整个系统。
这就是我想出的 - 经过测试并在 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
}
SDL_SetWindowResizable()
函数是在 2016 年 10 月发布的 SDL 2.0.5 中添加的。宣布推出 SDL 2.0.5
假设你的SDL_Window指针(你从SDL_CreateWindow()
得到的)被命名为window
,使用:
/* To disable resizing: */
SDL_SetWindowResizable(window, SDL_FALSE);
/* To enable resizing: */
SDL_SetWindowResizable(window, SDL_TRUE);
相关文章:
- WebKit2GTK+ "window-object-cleared"未清除
- MFC GetDC() 断言失败 - "Not a window"
- OpenCV : 为什么"Gray window"总是生成?
- QMediaPlayer 無法在 Window 上播放歌曲
- window.display() 单独在显示的最后一个缓冲区和当前缓冲区之间切换
- opencv cv::addText exception if no window
- 我如何使用 GTK3 在 C 中调用另一个"window"
- Winapi Window窗口异常破坏多个作品
- SFML std::length_error on window.setTitle
- 请参阅Watch-Window中的原始类型定义
- 如果使用WM_PAINT样式创建 Window,则永远不会传递WS_POPUP消息
- Qt在单击按钮时调用Child-Window
- 在Visual Studio中使用Window Media Player
- Visual Studio 2015 Community - Immediate Window
- Window.h c ++如何从开关内的数组中获取按钮的索引
- 在没有 UWP 的情况下从 C++/WinRT 使用 FileOpenPicker 时出现视觉"Invalid window handle"错误
- 这是从VS window c ++项目迁移到linux项目的最有效方法
- GUI Window from CLI
- opencv 命名为 Window leak (C++ 和 opencv)
- 使用window.draw()在主SFML外部