summaryrefslogtreecommitdiff
path: root/src/contrib/SDL-2.30.2/docs/README-gdk.md
diff options
context:
space:
mode:
Diffstat (limited to 'src/contrib/SDL-2.30.2/docs/README-gdk.md')
-rw-r--r--src/contrib/SDL-2.30.2/docs/README-gdk.md176
1 files changed, 176 insertions, 0 deletions
diff --git a/src/contrib/SDL-2.30.2/docs/README-gdk.md b/src/contrib/SDL-2.30.2/docs/README-gdk.md
new file mode 100644
index 0000000..6718a61
--- /dev/null
+++ b/src/contrib/SDL-2.30.2/docs/README-gdk.md
@@ -0,0 +1,176 @@
1GDK
2=====
3
4This port allows SDL applications to run via Microsoft's Game Development Kit (GDK).
5
6Windows (GDK) and Xbox One/Xbox Series (GDKX) are both supported and all the required code is included in this public SDL release. However, only licensed Xbox developers have access to the GDKX libraries which will allow you to build the Xbox targets.
7
8
9Requirements
10------------
11
12* Microsoft Visual Studio 2022 (in theory, it should also work in 2017 or 2019, but this has not been tested)
13* Microsoft GDK June 2022 or newer (public release [here](https://github.com/microsoft/GDK/releases/tag/June_2022))
14* For Xbox, you will need the corresponding GDKX version (licensed developers only)
15* To publish a package or successfully authenticate a user, you will need to create an app id/configure services in Partner Center. However, for local testing purposes (without authenticating on Xbox Live), the identifiers used by the GDK test programs in the included solution will work.
16
17
18Windows GDK Status
19------
20
21The Windows GDK port supports the full set of Win32 APIs, renderers, controllers, input devices, etc., as the normal Windows x64 build of SDL.
22
23* Additionally, the GDK port adds the following:
24 * Compile-time platform detection for SDL programs. The `__GDK__` is `#define`d on every GDK platform, and the `__WINGDK__` is `#define`d on Windows GDK, specifically. (This distinction exists because other GDK platforms support a smaller subset of functionality. This allows you to mark code for "any" GDK separate from Windows GDK.)
25 * GDK-specific setup:
26 * Initializing/uninitializing the game runtime, and initializing Xbox Live services
27 * Creating a global task queue and setting it as the default for the process. When running any async operations, passing in `NULL` as the task queue will make the task get added to the global task queue.
28
29 * An implementation on `WinMain` that performs the above GDK setup (you should link against SDL2main.lib, as in Windows x64). If you are unable to do this, you can instead manually call `SDL_GDKRunApp` from your entry point, passing in your `SDL_main` function and `NULL` as the parameters.
30 * Global task queue callbacks are dispatched during `SDL_PumpEvents` (which is also called internally if using `SDL_PollEvent`).
31 * You can get the handle of the global task queue through `SDL_GDKGetTaskQueue`, if needed. When done with the queue, be sure to use `XTaskQueueCloseHandle` to decrement the reference count (otherwise it will cause a resource leak).
32
33* Single-player games have some additional features available:
34 * Call `SDL_GDKGetDefaultUser` to get the default XUserHandle pointer.
35 * `SDL_GetPrefPath` still works, but only for single-player titles.
36
37 These functions mostly wrap around async APIs, and thus should be treated as synchronous alternatives. Also note that the single-player functions return on any OS errors, so be sure to validate the return values!
38
39* What doesn't work:
40 * Compilation with anything other than through the included Visual C++ solution file
41
42## VisualC-GDK Solution
43
44The included `VisualC-GDK/SDL.sln` solution includes the following targets for the Gaming.Desktop.x64 configuration:
45
46* SDL2 (DLL) - This is the typical SDL2.dll, but for Gaming.Desktop.x64.
47* SDL2main (lib) - This contains a drop-in implementation of `WinMain` that is used as the entry point for GDK programs.
48* tests/testgamecontroller - Standard SDL test program demonstrating controller functionality.
49* tests/testgdk - GDK-specific test program that demonstrates using the global task queue to login a user into Xbox Live.
50 *NOTE*: As of the June 2022 GDK, you cannot test user logins without a valid Title ID and MSAAppId. You will need to manually change the identifiers in the `MicrosoftGame.config` to your valid IDs from Partner Center if you wish to test this.
51* tests/testsprite2 - Standard SDL test program demonstrating sprite drawing functionality.
52
53If you set one of the test programs as a startup project, you can run it directly from Visual Studio.
54
55Windows GDK Setup, Detailed Steps
56---------------------
57
58These steps assume you already have a game using SDL that runs on Windows x64 along with a corresponding Visual Studio solution file for the x64 version. If you don't have this, it's easiest to use one of the test program vcxproj files in the `VisualC-GDK` directory as a starting point, though you will still need to do most of the steps below.
59
60### 1. Add a Gaming.Desktop.x64 Configuration ###
61
62In your game's existing Visual Studio Solution, go to Build > Configuration Manager. From the "Active solution platform" drop-down select "New...". From the drop-down list, select Gaming.Desktop.x64 and copy the settings from the x64 configuration.
63
64### 2. Build SDL2 and SDL2main for GDK ###
65
66Open `VisualC-GDK/SDL.sln` in Visual Studio, you need to build the SDL2 and SDL2main targets for the Gaming.Desktop.x64 platform (Release is recommended). You will need to copy/keep track of the `SDL2.dll`, `XCurl.dll` (which is output by Gaming.Desktop.x64), `SDL2.lib`, and `SDL2main.lib` output files for your game project.
67
68*Alternatively*, you could setup your solution file to instead reference the SDL2/SDL2main project file targets from the SDL source, and add those projects as a dependency. This would mean that SDL2 and SDL2main would both be built when your game is built.
69
70### 3. Configuring Project Settings ###
71
72While the Gaming.Desktop.x64 configuration sets most of the required settings, there are some additional items to configure for your game project under the Gaming.Desktop.x64 Configuration:
73
74* Under C/C++ > General > Additional Include Directories, make sure the `SDL/include` path is referenced
75* Under Linker > General > Additional Library Directories, make sure to reference the path where the newly-built SDL2.lib and SDL2main.lib are
76* Under Linker > Input > Additional Dependencies, you need the following:
77 * `SDL2.lib`
78 * `SDL2main.lib` (unless not using)
79 * `xgameruntime.lib`
80 * `../Microsoft.Xbox.Services.141.GDK.C.Thunks.lib`
81* Note that in general, the GDK libraries depend on the MSVC C/C++ runtime, so there is no way to remove this dependency from a GDK program that links against GDK.
82
83### 4. Setting up SDL_main ###
84
85Rather than using your own implementation of `WinMain`, it's recommended that you instead `#include "SDL_main.h"` and declare a standard main function. If you are unable to do this, you can instead manually call `SDL_GDKRunApp` from your entry point, passing in your `SDL_main` function and `NULL` as the parameters.
86
87### 5. Required DLLs ###
88
89The game will not launch in the debugger unless required DLLs are included in the directory that contains the game's .exe file. You need to make sure that the following files are copied into the directory:
90
91* Your SDL2.dll
92* "$(Console_GRDKExtLibRoot)Xbox.Services.API.C\DesignTime\CommonConfiguration\Neutral\Lib\Release\Microsoft.Xbox.Services.141.GDK.C.Thunks.dll"
93* XCurl.dll
94
95You can either copy these in a post-build step, or you can add the dlls into the project and set its Configuration Properties > General > Item type to "Copy file," which will also copy them into the output directory.
96
97### 6. Setting up MicrosoftGame.config ###
98
99You can copy `VisualC-GDK/tests/testgdk/MicrosoftGame.config` and use that as a starting point in your project. Minimally, you will want to change the Executable Name attribute, the DefaultDisplayName, and the Description.
100
101This file must be copied into the same directory as the game's .exe file. As with the DLLs, you can either use a post-build step or the "Copy file" item type.
102
103For basic testing, you do not need to change anything else in `MicrosoftGame.config`. However, if you want to test any Xbox Live services (such as logging in users) _or_ publish a package, you will need to setup a Game app on Partner Center.
104
105Then, you need to set the following values to the values from Partner Center:
106
107* Identity tag - Name and Publisher attributes
108* TitleId
109* MSAAppId
110
111### 7. Adding Required Logos
112
113Several logo PNG files are required to be able to launch the game, even from the debugger. You can use the sample logos provided in `VisualC-GDK/logos`. As with the other files, they must be copied into the same directory as the game's .exe file.
114
115
116### 8. Copying any Data Files ###
117
118When debugging GDK games, there is no way to specify a working directory. Therefore, any required game data must also be copied into the output directory, likely in a post-build step.
119
120
121### 9. Build and Run from Visual Studio ###
122
123At this point, you should be able to build and run your game from the Visual Studio Debugger. If you get any linker errors, make sure you double-check that you referenced all the required libs.
124
125If you are testing Xbox Live functionality, it's likely you will need to change to the Sandbox for your title. To do this:
126
1271. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu
1282. Switch the sandbox name with:
129 `XblPCSandbox SANDBOX.#`
1303. (To switch back to the retail sandbox):
131 `XblPCSandbox RETAIL`
132
133### 10. Packaging and Installing Locally
134
135You can use one of the test program's `PackageLayout.xml` as a starting point. Minimally, you will need to change the exe to the correct name and also reference any required game data. As with the other data files, it's easiest if you have this copy to the output directory, although it's not a requirement as you can specify relative paths to files.
136
137To create the package:
138
1391. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu
1402. `cd` to the directory containing the `PackageLayout.xml` with the correct paths (if you use the local path as in the sample package layout, this would be from your .exe output directory)
1413. `mkdir Package` to create an output directory
1424. To package the file into the `Package` directory, use:
143 `makepkg pack /f PackageLayout.xml /lt /d . /nogameos /pc /pd Package`
1445. To install the package, use:
145 `wdapp install PACKAGENAME.msixvc`
1466. Once the package is installed, you can run it from the start menu.
1477. As with when running from Visual Studio, if you need to test any Xbox Live functionality you must switch to the correct sandbox.
148
149Xbox GDKX Setup
150---------------------
151In general, the same process in the Windows GDK instructions work. There are just a few additional notes:
152* For Xbox One consoles, use the Gaming.Xbox.XboxOne.x64 target
153* For Xbox Series consoles, use the Gaming.Xbox.Scarlett.x64 target
154* The Xbox One target sets the `__XBOXONE__` define and the Xbox Series target sets the `__XBOXSERIES__` define
155* You don't need to link against the Xbox.Services Thunks lib nor include that dll in your package (it doesn't exist for Xbox)
156* The shader blobs for Xbox are created in a pre-build step for the Xbox targets, rather than included in the source (due to NDA and version compatability reasons)
157* To create a package, use:
158 `makepkg pack /f PackageLayout.xml /lt /d . /pd Package`
159* To install the package, use:
160 `xbapp install [PACKAGE].xvc`
161* For some reason, if you make changes that require SDL2.dll to build, and you are running through the debugger (instead of a package), you have to rebuild your .exe target for the debugger to recognize the dll has changed and needs to be transferred to the console again
162* While there are successful releases of Xbox titles using this port, it is not as extensively tested as other targets
163
164Troubleshooting
165---------------
166
167#### Xbox Live Login does not work
168
169As of June 2022 GDK, you must have a valid Title Id and MSAAppId in order to test Xbox Live functionality such as user login. Make sure these are set correctly in the `MicrosoftGame.config`. This means that even testgdk will not let you login without setting these properties to valid values.
170
171Furthermore, confirm that your PC is set to the correct sandbox.
172
173
174#### "The current user has already installed an unpackaged version of this app. A packaged version cannot replace this." error when installing
175
176Prior to June 2022 GDK, running from the Visual Studio debugger would still locally register the app (and it would appear on the start menu). To fix this, you have to uninstall it (it's simplest to right click on it from the start menu to uninstall it).