开发者

When using SDL_SetVideoMode, is there a way to get the internal SDL_Window pointer or 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开发者_JAVA百科 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().


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 :

...
screen = SDL_SetVideoMode(w, h, 0, flags);
...
HWND hnd= GetActiveWindow();

See this : GetActiveWindow function


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_SysWMinfo wmInfo;
SDL_GetWMInfo(&wmInfo);
HWND window = wmInfo.window;


SDL_SetVideoMode returns a surface based on the video frame buffer, not on a window (just like SDL_GetVideoSurface). You seem to assume that all surfaces correspond to windows, but that is not the case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜