summaryrefslogtreecommitdiff
path: root/src/contrib/SDL-3.2.20/docs/README-windows.md
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-08-30 16:53:58 -0700
committer3gg <3gg@shellblade.net>2025-08-30 16:53:58 -0700
commit6aaedb813fa11ba0679c3051bc2eb28646b9506c (patch)
tree34acbfc9840e02cb4753e6306ea7ce978bf8b58e /src/contrib/SDL-3.2.20/docs/README-windows.md
parent8f228ade99dd3d4c8da9b78ade1815c9adf85c8f (diff)
Update to SDL3
Diffstat (limited to 'src/contrib/SDL-3.2.20/docs/README-windows.md')
-rw-r--r--src/contrib/SDL-3.2.20/docs/README-windows.md128
1 files changed, 128 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/docs/README-windows.md b/src/contrib/SDL-3.2.20/docs/README-windows.md
new file mode 100644
index 0000000..1e6d464
--- /dev/null
+++ b/src/contrib/SDL-3.2.20/docs/README-windows.md
@@ -0,0 +1,128 @@
1# Windows
2
3## Old systems
4
5WinRT, Windows Phone, and UWP are no longer supported.
6
7All desktop Windows versions, back to Windows XP, are still supported.
8
9## LLVM and Intel C++ compiler support
10
11SDL will build with the Visual Studio project files with LLVM-based compilers, such as the Intel oneAPI C++
12compiler, but you'll have to manually add the "-msse3" command line option
13to at least the SDL_audiocvt.c source file, and possibly others. This may
14not be necessary if you build SDL with CMake instead of the included Visual
15Studio solution.
16
17Details are here: https://github.com/libsdl-org/SDL/issues/5186
18
19## MinGW-w64 compiler support
20
21SDL can be built with MinGW-w64 and CMake. Minimum tested MinGW-w64 version is 8.0.3.
22
23On a Windows host, you first need to install and set up the MSYS2 environment, which provides the MinGW-w64 toolchain. Install MSYS2, typically to `C:\msys64`, and follow the instructions on the MSYS2 wiki to use the MinGW-w64 shell to update all components in the MSYS2 environment. This generally amounts to running `pacman -Syuu` from the mingw64 shell, but refer to MSYS2's documentation for more details. Once the MSYS2 environment has been updated, install the x86_64 MinGW toolchain from the mingw64 shell with the command `pacman -S mingw-w64-x86_64-toolchain`. (You can additionally install `mingw-w64-i686-toolchain` if you intend to build 32-bit binaries as well. The remainder of this section assumes you only want to build 64-bit binaries.)
24
25To build and install SDL, you can use PowerShell or any CMake-compatible IDE. First, install CMake, Ninja, and Git. These tools can be installed using any number of tools, such as the MSYS2's `pacman`, `winget`, `Chocolatey`, or by manually downloading and running the installers. Clone SDL to an appropriate location with `git` and run the following commands from the root of the cloned repository:
26
27```sh
28mkdir build
29cmake -S . -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE=build-scripts/cmake-toolchain-mingw64-x86_64.cmake
30cmake --build build --parallel
31cmake --install build --prefix C:/Libraries
32```
33
34This installs SDL to `C:\Libraries`. You can specify another directory of your choice as desired. Ensure that your `CMAKE_PREFIX_PATH` includes `C:\Libraries` when you want to build against this copy of SDL. The simplest way to do this is to pass it to CMake as an option at configuration time:
35
36```sh
37cmake .. -G Ninja -DCMAKE_PREFIX_PATH=C:/Libraries
38```
39
40You will also need to configure CMake to use the MinGW-w64 toolchain to build your own project. Here is a minimal toolchain file that you could use for this purpose:
41
42```
43set(CMAKE_SYSTEM_NAME Windows)
44set(CMAKE_SYSTEM_PROCESSOR x86_64)
45
46find_program(CMAKE_C_COMPILER NAMES x86_64-w64-mingw32-gcc REQUIRED)
47find_program(CMAKE_CXX_COMPILER NAMES x86_64-w64-mingw32-g++ REQUIRED)
48find_program(CMAKE_RC_COMPILER NAMES x86_64-w64-mingw32-windres windres REQUIRED)
49```
50
51Save this in your project and refer to it at configuration time with the option `-DCMAKE_TOOLCHAIN_FILE`.
52
53On Windows, you also need to copy `SDL3.dll` to an appropriate directory so that the game can find it at runtime. For guidance, see [README-cmake.md](README-cmake.md#how-do-i-copy-a-sdl3-dynamic-library-to-another-location).
54
55Below is a minimal `CMakeLists.txt` file to build your game linked against a system SDL that was built with the MinGW-w64 toolchain. See [README-cmake.md](README-cmake.md) for more details on including SDL in your CMake project.
56
57```cmake
58cmake_minimum_required(VERSION 3.15)
59project(mygame)
60
61find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3-shared)
62
63add_executable(mygame WIN32 mygame.c)
64target_link_libraries(mygame PRIVATE SDL3::SDL3)
65
66# On Windows, copy SDL3.dll to the build directory
67if(WIN32)
68 add_custom_command(
69 TARGET mygame POST_BUILD
70 COMMAND "${CMAKE_COMMAND}" -E copy $<TARGET_FILE:SDL3::SDL3-shared> $<TARGET_FILE_DIR:mygame>
71 VERBATIM
72 )
73endif()
74```
75
76## OpenGL ES 2.x support
77
78SDL has support for OpenGL ES 2.x under Windows via two alternative
79implementations.
80
81The most straightforward method consists in running your app in a system with
82a graphic card paired with a relatively recent (as of November of 2013) driver
83which supports the WGL_EXT_create_context_es2_profile extension. Vendors known
84to ship said extension on Windows currently include nVidia and Intel.
85
86The other method involves using the
87[ANGLE library](https://code.google.com/p/angleproject/). If an OpenGL ES 2.x
88context is requested and no WGL_EXT_create_context_es2_profile extension is
89found, SDL will try to load the libEGL.dll library provided by ANGLE.
90
91To obtain the ANGLE binaries, you can either compile from source from
92https://chromium.googlesource.com/angle/angle or copy the relevant binaries
93from a recent Chrome/Chromium install for Windows. The files you need are:
94
95- libEGL.dll
96- libGLESv2.dll
97- d3dcompiler_46.dll (supports Windows Vista or later, better shader
98 compiler) *or* d3dcompiler_43.dll (supports Windows XP or later)
99
100If you compile ANGLE from source, you can configure it so it does not need the
101d3dcompiler_* DLL at all (for details on this, see their documentation).
102However, by default SDL will try to preload the d3dcompiler_46.dll to
103comply with ANGLE's requirements. If you wish SDL to preload
104d3dcompiler_43.dll (to support Windows XP) or to skip this step at all, you
105can use the SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more
106details).
107
108Known Bugs:
109
110- SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears
111 that there's a bug in the library which prevents the window contents from
112 refreshing if this is set to anything other than the default value.
113
114## Vulkan Surface Support
115
116Support for creating Vulkan surfaces is configured on by default. To disable
117it change the value of `SDL_VIDEO_VULKAN` to 0 in `SDL_config_windows.h`. You
118must install the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) in order to
119use Vulkan graphics in your application.
120
121## Transparent Window Support
122
123SDL uses the Desktop Window Manager (DWM) to create transparent windows. DWM is
124always enabled from Windows 8 and above. Windows 7 only enables DWM with Aero Glass
125theme.
126
127However, it cannot be guaranteed to work on all hardware configurations (an example
128is hybrid GPU systems, such as NVIDIA Optimus laptops).