mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-14 00:21:34 +00:00
Remove support for SDL2 2.0.5 and earlier
This commit is contained in:
parent
f676cd81d2
commit
e4ada10e78
2 changed files with 29 additions and 44 deletions
|
@ -179,6 +179,19 @@ else()
|
|||
if( NOT APPLE OR NOT OSX_COCOA_BACKEND )
|
||||
find_package( SDL2 REQUIRED CONFIG )
|
||||
include_directories( "${SDL2_INCLUDE_DIRS}" )
|
||||
set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}" "${SDL2_INCLUDE_DIRS}")
|
||||
CHECK_CXX_SOURCE_COMPILES("#include <SDL_version.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
#if !SDL_VERSION_ATLEAST(2, 0, 6)
|
||||
#error \"Only SDL 2.0.6 or later is supported.\"
|
||||
#endif
|
||||
return 0;
|
||||
}" SDL2_MIN_VERSION )
|
||||
if (NOT SDL2_MIN_VERSION)
|
||||
message(SEND_ERROR "Only SDL 2.0.6 or later is supported.")
|
||||
endif()
|
||||
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${SDL2_LIBRARIES}" )
|
||||
endif()
|
||||
|
||||
|
|
|
@ -61,12 +61,9 @@
|
|||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
// Requires SDL 2.0.6 or newer
|
||||
//#define SDL2_STATIC_LIBRARY
|
||||
|
||||
#if defined SDL2_STATIC_LIBRARY && defined HAVE_VULKAN
|
||||
#if defined HAVE_VULKAN
|
||||
#include <SDL_vulkan.h>
|
||||
#endif // SDL2_STATIC_LIBRARY && HAVE_VULKAN
|
||||
#endif // HAVE_VULKAN
|
||||
|
||||
// TYPES -------------------------------------------------------------------
|
||||
|
||||
|
@ -118,30 +115,7 @@ CCMD(vid_list_sdl_render_drivers)
|
|||
|
||||
namespace Priv
|
||||
{
|
||||
#ifdef SDL2_STATIC_LIBRARY
|
||||
|
||||
#define SDL2_OPTIONAL_FUNCTION(RESULT, NAME, ...) \
|
||||
RESULT(*NAME)(__VA_ARGS__) = SDL_ ## NAME
|
||||
|
||||
#else // !SDL2_STATIC_LIBRARY
|
||||
|
||||
FModule library("SDL2");
|
||||
|
||||
#define SDL2_OPTIONAL_FUNCTION(RESULT, NAME, ...) \
|
||||
static TOptProc<library, RESULT(*)(__VA_ARGS__)> NAME("SDL_" #NAME)
|
||||
|
||||
#endif // SDL2_STATIC_LIBRARY
|
||||
|
||||
SDL2_OPTIONAL_FUNCTION(int, GetWindowBordersSize, SDL_Window *window, int *top, int *left, int *bottom, int *right);
|
||||
#ifdef HAVE_VULKAN
|
||||
SDL2_OPTIONAL_FUNCTION(void, Vulkan_GetDrawableSize, SDL_Window *window, int *width, int *height);
|
||||
SDL2_OPTIONAL_FUNCTION(SDL_bool, Vulkan_GetInstanceExtensions, SDL_Window *window, unsigned int *count, const char **names);
|
||||
SDL2_OPTIONAL_FUNCTION(SDL_bool, Vulkan_CreateSurface, SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface);
|
||||
#endif
|
||||
|
||||
#undef SDL2_OPTIONAL_FUNCTION
|
||||
|
||||
static const uint32_t VulkanWindowFlag = 0x1000'0000;
|
||||
static const uint32_t VulkanWindowFlag = SDL_WINDOW_VULKAN;
|
||||
|
||||
SDL_Window *window;
|
||||
bool vulkanEnabled;
|
||||
|
@ -240,22 +214,21 @@ void I_GetVulkanDrawableSize(int *width, int *height)
|
|||
{
|
||||
assert(Priv::vulkanEnabled);
|
||||
assert(Priv::window != nullptr);
|
||||
assert(Priv::Vulkan_GetDrawableSize);
|
||||
Priv::Vulkan_GetDrawableSize(Priv::window, width, height);
|
||||
SDL_Vulkan_GetDrawableSize(Priv::window, width, height);
|
||||
}
|
||||
|
||||
bool I_GetVulkanPlatformExtensions(unsigned int *count, const char **names)
|
||||
{
|
||||
assert(Priv::vulkanEnabled);
|
||||
assert(Priv::window != nullptr);
|
||||
return Priv::Vulkan_GetInstanceExtensions(Priv::window, count, names) == SDL_TRUE;
|
||||
return SDL_Vulkan_GetInstanceExtensions(Priv::window, count, names) == SDL_TRUE;
|
||||
}
|
||||
|
||||
bool I_CreateVulkanSurface(VkInstance instance, VkSurfaceKHR *surface)
|
||||
{
|
||||
assert(Priv::vulkanEnabled);
|
||||
assert(Priv::window != nullptr);
|
||||
return Priv::Vulkan_CreateSurface(Priv::window, instance, surface) == SDL_TRUE;
|
||||
return SDL_Vulkan_CreateSurface(Priv::window, instance, surface) == SDL_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -419,20 +392,19 @@ SDLVideo::SDLVideo ()
|
|||
return;
|
||||
}
|
||||
|
||||
#ifndef SDL2_STATIC_LIBRARY
|
||||
// Load optional SDL functions
|
||||
if (!Priv::library.IsLoaded())
|
||||
// Fail gracefully if we somehow reach here after linking against a SDL2 library older than 2.0.6.
|
||||
SDL_version sdlver;
|
||||
SDL_GetVersion(&sdlver);
|
||||
if (!(sdlver.patch >= 6))
|
||||
{
|
||||
Priv::library.Load({ "libSDL2-2.0.so.0", "libSDL2-2.0.so", "libSDL2.so" });
|
||||
I_FatalError("Only SDL 2.0.6 or later is supported.");
|
||||
}
|
||||
#endif // !SDL2_STATIC_LIBRARY
|
||||
|
||||
#ifdef HAVE_SOFTPOLY
|
||||
Priv::softpolyEnabled = vid_preferbackend == 2;
|
||||
#endif
|
||||
#ifdef HAVE_VULKAN
|
||||
Priv::vulkanEnabled = vid_preferbackend == 1
|
||||
&& Priv::Vulkan_GetDrawableSize && Priv::Vulkan_GetInstanceExtensions && Priv::Vulkan_CreateSurface;
|
||||
Priv::vulkanEnabled = vid_preferbackend == 1;
|
||||
|
||||
if (Priv::vulkanEnabled)
|
||||
{
|
||||
|
@ -539,7 +511,7 @@ int SystemBaseFrameBuffer::GetClientWidth()
|
|||
|
||||
#ifdef HAVE_VULKAN
|
||||
assert(Priv::vulkanEnabled);
|
||||
Priv::Vulkan_GetDrawableSize(Priv::window, &width, nullptr);
|
||||
SDL_Vulkan_GetDrawableSize(Priv::window, &width, nullptr);
|
||||
#endif
|
||||
|
||||
return width;
|
||||
|
@ -562,7 +534,7 @@ int SystemBaseFrameBuffer::GetClientHeight()
|
|||
|
||||
#ifdef HAVE_VULKAN
|
||||
assert(Priv::vulkanEnabled);
|
||||
Priv::Vulkan_GetDrawableSize(Priv::window, nullptr, &height);
|
||||
SDL_Vulkan_GetDrawableSize(Priv::window, nullptr, &height);
|
||||
#endif
|
||||
|
||||
return height;
|
||||
|
@ -745,10 +717,10 @@ void ProcessSDLWindowEvent(const SDL_WindowEvent &event)
|
|||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_MOVED:
|
||||
if (!vid_fullscreen && Priv::GetWindowBordersSize)
|
||||
if (!vid_fullscreen)
|
||||
{
|
||||
int top = 0, left = 0;
|
||||
Priv::GetWindowBordersSize(Priv::window, &top, &left, nullptr, nullptr);
|
||||
SDL_GetWindowBordersSize(Priv::window, &top, &left, nullptr, nullptr);
|
||||
win_x = event.data1-left;
|
||||
win_y = event.data2-top;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue