使用SDL_SetVideoMode时,有没有办法获取内部SDL_Window指针或ID?
如果您使用 SDL_SetVideoMode() 创建窗口,您将返回一个表面,而不是窗口句柄。有没有办法获取SDL_Window句柄?我知道有一个 SDL_GetWindowFromID 函数,但我也不确定如何获取 ID,除了 SDL_GetWindowID 函数之外,这需要我已经拥有窗口句柄。
有什么建议吗?请注意,保持跨平台可移植性非常重要,因此如果可能的话,我更愿意坚持使用内置的 SDL 功能。
如果有帮助的话,我正在尝试获取和设置窗口位置和窗口大小,而这些函数需要窗口句柄。
谢谢!
编辑:我还应该提到,我正在根据用户的请求更改视频模式,因此我不能只使用默认 ID 1,因为每次调用 SDL_SetVideoMode() 时该 ID 都会更改。
If you create a window by using SDL_SetVideoMode(), you are returned a surface, not a window handle. Is there a way to get the SDL_Window handle? I know there is a SDL_GetWindowFromID function, but I'm also not sure how to get the ID, other than the SDL_GetWindowID function, which would require me to already have the window handle.
Any suggestions? Note that it is very important that I maintain cross platform portability, so I prefer to stick with built in SDL functionality if at all possible.
If it helps any, I'm trying to get and set the window position and window size, and those functions require a window handle.
Thanks!
EDIT: I should mention also that I am changing video modes at the user's request, so I cannot just use the default ID of 1, since this ID changes every time I call SDL_SetVideoMode().
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在 Windows 的 SDL-1.2.15 中遇到了同样的问题,但问题通过
GetActiveWindow
解决了。您可以像这样获取 SDL 窗口句柄:
请参阅:
GetActiveWindow 函数
I had the same problem with SDL-1.2.15 for windows ,but the problem solved by
GetActiveWindow
.You can get SDL window handle like this :
See this :
GetActiveWindow function
我遇到了这个问题 - 旧的 SDL 1.2 仅使用一个窗口,因此它将句柄保留在自己身上。这是我通过阅读源代码找到的方法:
包含 SDL_syswm.h 然后使用
SDL_GetWMInfo
获取窗口句柄,例如我在 Windows 中获取句柄的代码:
I had this exact problem - old SDL 1.2 only uses one window, so it keeps the handle to itself. Here's the method I found from reading the source code:
Include SDL_syswm.h then get the window handle using
SDL_GetWMInfo
e.g. my code for getting the handle in Windows:
SDL_SetVideoMode
返回基于视频帧缓冲区的表面,不在窗口上(就像SDL_GetVideoSurface
)。您似乎假设所有表面都对应于窗口,但事实并非如此。SDL_SetVideoMode
returns a surface based on the video frame buffer, not on a window (just likeSDL_GetVideoSurface
). You seem to assume that all surfaces correspond to windows, but that is not the case.