Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ jobs:
with:
arch: ${{ matrix.platform.arch }}
branch: 'latest-stable'
packages: build-base cmake git mold sdl2-dev lzo-dev libjpeg-turbo-dev openal-soft-dev libogg-dev libtheora-dev libvorbis-dev
packages: build-base cmake git mold sdl3-dev lzo-dev libjpeg-turbo-dev openal-soft-dev libogg-dev libtheora-dev libvorbis-dev

- name: Install Ubuntu packages
if: ${{ matrix.platform.name == 'Ubuntu' }}
run: |
sudo dpkg --add-architecture ${{ matrix.platform.arch }}
sudo apt-get update -qq
sudo apt-get install -qq -y \
libsdl2-dev:${{ matrix.platform.arch }} \
libsdl3-dev:${{ matrix.platform.arch }} \
liblzo2-dev:${{ matrix.platform.arch }} \
libjpeg-dev:${{ matrix.platform.arch }} \
libopenal-dev:${{ matrix.platform.arch }} \
Expand All @@ -134,11 +134,11 @@ jobs:
if: ${{ startsWith(matrix.platform.name, 'macOS') }}
run: |
brew update
brew install sdl2 lzo libogg libvorbis theora
brew install sdl3 lzo libogg libvorbis theora

- name: Install Fedora packages
if: ${{ matrix.platform.name == 'Fedora' }}
run: dnf install -y git gcc gcc-c++ rpmdevtools cmake SDL2-devel lzo-devel libjpeg-turbo-devel openal-soft-devel libogg-devel libtheora-devel libvorbis-devel
run: dnf install -y git gcc gcc-c++ rpmdevtools cmake SDL3-devel lzo-devel libjpeg-turbo-devel openal-soft-devel libogg-devel libtheora-devel libvorbis-devel

- name: Set environment variables
if: ${{ matrix.platform.cc != '' && matrix.platform.cxx != '' }}
Expand Down Expand Up @@ -185,16 +185,16 @@ jobs:
matrix:
platform:
- { name: FreeBSD, os: freebsd, os-version: '14.3', arch: x86_64,
install-cmd: "sudo pkg update && sudo pkg install -y cmake sdl2 lzo2 jpeg-turbo openal-soft libogg libtheora libvorbis"
install-cmd: "sudo pkg update && sudo pkg install -y cmake sdl3 lzo2 jpeg-turbo openal-soft libogg libtheora libvorbis"
}
- { name: OpenBSD, os: openbsd, os-version: '7.6', arch: x86_64,
install-cmd: "sudo pkg_add cmake SDL2 lzo2 jpeg openal libogg libtheora libvorbis",
install-cmd: "sudo pkg_add cmake SDL3 lzo2 jpeg openal libogg libtheora libvorbis",
}
- { name: NetBSD, os: netbsd, os-version: '10.1', arch: x86_64,
install-cmd: "sudo pkgin -y install cmake SDL2 lzo libjpeg-turbo openal-soft libogg libtheora libvorbis",
install-cmd: "sudo pkgin -y install cmake SDL3 lzo libjpeg-turbo openal-soft libogg libtheora libvorbis",
}
#- { name: Haiku, os: haiku, os-version: 'r1beta5', arch: x86_64,
# install-cmd: "sudo pkgman install -y cmake libsdl2_devel lzo_devel libjpeg_turbo_devel openal_devel libogg_devel libtheora_devel libvorbis_devel",
# install-cmd: "sudo pkgman install -y cmake libsdl3_devel lzo_devel libjpeg_turbo_devel openal_devel libogg_devel libtheora_devel libvorbis_devel",
# }
configuration: [Debug, Release]

Expand Down
2 changes: 1 addition & 1 deletion cmake/XRay.Compiler.GNULike.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
endif()

if (NOT WIN32)
find_package(SDL2 2.0.18 REQUIRED)
find_package(SDL3 3.4.0 REQUIRED CONFIG COMPONENTS SDL3)
find_package(OpenAL REQUIRED)
find_package(JPEG)
find_package(Ogg REQUIRED)
Expand Down
3 changes: 3 additions & 0 deletions cmake/XRay.Compiler.MSVC.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
include_guard()

# Dependencies
find_package(SDL3 3.4.0 REQUIRED CONFIG COMPONENTS SDL3)

# The MSVC compiler settings:
# Set properties:
set(CMAKE_VS_USE_DEBUG_LIBRARIES "$<CONFIG:Debug>")
Expand Down
4 changes: 2 additions & 2 deletions src/Common/PlatformApple.inl
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ typedef dirent DirEntryType;
#define O_SEQUENTIAL 0
#define SH_DENYWR 0

#if __has_include(<SDL_stdinc.h>)
#include <SDL_stdinc.h>
#if __has_include(<SDL3/SDL_stdinc.h>)
#include <SDL3/SDL_stdinc.h>
#define itoa SDL_itoa
#define _itoa_s SDL_itoa
#else
Expand Down
4 changes: 2 additions & 2 deletions src/Common/PlatformBSD.inl
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ typedef dirent DirEntryType;
#define O_SEQUENTIAL 0
#define SH_DENYWR 0

#if __has_include(<SDL_stdinc.h>)
#include <SDL_stdinc.h>
#if __has_include(<SDL3/SDL_stdinc.h>)
#include <SDL3/SDL_stdinc.h>
#define itoa SDL_itoa
#define _itoa_s SDL_itoa
#else
Expand Down
4 changes: 2 additions & 2 deletions src/Common/PlatformLinux.inl
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ typedef dirent DirEntryType;
#define O_SEQUENTIAL 0
#define SH_DENYWR 0

#if __has_include(<SDL_stdinc.h>)
#include <SDL_stdinc.h>
#if __has_include(<SDL3/SDL_stdinc.h>)
#include <SDL3/SDL_stdinc.h>
#define itoa SDL_itoa
#define _itoa_s SDL_itoa
#else
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/xr_effgamma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ void CGammaControl::Update() const
#endif
u16 red[256], green[256], blue[256];
GenLUT(red, green, blue, 256);
SDL_SetWindowGammaRamp(Device.m_sdlWnd, red, green, blue);
// SDL3 removed window gamma ramp control; keep data prepared for future backends.
}
} // namespace xray::render::RENDER_NAMESPACE
11 changes: 4 additions & 7 deletions src/Layers/xrRenderDX11/dx11HW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "StateManager/dx11SamplerStateCache.h"
#include "dx11TextureUtils.h"

#include <SDL_syswm.h>
#include <SDL3/SDL_properties.h>

namespace xray::render::RENDER_NAMESPACE
{
Expand Down Expand Up @@ -241,18 +241,15 @@ void CHW::CreateDevice(SDL_Window* sdlWnd)
}
}

SDL_SysWMinfo info;
SDL_VERSION(&info.version);

if (!SDL_GetWindowWMInfo(sdlWnd, &info))
const SDL_PropertiesID props = SDL_GetWindowProperties(sdlWnd);
const HWND hwnd = static_cast<HWND>(SDL_GetPointerProperty(props, SDL_PROP_WINDOW_WIN32_HWND_POINTER, nullptr));
if (!hwnd)
{
Msg("! Failed to retrieve SDL window handle: %s", SDL_GetError());
Valid = false;
return;
}

const HWND hwnd = info.info.win.window;

if (!CreateSwapChain2(hwnd))
{
if (!CreateSwapChain(hwnd))
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderDX11/dx11HW.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Layers/xrRender/HWCaps.h"
#include "Layers/xrRender/stats_manager.h"

#include <SDL.h>
#include <SDL3/SDL.h>

namespace xray::render::RENDER_NAMESPACE
{
Expand Down
17 changes: 6 additions & 11 deletions src/Layers/xrRenderGL/glHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void UpdateVSync()
if (psDeviceFlags.test(rsVSync))
{
// Try adaptive vsync first
if (SDL_GL_SetSwapInterval(-1) == -1)
if (!SDL_GL_SetSwapInterval(-1))
SDL_GL_SetSwapInterval(1);
}
else
Expand Down Expand Up @@ -80,12 +80,7 @@ void CHW::CreateDevice(SDL_Window* hWnd)

R_ASSERT(m_window);

// Choose the closest pixel format
SDL_DisplayMode mode;
SDL_GetWindowDisplayMode(m_window, &mode);
mode.format = SDL_PIXELFORMAT_RGBA8888;
// Apply the pixel format to the device context
SDL_SetWindowDisplayMode(m_window, &mode);
// Display mode selection is handled via SDL_SetWindowFullscreenMode in device setup.

Caps.fTarget = D3DFMT_A8R8G8B8;
Caps.fDepth = D3DFMT_D24S8;
Expand All @@ -98,7 +93,7 @@ void CHW::CreateDevice(SDL_Window* hWnd)
return;
}

if (MakeContextCurrent(IRender::PrimaryContext) != 0)
if (!MakeContextCurrent(IRender::PrimaryContext))
{
Log("! OpenGL: could not make context current:", SDL_GetError());
return;
Expand Down Expand Up @@ -158,7 +153,7 @@ void CHW::DestroyDevice()
if (context == m_context)
SDL_GL_MakeCurrent(nullptr, nullptr);

SDL_GL_DeleteContext(m_context);
SDL_GL_DestroyContext(m_context);
m_context = nullptr;
}

Expand Down Expand Up @@ -206,7 +201,7 @@ IRender::RenderContext CHW::GetCurrentContext() const
return IRender::NoContext;
}

int CHW::MakeContextCurrent(IRender::RenderContext context) const
bool CHW::MakeContextCurrent(IRender::RenderContext context) const
{
switch (context)
{
Expand All @@ -219,7 +214,7 @@ int CHW::MakeContextCurrent(IRender::RenderContext context) const
default:
NODEFAULT;
}
return -1;
return false;
}

void CHW::UpdateViews()
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderGL/glHW.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CHW
void SetPrimaryAttributes(u32& windowFlags);

IRender::RenderContext GetCurrentContext() const;
int MakeContextCurrent(IRender::RenderContext context) const;
bool MakeContextCurrent(IRender::RenderContext context) const;

static std::pair<u32, u32> GetSurfaceSize();
DeviceState GetDeviceState() const;
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_GL/r2_test_hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class sdl_window_test_helper
{
u32 flags{};
m_hw.SetPrimaryAttributes(flags);
m_window = SDL_CreateWindow("TestOpenGLWindow", 0, 0, 1, 1, SDL_WINDOW_HIDDEN | flags);
m_window = SDL_CreateWindow("TestOpenGLWindow", 1, 1, SDL_WINDOW_HIDDEN | flags);
if (!m_window)
{
Log("~ Cannot create helper window for OpenGL test:", SDL_GetError());
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRenderPC_GL/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "xrParticles/psystem.h"

#include "glad/gl.h"
#include <SDL_opengl.h>
#include <SDL_opengl_glext.h>
#include <SDL3/SDL_opengl.h>
#include <SDL3/SDL_opengl_glext.h>

#define R_GL 0
#define R_R1 1
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender_R2/r2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ IRender::RenderContext CRender::GetCurrentContext() const

void CRender::MakeContextCurrent(RenderContext context)
{
R_ASSERT3(HW.MakeContextCurrent(context) == 0,
R_ASSERT3(HW.MakeContextCurrent(context),
"Failed to switch OpenGL context", SDL_GetError());
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/editors/xrWeatherEngine/engine_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ void engine_impl::disconnect() { Console->Execute("quit"); }

bool engine_impl::quit_requested() const
{
return SDL_QuitRequested();
SDL_PumpEvents();
return SDL_PeepEvents(nullptr, 0, SDL_PEEKEVENT, SDL_EVENT_QUIT, SDL_EVENT_QUIT) > 0;
}

void engine_impl::value(pcstr value, shared_str& result) { result = value; }
Expand Down Expand Up @@ -395,4 +396,3 @@ void engine_impl::reload_weathers()
if (environment.Current[1]->exec_time == game_time)
environment.SelectEnvs(game_time + .1f);
}

2 changes: 1 addition & 1 deletion src/xrCore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ target_link_libraries(xrCore
PUBLIC
pthread
$<$<PLATFORM_ID:FreeBSD,OpenBSD,NetBSD,DragonFlyBSD>:execinfo>
SDL2::SDL2
SDL3::SDL3

PRIVATE
xrMiscMath
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/LocatorAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <sys/stat.h>
#include <sys/utime.h>
#elif defined(XR_PLATFORM_POSIX)
#include <SDL.h>
#include <SDL3/SDL.h>
#include <glob.h>
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/ModuleLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#if defined(XR_PLATFORM_LINUX) || defined(XR_PLATFORM_BSD)
#include <dlfcn.h>
#else
#include <SDL_loadso.h>
#include <SDL3/SDL_loadso.h>
#endif

#include "ModuleLookup.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/Threading/TaskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "ScopeLock.hpp"

#include <thread>
#include <SDL_events.h>
#include <SDL3/SDL_events.h>

#include "Math/fast_lc16.hpp"

Expand Down
11 changes: 8 additions & 3 deletions src/xrCore/_math.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "stdafx.h"

#include <thread>
#include <SDL.h>
#include <SDL3/SDL.h>

// Initialized on startup
XRCORE_API Fmatrix Fidentity;
Expand Down Expand Up @@ -59,9 +59,7 @@ void _initialize_cpu()
};

// x86
listFeature("RDTSC", SDL_HasRDTSC());
listFeature("MMX", SDL_HasMMX());
listFeature("3DNow!", SDL_Has3DNow());
listFeature("SSE", SDL_HasSSE());
listFeature("SSE2", CPU::HasSSE2);
listFeature("SSE3", SDL_HasSSE3());
Expand Down Expand Up @@ -98,6 +96,13 @@ void _initialize_cpu()
#define _MM_SET_DENORMALS_ZERO_MODE(mode)
#else
#include <xmmintrin.h>
#if defined(__SSE3__) || defined(_MSC_VER)
#include <pmmintrin.h>
#endif
#ifndef _MM_DENORMALS_ZERO_ON
#define _MM_DENORMALS_ZERO_ON 0
#define _MM_SET_DENORMALS_ZERO_MODE(mode) ((void)0)
#endif
#endif

static BOOL _denormals_are_zero_supported = TRUE;
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/os_clipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "os_clipboard.h"
#include "Text/StringConversion.hpp"

#include <SDL.h>
#include <SDL3/SDL.h>

#include <locale>

Expand Down
24 changes: 15 additions & 9 deletions src/xrCore/xrCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "xrCore/_std_extensions.h"
#include "Threading/TaskManager.hpp"

#include <SDL.h>
#include <SDL3/SDL.h>

#if __has_include(".GitInfo.hpp")
#include ".GitInfo.hpp"
Expand Down Expand Up @@ -200,18 +200,24 @@ void xrCore::Initialize(pcstr _ApplicationName, pcstr commandLine, bool init_fs,
_splitpath(fn, dr, di, nullptr, nullptr);
strconcat(sizeof(ApplicationPath), ApplicationPath, dr, di);
#elif defined(XR_PLATFORM_POSIX)
char* base_path = SDL_GetBasePath();
if (!base_path)
const char* base_path = SDL_GetBasePath();
if (base_path)
{
SDL_strlcpy(ApplicationPath, base_path, sizeof(ApplicationPath));
}
else
{
char* pref_path = nullptr;
if (strstr(Core.Params, "-shoc") || strstr(Core.Params, "-soc"))
base_path = SDL_GetPrefPath("GSC Game World", "S.T.A.L.K.E.R. - Shadow of Chernobyl");
pref_path = SDL_GetPrefPath("GSC Game World", "S.T.A.L.K.E.R. - Shadow of Chernobyl");
else if (strstr(Core.Params, "-cs"))
base_path = SDL_GetPrefPath("GSC Game World", "S.T.A.L.K.E.R. - Clear Sky");
pref_path = SDL_GetPrefPath("GSC Game World", "S.T.A.L.K.E.R. - Clear Sky");
else
base_path = SDL_GetPrefPath("GSC Game World", "S.T.A.L.K.E.R. - Call of Pripyat");
pref_path = SDL_GetPrefPath("GSC Game World", "S.T.A.L.K.E.R. - Call of Pripyat");

SDL_strlcpy(ApplicationPath, pref_path ? pref_path : "", sizeof(ApplicationPath));
SDL_free(pref_path);
}
SDL_strlcpy(ApplicationPath, base_path, sizeof(ApplicationPath));
SDL_free(base_path);
#else
# error Select or add implementation for your platform
#endif
Expand Down Expand Up @@ -271,7 +277,7 @@ void xrCore::Initialize(pcstr _ApplicationName, pcstr commandLine, bool init_fs,

Memory._initialize();

SDL_LogSetOutputFunction(SDLLogOutput, nullptr);
SDL_SetLogOutputFunction(SDLLogOutput, nullptr);
Msg("\ncommand line %s\n", Params);
_initialize_cpu();
TaskScheduler = xr_make_unique<TaskManager>();
Expand Down
Loading
Loading