Rename SDLmain to SDL_main and SDLtest to SDL_test for consistency with other SDL libraries

This commit is contained in:
Sam Lantinga
2022-11-28 09:54:09 -08:00
parent b4ebb3b568
commit c2432f8d0d
52 changed files with 158 additions and 155 deletions

View File

@@ -83,8 +83,8 @@ If you already have a project that uses CMake, the instructions change somewhat:
2. Edit "<project>/app/build.gradle" to comment out or remove sections containing ndk-build
and uncomment the cmake sections. Add arguments to the CMake invocation as needed.
3. Edit "<project>/app/jni/CMakeLists.txt" to include your project (it defaults to
adding the "src" subdirectory). Note that you'll have SDL3, SDL3main and SDL3-static
as targets in your project, so you should have "target_link_libraries(yourgame SDL3 SDL3main)"
adding the "src" subdirectory). Note that you'll have SDL3, SDL3_main and SDL3-static
as targets in your project, so you should have "target_link_libraries(yourgame SDL3 SDL3_main)"
in your CMakeLists.txt file. Also be aware that you should use add_library() instead of
add_executable() for the target containing your "main" function.

View File

@@ -60,17 +60,17 @@ else()
# 1. Look for a SDL3 package, 2. look for the SDL3 component and 3. fail if none can be found
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
# 1. Look for a SDL3 package, 2. Look for the SDL3maincomponent and 3. DO NOT fail when SDL3main is not available
find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3main)
# 1. Look for a SDL3 package, 2. Look for the SDL3_maincomponent and 3. DO NOT fail when SDL3_main is not available
find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3_main)
endif()
# Create your game executable target as usual
add_executable(mygame WIN32 mygame.c)
# SDL3::SDL3main may or may not be available. It is e.g. required by Windows GUI applications
if(TARGET SDL3::SDL3main)
# SDL3::SDL3_main may or may not be available. It is e.g. required by Windows GUI applications
if(TARGET SDL3::SDL3_main)
# It has an implicit dependency on SDL3 functions, so it MUST be added before SDL3::SDL3 (or SDL3::SDL3-static)
target_link_libraries(mygame PRIVATE SDL3::SDL3main)
target_link_libraries(mygame PRIVATE SDL3::SDL3_main)
endif()
# Link to the actual SDL3 library. SDL3::SDL3 is the shared SDL library, SDL3::SDL3-static is the static SDL libarary.
@@ -87,8 +87,9 @@ The following components are available, to be used as an argument of `find_packa
|----------------|--------------------------------------------------------------------------------------------|
| SDL3 | The SDL3 shared library, available through the `SDL3::SDL3` target [^SDL_TARGET_EXCEPTION] |
| SDL3-static | The SDL3 static library, available through the `SDL3::SDL3-static` target |
| SDL3main | The SDL3main static library, available through the `SDL3::SDL3main` target |
| SDL3test | The SDL3test static library, available through the `SDL3::SDL3test` target |
| SDL3_main | The SDL3_main static library, available through the `SDL3::SDL3_main` target |
| SDL3_test | The SDL3_test static library, available through the `SDL3::SDL3_test` target |
### Using a vendored SDL

View File

@@ -25,7 +25,7 @@ The Windows GDK port supports the full set of Win32 APIs, renderers, controllers
* Initializing/uninitializing the game runtime, and initializing Xbox Live services
* 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.
* An implementation on `WinMain` that performs the above GDK setup (you should link against SDL3main.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.
* An implementation on `WinMain` that performs the above GDK setup (you should link against SDL3_main.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.
* Global task queue callbacks are dispatched during `SDL_PumpEvents` (which is also called internally if using `SDL_PollEvent`).
* 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).
@@ -37,7 +37,7 @@ The Windows GDK port supports the full set of Win32 APIs, renderers, controllers
The included `VisualC-GDK/SDL.sln` solution includes the following targets for the Gaming.Desktop.x64 configuration:
* SDL3 (DLL) - This is the typical SDL3.dll, but for Gaming.Desktop.x64.
* SDL3main (lib) - This contains a drop-in implementation of `WinMain` that is used as the entry point for GDK programs.
* SDL3_main (lib) - This contains a drop-in implementation of `WinMain` that is used as the entry point for GDK programs.
* tests/testgamecontroller - Standard SDL test program demonstrating controller functionality.
* tests/testgdk - GDK-specific test program that demonstrates using the global task queue to login a user into Xbox Live.
*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.
@@ -54,21 +54,21 @@ These steps assume you already have a game using SDL that runs on Windows x64 al
In 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.
### 2. Build SDL3 and SDL3main for GDK ###
### 2. Build SDL3 and SDL3_main for GDK ###
Open `VisualC-GDK/SDL.sln` in Visual Studio, you need to build the SDL3 and SDL3main targets for the Gaming.Desktop.x64 platform (Release is recommended). You will need to copy/keep track of the `SDL3.dll`, `XCurl.dll` (which is output by Gaming.Desktop.x64), `SDL3.lib`, and `SDL3main.lib` output files for your game project.
Open `VisualC-GDK/SDL.sln` in Visual Studio, you need to build the SDL3 and SDL3_main targets for the Gaming.Desktop.x64 platform (Release is recommended). You will need to copy/keep track of the `SDL3.dll`, `XCurl.dll` (which is output by Gaming.Desktop.x64), `SDL3.lib`, and `SDL3_main.lib` output files for your game project.
*Alternatively*, you could setup your solution file to instead reference the SDL3/SDL3main project file targets from the SDL source, and add those projects as a dependency. This would mean that SDL3 and SDL3main would both be built when your game is built.
*Alternatively*, you could setup your solution file to instead reference the SDL3/SDL3_main project file targets from the SDL source, and add those projects as a dependency. This would mean that SDL3 and SDL3_main would both be built when your game is built.
### 3. Configuring Project Settings ###
While 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:
* Under C/C++ > General > Additional Include Directories, make sure the `SDL/include` path is referenced
* Under Linker > General > Additional Library Directories, make sure to reference the path where the newly-built SDL3.lib and SDL3main.lib are
* Under Linker > General > Additional Library Directories, make sure to reference the path where the newly-built SDL3.lib and SDL3_main.lib are
* Under Linker > Input > Additional Dependencies, you need the following:
* `SDL3.lib`
* `SDL3main.lib` (unless not using)
* `SDL3_main.lib` (unless not using)
* `xgameruntime.lib`
* `../Microsoft.Xbox.Services.141.GDK.C.Thunks.lib`
* 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.

View File

@@ -9,9 +9,9 @@ SDL headers should now be included as `#include <SDL3/SDL.h>`. Typically that's
CMake users should use this snippet to include SDL support in their project:
```
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3main)
if(TARGET SDL3::SDL3main)
target_link_libraries(mygame PRIVATE SDL3::SDL3main)
find_package(SDL3 REQUIRED CONFIG COMPONENTS SDL3_main)
if(TARGET SDL3::SDL3_main)
target_link_libraries(mygame PRIVATE SDL3::SDL3_main)
endif()
target_link_libraries(mygame PRIVATE SDL3::SDL3)
```
@@ -28,6 +28,8 @@ CFLAGS += $(shell pkg-config sdl3 --cflags)
LDFLAGS += $(shell pkg-config sdl3 --libs)
```
The SDL3main and SDL3test libraries have been renamed SDL3_main and SDL3_test, respectively.
## SDL_platform.h

View File

@@ -22,6 +22,6 @@ cmake --install build
## Notes
- Currently only software rendering is supported.
- SDL3main should be used to ensure ROMFS is enabled.
- SDL3_main should be used to ensure ROMFS is enabled.
- By default, the extra L2 cache and higher clock speeds of the New 2/3DS lineup are enabled. If you wish to turn it off, use `osSetSpeedupEnable(false)` in your main function.
- `SDL_GetBasePath` returns the romfs root instead of the executable's directory.

View File

@@ -29,7 +29,7 @@ Later, we will refer to the following `.lib` and `.dll` files that have just bee
- `./VisualC/Win32/Debug/SDL3.dll` or `./VisualC/Win32/Release/SDL3.dll`
- `./VisualC/Win32/Debug/SDL3.lib` or `./VisualC/Win32/Release/SDL3.lib`
- `./VisualC/Win32/Debug/SDL3main.lib` or `./VisualC/Win32/Release/SDL3main.lib`
- `./VisualC/Win32/Debug/SDL3_main.lib` or `./VisualC/Win32/Release/SDL3_main.lib`
_Note for the `x64` versions, just replace `Win32` in the path with `x64`_
@@ -64,7 +64,7 @@ Copy the following file into your Project directory:
Add the following files to your project (It is not necessary to copy them to your project directory):
- `SDL3.lib`
- `SDL3main.lib`
- `SDL3_main.lib`
To add them to your project, right click on your project, and select
`Add files to project`.

View File

@@ -71,7 +71,7 @@ Here is a rough list of what works, and what doesn't:
well as many keys with documented hardware scancodes. Converting
SDL_Scancodes to or from SDL_Keycodes may not work, due to missing APIs
(MapVirtualKey()) in Microsoft's Windows Store / UWP APIs.
* SDLmain. WinRT uses a different signature for each app's main() function.
* SDL_main. WinRT uses a different signature for each app's main() function.
SDL-based apps that use this port must compile in SDL_winrt_main_NonXAML.cpp
(in `SDL\src\main\winrt\`) directly in order for their C-style main()
functions to be called.