最大化SDL窗口 [英] Maximize SDL window

查看:367
本文介绍了最大化SDL窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该如何告诉SDL最大化应用程序窗口?

How should I tell SDL to maximize the application window?

我正在使用以下标志创建窗口:SDL_OPENGL | SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_RESIZABLE.

I'm creating the window with these flags: SDL_OPENGL | SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_RESIZABLE.

推荐答案

使用SDL_RESIZABLE标志时,此功能由窗口管理器控制.要模拟使用SDL最大化窗口,您需要首先确定最大化时窗口将占据的大小.然后,将带有 SDL_VIDEO_WINDOW_POS环境变量.

This functionality is controlled by the window manager when you use the SDL_RESIZABLE flag. To simulate the maximizing a window with SDL you would need to first determine the size the window would occupy when maximized. Then you would call SDL_SetVideoMode with this size after placing the window with the SDL_VIDEO_WINDOW_POS environment variable.

如果您确实确实需要最大化窗口,就像您单击最大化按钮一样,那么您将必须直接访问底层的窗口管理器(即SDL不能为您提供帮助).

If you truly need the window to be maximized as if you had clicked on the maximize button, then you will have to access the underlying window manager directly (i.e. SDL won't help you).

例如, ShowWindow 函数可以用于使用Win32 API最大化窗口.要获取由SDL创建的窗口的句柄,请使用 SDL_GetWMInfo 函数.生成的 SDL_SysWMinfo 结构包含一个 window 字段,键入HWND.该参数必须与SW_MAXIMIZE标志一起传递给ShowWindow函数.

For example, the ShowWindow function can be used to maximize a window using the Win32 API. To get a handle to the window created by SDL use the SDL_GetWMInfo function. The resulting SDL_SysWMinfo struct contains a window field of type HWND. This must be passed to the ShowWindow function along with the SW_MAXIMIZE flag.

SDL_SysWMinfo info;
SDL_VERSION(&info.version);
SDL_GetWMInfo(&info);
ShowWindow(info.window, SW_MAXIMIZE);

这篇关于最大化SDL窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆