Simplify VSync toggling (#977)

* Simplify VSync toggling

* Bump required SDL version to 2.0.18

SDL_RenderSetVSync requires it, see:
https://wiki.libsdl.org/SDL2/SDL_RenderSetVSync

* remove win_version.c

---------

Co-authored-by: Roman Fomin <rfomin@gmail.com>
This commit is contained in:
Julia Nechaevskaya 2023-04-08 21:41:31 +03:00 committed by GitHub
parent ce8f70ff00
commit c642d27993
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 9 additions and 95 deletions

View File

@ -72,7 +72,7 @@ option(CMAKE_FIND_PACKAGE_PREFER_CONFIG
"Lookup package config files before using find modules" ON)
# Library requirements.
find_package(SDL2 2.0.7 REQUIRED)
find_package(SDL2 2.0.18 REQUIRED)
find_package(SDL2_net REQUIRED)
find_package(OpenAL REQUIRED)
find_package(SndFile REQUIRED)

View File

@ -128,8 +128,7 @@ set(WOOF_SOURCES
if(WIN32)
list(APPEND
WOOF_SOURCES
i_winmusic.c
../win32/win_version.c ../win32/win_version.h)
i_winmusic.c)
if(MSVC)
list(APPEND
WOOF_SOURCES

View File

@ -43,10 +43,6 @@
#include "icon.c"
#ifdef _WIN32
#include "../win32/win_version.h"
#endif
int SCREENWIDTH, SCREENHEIGHT;
int NONWIDEWIDTH; // [crispy] non-widescreen SCREENWIDTH
int WIDESCREENDELTA; // [crispy] horizontal widescreen offset
@ -694,6 +690,11 @@ void I_ToggleToggleFullScreen(void)
I_ToggleFullScreen();
}
void I_ToggleVsync(void)
{
SDL_RenderSetVSync(renderer, use_vsync);
}
// killough 3/22/98: rewritten to use interrupt-driven keyboard queue
void I_GetEvent(void)
@ -1560,16 +1561,6 @@ static void I_InitGraphicsMode(void)
I_GetWindowPosition(&window_x, &window_y, v_w, v_h);
#ifdef _WIN32
// [JN] Windows 11 idiocy. Indicate that window using OpenGL mode (while it's
// a Direct3D in fact), so SDL texture will not be freezed upon vsync
// toggling.
if (I_CheckWindows11())
{
flags |= SDL_WINDOW_OPENGL;
}
#endif
// [FG] create rendering window
if (screen == NULL)
{

View File

@ -63,6 +63,7 @@ int I_ScanCode2DoomCode(int); // killough
void I_ResetScreen(void); // killough 10/98
void I_ToggleToggleFullScreen(void); // [FG] fullscreen mode menu toggle
void I_ToggleVsync(void); // [JN] Calls native SDL vsync toggle
extern int use_vsync; // killough 2/8/98: controls whether vsync is called
extern int disk_icon; // killough 10/98

View File

@ -3948,7 +3948,7 @@ setup_menu_t gen_settings1[] = { // General Settings screen1
M_Y + gen1_fpslimit*M_SPC, {"fpslimit"}, 0, M_CoerceFPSLimit},
{"Vertical Sync", S_YESNO, m_null, M_X,
M_Y+ gen1_vsync*M_SPC, {"use_vsync"}, 0, I_ResetScreen},
M_Y+ gen1_vsync*M_SPC, {"use_vsync"}, 0, I_ToggleVsync},
{"Gamma Correction", S_THERMO, m_null, M_X_THRM,
M_Y+ gen1_gamma*M_SPC, {"gamma2"}, 0, M_ResetGamma, gamma_strings},

View File

@ -1,50 +0,0 @@
//
// Copyright(C) 2022 Roman Fomin
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// DESCRIPTION:
// Check Windows version
//
#include "win_version.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
typedef long (__stdcall *PRTLGETVERSION)(PRTL_OSVERSIONINFOEXW);
int I_CheckWindows11(void)
{
PRTLGETVERSION pRtlGetVersion = (PRTLGETVERSION)GetProcAddress(
GetModuleHandle("ntdll.dll"), "RtlGetVersion");
if (pRtlGetVersion)
{
OSVERSIONINFOEXW info;
ZeroMemory(&info, sizeof(OSVERSIONINFOEXW));
info.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
pRtlGetVersion((PRTL_OSVERSIONINFOEXW)&info);
if (info.dwPlatformId == VER_PLATFORM_WIN32_NT)
{
if (info.dwMajorVersion == 10)
{
if (info.dwBuildNumber >= 22000)
return 1;
}
}
}
return 0;
}

View File

@ -1,27 +0,0 @@
//
// Copyright(C) 2022 Roman Fomin
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// DESCRIPTION:
// Check Windows version
//
#ifndef __WIN_WIN_VERSION__
#define __WIN_WIN_VERSION__
#ifdef _WIN32
int I_CheckWindows11(void);
#endif
#endif