diff options
Diffstat (limited to 'contrib/SDL-3.2.8/docs/README-windows.md')
| -rw-r--r-- | contrib/SDL-3.2.8/docs/README-windows.md | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/docs/README-windows.md b/contrib/SDL-3.2.8/docs/README-windows.md new file mode 100644 index 0000000..1e6d464 --- /dev/null +++ b/contrib/SDL-3.2.8/docs/README-windows.md | |||
| @@ -0,0 +1,128 @@ | |||
| 1 | # Windows | ||
| 2 | |||
| 3 | ## Old systems | ||
| 4 | |||
| 5 | WinRT, Windows Phone, and UWP are no longer supported. | ||
| 6 | |||
| 7 | All desktop Windows versions, back to Windows XP, are still supported. | ||
| 8 | |||
| 9 | ## LLVM and Intel C++ compiler support | ||
| 10 | |||
| 11 | SDL will build with the Visual Studio project files with LLVM-based compilers, such as the Intel oneAPI C++ | ||
| 12 | compiler, but you'll have to manually add the "-msse3" command line option | ||
| 13 | to at least the SDL_audiocvt.c source file, and possibly others. This may | ||
| 14 | not be necessary if you build SDL with CMake instead of the included Visual | ||
| 15 | Studio solution. | ||
| 16 | |||
| 17 | Details are here: https://github.com/libsdl-org/SDL/issues/5186 | ||
| 18 | |||
| 19 | ## MinGW-w64 compiler support | ||
| 20 | |||
| 21 | SDL can be built with MinGW-w64 and CMake. Minimum tested MinGW-w64 version is 8.0.3. | ||
| 22 | |||
| 23 | On 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 | |||
| 25 | To 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 | ||
| 28 | mkdir build | ||
| 29 | cmake -S . -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE=build-scripts/cmake-toolchain-mingw64-x86_64.cmake | ||
| 30 | cmake --build build --parallel | ||
| 31 | cmake --install build --prefix C:/Libraries | ||
| 32 | ``` | ||
| 33 | |||
| 34 | This 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 | ||
| 37 | cmake .. -G Ninja -DCMAKE_PREFIX_PATH=C:/Libraries | ||
| 38 | ``` | ||
| 39 | |||
| 40 | You 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 | ``` | ||
| 43 | set(CMAKE_SYSTEM_NAME Windows) | ||
| 44 | set(CMAKE_SYSTEM_PROCESSOR x86_64) | ||
| 45 | |||
| 46 | find_program(CMAKE_C_COMPILER NAMES x86_64-w64-mingw32-gcc REQUIRED) | ||
| 47 | find_program(CMAKE_CXX_COMPILER NAMES x86_64-w64-mingw32-g++ REQUIRED) | ||
| 48 | find_program(CMAKE_RC_COMPILER NAMES x86_64-w64-mingw32-windres windres REQUIRED) | ||
| 49 | ``` | ||
| 50 | |||
| 51 | Save this in your project and refer to it at configuration time with the option `-DCMAKE_TOOLCHAIN_FILE`. | ||
| 52 | |||
| 53 | On 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 | |||
| 55 | Below 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 | ||
| 58 | cmake_minimum_required(VERSION 3.15) | ||
| 59 | project(mygame) | ||
| 60 | |||
| 61 | find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3-shared) | ||
| 62 | |||
| 63 | add_executable(mygame WIN32 mygame.c) | ||
| 64 | target_link_libraries(mygame PRIVATE SDL3::SDL3) | ||
| 65 | |||
| 66 | # On Windows, copy SDL3.dll to the build directory | ||
| 67 | if(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 | ) | ||
| 73 | endif() | ||
| 74 | ``` | ||
| 75 | |||
| 76 | ## OpenGL ES 2.x support | ||
| 77 | |||
| 78 | SDL has support for OpenGL ES 2.x under Windows via two alternative | ||
| 79 | implementations. | ||
| 80 | |||
| 81 | The most straightforward method consists in running your app in a system with | ||
| 82 | a graphic card paired with a relatively recent (as of November of 2013) driver | ||
| 83 | which supports the WGL_EXT_create_context_es2_profile extension. Vendors known | ||
| 84 | to ship said extension on Windows currently include nVidia and Intel. | ||
| 85 | |||
| 86 | The other method involves using the | ||
| 87 | [ANGLE library](https://code.google.com/p/angleproject/). If an OpenGL ES 2.x | ||
| 88 | context is requested and no WGL_EXT_create_context_es2_profile extension is | ||
| 89 | found, SDL will try to load the libEGL.dll library provided by ANGLE. | ||
| 90 | |||
| 91 | To obtain the ANGLE binaries, you can either compile from source from | ||
| 92 | https://chromium.googlesource.com/angle/angle or copy the relevant binaries | ||
| 93 | from 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 | |||
| 100 | If you compile ANGLE from source, you can configure it so it does not need the | ||
| 101 | d3dcompiler_* DLL at all (for details on this, see their documentation). | ||
| 102 | However, by default SDL will try to preload the d3dcompiler_46.dll to | ||
| 103 | comply with ANGLE's requirements. If you wish SDL to preload | ||
| 104 | d3dcompiler_43.dll (to support Windows XP) or to skip this step at all, you | ||
| 105 | can use the SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more | ||
| 106 | details). | ||
| 107 | |||
| 108 | Known 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 | |||
| 116 | Support for creating Vulkan surfaces is configured on by default. To disable | ||
| 117 | it change the value of `SDL_VIDEO_VULKAN` to 0 in `SDL_config_windows.h`. You | ||
| 118 | must install the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) in order to | ||
| 119 | use Vulkan graphics in your application. | ||
| 120 | |||
| 121 | ## Transparent Window Support | ||
| 122 | |||
| 123 | SDL uses the Desktop Window Manager (DWM) to create transparent windows. DWM is | ||
| 124 | always enabled from Windows 8 and above. Windows 7 only enables DWM with Aero Glass | ||
| 125 | theme. | ||
| 126 | |||
| 127 | However, it cannot be guaranteed to work on all hardware configurations (an example | ||
| 128 | is hybrid GPU systems, such as NVIDIA Optimus laptops). | ||
