我在使用我的程序停用全屏模式時遇到問題。進入全屏幕會正常發生,但嘗試返回到窗口模式不起作用,唯一的影響是光標會再次顯示。SDL2:如何正確切換全屏?
這裏的MCVE/SSCCE再現這個問題對我來說:
void ToggleFullscreen(SDL_Window* Window) {
Uint32 FullscreenFlag = SDL_WINDOW_FULLSCREEN;
bool IsFullscreen = SDL_GetWindowFlags(Window) & FullscreenFlag;
SDL_SetWindowFullscreen(Window, IsFullscreen ? 0 : FullscreenFlag);
SDL_ShowCursor(IsFullscreen);
}
int main() {
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* Window = SDL_CreateWindow("",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, 0);
bool Exit = false;
for (SDL_Event Event; !Exit;) {
SDL_WaitEvent(&Event);
if (Event.type == SDL_KEYDOWN) {
switch (Event.key.keysym.sym) {
case SDLK_f: ToggleFullscreen(Window); break;
case SDLK_q: Exit = true; break;
}
}
}
SDL_DestroyWindow(Window);
SDL_Quit();
}
SDL_SetWindowFullscreen
回報0
,好像操作是成功的。我究竟做錯了什麼? (我在OS X 10.10.3上使用SDL 2.0.3。)
似乎有一個補丁在v2.0.4分支中的bug。我想我會等到它發佈。 – emlai