mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 03:18:13 +00:00
docs: heavy editing to make this happy with latest wikibridge.
The public headers saw lots of cleanups, backporting from SDL3 docs, and merging with the wiki. The markdown files in docs/README-*.md were converted to Unix endlines.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,483 +1,483 @@
|
|||||||
Android
|
Android
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
Matt Styles wrote a tutorial on building SDL for Android with Visual Studio:
|
Matt Styles wrote a tutorial on building SDL for Android with Visual Studio:
|
||||||
http://trederia.blogspot.de/2017/03/building-sdl2-for-android-with-visual.html
|
http://trederia.blogspot.de/2017/03/building-sdl2-for-android-with-visual.html
|
||||||
|
|
||||||
The rest of this README covers the Android gradle style build process.
|
The rest of this README covers the Android gradle style build process.
|
||||||
|
|
||||||
If you are using the older ant build process, it is no longer officially
|
If you are using the older ant build process, it is no longer officially
|
||||||
supported, but you can use the "android-project-ant" directory as a template.
|
supported, but you can use the "android-project-ant" directory as a template.
|
||||||
|
|
||||||
|
|
||||||
Requirements
|
Requirements
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
Android SDK (version 34 or later)
|
Android SDK (version 34 or later)
|
||||||
https://developer.android.com/sdk/index.html
|
https://developer.android.com/sdk/index.html
|
||||||
|
|
||||||
Android NDK r15c or later
|
Android NDK r15c or later
|
||||||
https://developer.android.com/tools/sdk/ndk/index.html
|
https://developer.android.com/tools/sdk/ndk/index.html
|
||||||
|
|
||||||
Minimum API level supported by SDL: 19 (Android 4.4)
|
Minimum API level supported by SDL: 19 (Android 4.4)
|
||||||
|
|
||||||
|
|
||||||
How the port works
|
How the port works
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
- Android applications are Java-based, optionally with parts written in C
|
- Android applications are Java-based, optionally with parts written in C
|
||||||
- As SDL apps are C-based, we use a small Java shim that uses JNI to talk to
|
- As SDL apps are C-based, we use a small Java shim that uses JNI to talk to
|
||||||
the SDL library
|
the SDL library
|
||||||
- This means that your application C code must be placed inside an Android
|
- This means that your application C code must be placed inside an Android
|
||||||
Java project, along with some C support code that communicates with Java
|
Java project, along with some C support code that communicates with Java
|
||||||
- This eventually produces a standard Android .apk package
|
- This eventually produces a standard Android .apk package
|
||||||
|
|
||||||
The Android Java code implements an "Activity" and can be found in:
|
The Android Java code implements an "Activity" and can be found in:
|
||||||
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
|
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
|
||||||
|
|
||||||
The Java code loads your game code, the SDL shared library, and
|
The Java code loads your game code, the SDL shared library, and
|
||||||
dispatches to native functions implemented in the SDL library:
|
dispatches to native functions implemented in the SDL library:
|
||||||
src/core/android/SDL_android.c
|
src/core/android/SDL_android.c
|
||||||
|
|
||||||
|
|
||||||
Building an app
|
Building an app
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
For simple projects you can use the script located at build-scripts/androidbuild.sh
|
For simple projects you can use the script located at build-scripts/androidbuild.sh
|
||||||
|
|
||||||
There's two ways of using it:
|
There's two ways of using it:
|
||||||
|
|
||||||
androidbuild.sh com.yourcompany.yourapp < sources.list
|
androidbuild.sh com.yourcompany.yourapp < sources.list
|
||||||
androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c
|
androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c
|
||||||
|
|
||||||
sources.list should be a text file with a source file name in each line
|
sources.list should be a text file with a source file name in each line
|
||||||
Filenames should be specified relative to the current directory, for example if
|
Filenames should be specified relative to the current directory, for example if
|
||||||
you are in the build-scripts directory and want to create the testgles.c test, you'll
|
you are in the build-scripts directory and want to create the testgles.c test, you'll
|
||||||
run:
|
run:
|
||||||
|
|
||||||
./androidbuild.sh org.libsdl.testgles ../test/testgles.c
|
./androidbuild.sh org.libsdl.testgles ../test/testgles.c
|
||||||
|
|
||||||
One limitation of this script is that all sources provided will be aggregated into
|
One limitation of this script is that all sources provided will be aggregated into
|
||||||
a single directory, thus all your source files should have a unique name.
|
a single directory, thus all your source files should have a unique name.
|
||||||
|
|
||||||
Once the project is complete the script will tell you where the debug APK is located.
|
Once the project is complete the script will tell you where the debug APK is located.
|
||||||
If you want to create a signed release APK, you can use the project created by this
|
If you want to create a signed release APK, you can use the project created by this
|
||||||
utility to generate it.
|
utility to generate it.
|
||||||
|
|
||||||
Finally, a word of caution: re running androidbuild.sh wipes any changes you may have
|
Finally, a word of caution: re running androidbuild.sh wipes any changes you may have
|
||||||
done in the build directory for the app!
|
done in the build directory for the app!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
For more complex projects, follow these instructions:
|
For more complex projects, follow these instructions:
|
||||||
|
|
||||||
1. Get the source code for SDL and copy the 'android-project' directory located at SDL/android-project to a suitable location. Also make sure to rename it to your project name (In these examples: YOURPROJECT).
|
1. Get the source code for SDL and copy the 'android-project' directory located at SDL/android-project to a suitable location. Also make sure to rename it to your project name (In these examples: YOURPROJECT).
|
||||||
|
|
||||||
(The 'android-project' directory can basically be seen as a sort of starting point for the android-port of your project. It contains the glue code between the Android Java 'frontend' and the SDL code 'backend'. It also contains some standard behaviour, like how events should be handled, which you will be able to change.)
|
(The 'android-project' directory can basically be seen as a sort of starting point for the android-port of your project. It contains the glue code between the Android Java 'frontend' and the SDL code 'backend'. It also contains some standard behaviour, like how events should be handled, which you will be able to change.)
|
||||||
|
|
||||||
2. Move or [symlink](https://en.wikipedia.org/wiki/Symbolic_link) the SDL directory into the "YOURPROJECT/app/jni" directory
|
2. Move or [symlink](https://en.wikipedia.org/wiki/Symbolic_link) the SDL directory into the "YOURPROJECT/app/jni" directory
|
||||||
|
|
||||||
(This is needed as the source of SDL has to be compiled by the Android compiler)
|
(This is needed as the source of SDL has to be compiled by the Android compiler)
|
||||||
|
|
||||||
3. Edit "YOURPROJECT/app/jni/src/Android.mk" to include your source files.
|
3. Edit "YOURPROJECT/app/jni/src/Android.mk" to include your source files.
|
||||||
|
|
||||||
(They should be separated by spaces after the "LOCAL_SRC_FILES := " declaration)
|
(They should be separated by spaces after the "LOCAL_SRC_FILES := " declaration)
|
||||||
|
|
||||||
4a. If you want to use Android Studio, simply open your 'YOURPROJECT' directory and start building.
|
4a. If you want to use Android Studio, simply open your 'YOURPROJECT' directory and start building.
|
||||||
|
|
||||||
4b. If you want to build manually, run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device
|
4b. If you want to build manually, run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device
|
||||||
|
|
||||||
|
|
||||||
If you already have a project that uses CMake, the instructions change somewhat:
|
If you already have a project that uses CMake, the instructions change somewhat:
|
||||||
|
|
||||||
1. Do points 1 and 2 from the instruction above.
|
1. Do points 1 and 2 from the instruction above.
|
||||||
2. Edit "YOURPROJECT/app/build.gradle" to comment out or remove sections containing ndk-build
|
2. Edit "YOURPROJECT/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.
|
and uncomment the cmake sections. Add arguments to the CMake invocation as needed.
|
||||||
3. Edit "YOURPROJECT/app/jni/CMakeLists.txt" to include your project (it defaults to
|
3. Edit "YOURPROJECT/app/jni/CMakeLists.txt" to include your project (it defaults to
|
||||||
adding the "src" subdirectory). Note that you'll have SDL2, SDL2main and SDL2-static
|
adding the "src" subdirectory). Note that you'll have SDL2, SDL2main and SDL2-static
|
||||||
as targets in your project, so you should have "target_link_libraries(yourgame SDL2 SDL2main)"
|
as targets in your project, so you should have "target_link_libraries(yourgame SDL2 SDL2main)"
|
||||||
in your CMakeLists.txt file. Also be aware that you should use add_library() instead of
|
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.
|
add_executable() for the target containing your "main" function.
|
||||||
|
|
||||||
If you wish to use Android Studio, you can skip the last step.
|
If you wish to use Android Studio, you can skip the last step.
|
||||||
|
|
||||||
4. Run './gradlew installDebug' or './gradlew installRelease' in the project directory. It will build and install your .apk on any
|
4. Run './gradlew installDebug' or './gradlew installRelease' in the project directory. It will build and install your .apk on any
|
||||||
connected Android device
|
connected Android device
|
||||||
|
|
||||||
Here's an explanation of the files in the Android project, so you can customize them:
|
Here's an explanation of the files in the Android project, so you can customize them:
|
||||||
|
|
||||||
android-project/app
|
android-project/app
|
||||||
build.gradle - build info including the application version and SDK
|
build.gradle - build info including the application version and SDK
|
||||||
src/main/AndroidManifest.xml - package manifest. Among others, it contains the class name of the main Activity and the package name of the application.
|
src/main/AndroidManifest.xml - package manifest. Among others, it contains the class name of the main Activity and the package name of the application.
|
||||||
jni/ - directory holding native code
|
jni/ - directory holding native code
|
||||||
jni/Application.mk - Application JNI settings, including target platform and STL library
|
jni/Application.mk - Application JNI settings, including target platform and STL library
|
||||||
jni/Android.mk - Android makefile that can call recursively the Android.mk files in all subdirectories
|
jni/Android.mk - Android makefile that can call recursively the Android.mk files in all subdirectories
|
||||||
jni/CMakeLists.txt - Top-level CMake project that adds SDL as a subproject
|
jni/CMakeLists.txt - Top-level CMake project that adds SDL as a subproject
|
||||||
jni/SDL/ - (symlink to) directory holding the SDL library files
|
jni/SDL/ - (symlink to) directory holding the SDL library files
|
||||||
jni/SDL/Android.mk - Android makefile for creating the SDL shared library
|
jni/SDL/Android.mk - Android makefile for creating the SDL shared library
|
||||||
jni/src/ - directory holding your C/C++ source
|
jni/src/ - directory holding your C/C++ source
|
||||||
jni/src/Android.mk - Android makefile that you should customize to include your source code and any library references
|
jni/src/Android.mk - Android makefile that you should customize to include your source code and any library references
|
||||||
jni/src/CMakeLists.txt - CMake file that you may customize to include your source code and any library references
|
jni/src/CMakeLists.txt - CMake file that you may customize to include your source code and any library references
|
||||||
src/main/assets/ - directory holding asset files for your application
|
src/main/assets/ - directory holding asset files for your application
|
||||||
src/main/res/ - directory holding resources for your application
|
src/main/res/ - directory holding resources for your application
|
||||||
src/main/res/mipmap-* - directories holding icons for different phone hardware
|
src/main/res/mipmap-* - directories holding icons for different phone hardware
|
||||||
src/main/res/values/strings.xml - strings used in your application, including the application name
|
src/main/res/values/strings.xml - strings used in your application, including the application name
|
||||||
src/main/java/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding to SDL. Be very careful changing this, as the SDL library relies on this implementation. You should instead subclass this for your application.
|
src/main/java/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding to SDL. Be very careful changing this, as the SDL library relies on this implementation. You should instead subclass this for your application.
|
||||||
|
|
||||||
|
|
||||||
Customizing your application name
|
Customizing your application name
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
To customize your application name, edit AndroidManifest.xml and replace
|
To customize your application name, edit AndroidManifest.xml and replace
|
||||||
"org.libsdl.app" with an identifier for your product package.
|
"org.libsdl.app" with an identifier for your product package.
|
||||||
|
|
||||||
Then create a Java class extending SDLActivity and place it in a directory
|
Then create a Java class extending SDLActivity and place it in a directory
|
||||||
under src matching your package, e.g.
|
under src matching your package, e.g.
|
||||||
|
|
||||||
src/com/gamemaker/game/MyGame.java
|
src/com/gamemaker/game/MyGame.java
|
||||||
|
|
||||||
Here's an example of a minimal class file:
|
Here's an example of a minimal class file:
|
||||||
|
|
||||||
--- MyGame.java --------------------------
|
--- MyGame.java --------------------------
|
||||||
package com.gamemaker.game;
|
package com.gamemaker.game;
|
||||||
|
|
||||||
import org.libsdl.app.SDLActivity;
|
import org.libsdl.app.SDLActivity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A sample wrapper class that just calls SDLActivity
|
* A sample wrapper class that just calls SDLActivity
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MyGame extends SDLActivity { }
|
public class MyGame extends SDLActivity { }
|
||||||
|
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
Then replace "SDLActivity" in AndroidManifest.xml with the name of your
|
Then replace "SDLActivity" in AndroidManifest.xml with the name of your
|
||||||
class, .e.g. "MyGame"
|
class, .e.g. "MyGame"
|
||||||
|
|
||||||
|
|
||||||
Customizing your application icon
|
Customizing your application icon
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
Conceptually changing your icon is just replacing the "ic_launcher.png" files in
|
Conceptually changing your icon is just replacing the "ic_launcher.png" files in
|
||||||
the drawable directories under the res directory. There are several directories
|
the drawable directories under the res directory. There are several directories
|
||||||
for different screen sizes.
|
for different screen sizes.
|
||||||
|
|
||||||
|
|
||||||
Loading assets
|
Loading assets
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
Any files you put in the "app/src/main/assets" directory of your project
|
Any files you put in the "app/src/main/assets" directory of your project
|
||||||
directory will get bundled into the application package and you can load
|
directory will get bundled into the application package and you can load
|
||||||
them using the standard functions in SDL_rwops.h.
|
them using the standard functions in SDL_rwops.h.
|
||||||
|
|
||||||
There are also a few Android specific functions that allow you to get other
|
There are also a few Android specific functions that allow you to get other
|
||||||
useful paths for saving and loading data:
|
useful paths for saving and loading data:
|
||||||
* SDL_AndroidGetInternalStoragePath()
|
* SDL_AndroidGetInternalStoragePath()
|
||||||
* SDL_AndroidGetExternalStorageState()
|
* SDL_AndroidGetExternalStorageState()
|
||||||
* SDL_AndroidGetExternalStoragePath()
|
* SDL_AndroidGetExternalStoragePath()
|
||||||
|
|
||||||
See SDL_system.h for more details on these functions.
|
See SDL_system.h for more details on these functions.
|
||||||
|
|
||||||
The asset packaging system will, by default, compress certain file extensions.
|
The asset packaging system will, by default, compress certain file extensions.
|
||||||
SDL includes two asset file access mechanisms, the preferred one is the so
|
SDL includes two asset file access mechanisms, the preferred one is the so
|
||||||
called "File Descriptor" method, which is faster and doesn't involve the Dalvik
|
called "File Descriptor" method, which is faster and doesn't involve the Dalvik
|
||||||
GC, but given this method does not work on compressed assets, there is also the
|
GC, but given this method does not work on compressed assets, there is also the
|
||||||
"Input Stream" method, which is automatically used as a fall back by SDL. You
|
"Input Stream" method, which is automatically used as a fall back by SDL. You
|
||||||
may want to keep this fact in mind when building your APK, specially when large
|
may want to keep this fact in mind when building your APK, specially when large
|
||||||
files are involved.
|
files are involved.
|
||||||
For more information on which extensions get compressed by default and how to
|
For more information on which extensions get compressed by default and how to
|
||||||
disable this behaviour, see for example:
|
disable this behaviour, see for example:
|
||||||
|
|
||||||
http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/
|
http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/
|
||||||
|
|
||||||
|
|
||||||
Pause / Resume behaviour
|
Pause / Resume behaviour
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
If SDL_HINT_ANDROID_BLOCK_ON_PAUSE hint is set (the default),
|
If SDL_HINT_ANDROID_BLOCK_ON_PAUSE hint is set (the default),
|
||||||
the event loop will block itself when the app is paused (ie, when the user
|
the event loop will block itself when the app is paused (ie, when the user
|
||||||
returns to the main Android dashboard). Blocking is better in terms of battery
|
returns to the main Android dashboard). Blocking is better in terms of battery
|
||||||
use, and it allows your app to spring back to life instantaneously after resume
|
use, and it allows your app to spring back to life instantaneously after resume
|
||||||
(versus polling for a resume message).
|
(versus polling for a resume message).
|
||||||
|
|
||||||
Upon resume, SDL will attempt to restore the GL context automatically.
|
Upon resume, SDL will attempt to restore the GL context automatically.
|
||||||
In modern devices (Android 3.0 and up) this will most likely succeed and your
|
In modern devices (Android 3.0 and up) this will most likely succeed and your
|
||||||
app can continue to operate as it was.
|
app can continue to operate as it was.
|
||||||
|
|
||||||
However, there's a chance (on older hardware, or on systems under heavy load),
|
However, there's a chance (on older hardware, or on systems under heavy load),
|
||||||
where the GL context can not be restored. In that case you have to listen for
|
where the GL context can not be restored. In that case you have to listen for
|
||||||
a specific message (SDL_RENDER_DEVICE_RESET) and restore your textures
|
a specific message (SDL_RENDER_DEVICE_RESET) and restore your textures
|
||||||
manually or quit the app.
|
manually or quit the app.
|
||||||
|
|
||||||
You should not use the SDL renderer API while the app going in background:
|
You should not use the SDL renderer API while the app going in background:
|
||||||
- SDL_APP_WILLENTERBACKGROUND:
|
- SDL_APP_WILLENTERBACKGROUND:
|
||||||
after you read this message, GL context gets backed-up and you should not
|
after you read this message, GL context gets backed-up and you should not
|
||||||
use the SDL renderer API.
|
use the SDL renderer API.
|
||||||
|
|
||||||
When this event is received, you have to set the render target to NULL, if you're using it.
|
When this event is received, you have to set the render target to NULL, if you're using it.
|
||||||
(eg call SDL_SetRenderTarget(renderer, NULL))
|
(eg call SDL_SetRenderTarget(renderer, NULL))
|
||||||
|
|
||||||
- SDL_APP_DIDENTERFOREGROUND:
|
- SDL_APP_DIDENTERFOREGROUND:
|
||||||
GL context is restored, and the SDL renderer API is available (unless you
|
GL context is restored, and the SDL renderer API is available (unless you
|
||||||
receive SDL_RENDER_DEVICE_RESET).
|
receive SDL_RENDER_DEVICE_RESET).
|
||||||
|
|
||||||
Mouse / Touch events
|
Mouse / Touch events
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
In some case, SDL generates synthetic mouse (resp. touch) events for touch
|
In some case, SDL generates synthetic mouse (resp. touch) events for touch
|
||||||
(resp. mouse) devices.
|
(resp. mouse) devices.
|
||||||
To enable/disable this behavior, see SDL_hints.h:
|
To enable/disable this behavior, see SDL_hints.h:
|
||||||
- SDL_HINT_TOUCH_MOUSE_EVENTS
|
- SDL_HINT_TOUCH_MOUSE_EVENTS
|
||||||
- SDL_HINT_MOUSE_TOUCH_EVENTS
|
- SDL_HINT_MOUSE_TOUCH_EVENTS
|
||||||
|
|
||||||
Misc
|
Misc
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
For some device, it appears to works better setting explicitly GL attributes
|
For some device, it appears to works better setting explicitly GL attributes
|
||||||
before creating a window:
|
before creating a window:
|
||||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
||||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
|
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
|
||||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
||||||
|
|
||||||
Threads and the Java VM
|
Threads and the Java VM
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
For a quick tour on how Linux native threads interoperate with the Java VM, take
|
For a quick tour on how Linux native threads interoperate with the Java VM, take
|
||||||
a look here: https://developer.android.com/guide/practices/jni.html
|
a look here: https://developer.android.com/guide/practices/jni.html
|
||||||
|
|
||||||
If you want to use threads in your SDL app, it's strongly recommended that you
|
If you want to use threads in your SDL app, it's strongly recommended that you
|
||||||
do so by creating them using SDL functions. This way, the required attach/detach
|
do so by creating them using SDL functions. This way, the required attach/detach
|
||||||
handling is managed by SDL automagically. If you have threads created by other
|
handling is managed by SDL automagically. If you have threads created by other
|
||||||
means and they make calls to SDL functions, make sure that you call
|
means and they make calls to SDL functions, make sure that you call
|
||||||
Android_JNI_SetupThread() before doing anything else otherwise SDL will attach
|
Android_JNI_SetupThread() before doing anything else otherwise SDL will attach
|
||||||
your thread automatically anyway (when you make an SDL call), but it'll never
|
your thread automatically anyway (when you make an SDL call), but it'll never
|
||||||
detach it.
|
detach it.
|
||||||
|
|
||||||
|
|
||||||
If you ever want to use JNI in a native thread (created by "SDL_CreateThread()"),
|
If you ever want to use JNI in a native thread (created by "SDL_CreateThread()"),
|
||||||
it won't be able to find your java class and method because of the java class loader
|
it won't be able to find your java class and method because of the java class loader
|
||||||
which is different for native threads, than for java threads (eg your "main()").
|
which is different for native threads, than for java threads (eg your "main()").
|
||||||
|
|
||||||
the work-around is to find class/method, in you "main()" thread, and to use them
|
the work-around is to find class/method, in you "main()" thread, and to use them
|
||||||
in your native thread.
|
in your native thread.
|
||||||
|
|
||||||
see:
|
see:
|
||||||
https://developer.android.com/training/articles/perf-jni#faq:-why-didnt-findclass-find-my-class
|
https://developer.android.com/training/articles/perf-jni#faq:-why-didnt-findclass-find-my-class
|
||||||
|
|
||||||
Using STL
|
Using STL
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
You can use STL in your project by creating an Application.mk file in the jni
|
You can use STL in your project by creating an Application.mk file in the jni
|
||||||
folder and adding the following line:
|
folder and adding the following line:
|
||||||
|
|
||||||
APP_STL := c++_shared
|
APP_STL := c++_shared
|
||||||
|
|
||||||
For more information go here:
|
For more information go here:
|
||||||
https://developer.android.com/ndk/guides/cpp-support
|
https://developer.android.com/ndk/guides/cpp-support
|
||||||
|
|
||||||
|
|
||||||
Using the emulator
|
Using the emulator
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
There are some good tips and tricks for getting the most out of the
|
There are some good tips and tricks for getting the most out of the
|
||||||
emulator here: https://developer.android.com/tools/devices/emulator.html
|
emulator here: https://developer.android.com/tools/devices/emulator.html
|
||||||
|
|
||||||
Especially useful is the info on setting up OpenGL ES 2.0 emulation.
|
Especially useful is the info on setting up OpenGL ES 2.0 emulation.
|
||||||
|
|
||||||
Notice that this software emulator is incredibly slow and needs a lot of disk space.
|
Notice that this software emulator is incredibly slow and needs a lot of disk space.
|
||||||
Using a real device works better.
|
Using a real device works better.
|
||||||
|
|
||||||
|
|
||||||
Troubleshooting
|
Troubleshooting
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
You can see if adb can see any devices with the following command:
|
You can see if adb can see any devices with the following command:
|
||||||
|
|
||||||
adb devices
|
adb devices
|
||||||
|
|
||||||
You can see the output of log messages on the default device with:
|
You can see the output of log messages on the default device with:
|
||||||
|
|
||||||
adb logcat
|
adb logcat
|
||||||
|
|
||||||
You can push files to the device with:
|
You can push files to the device with:
|
||||||
|
|
||||||
adb push local_file remote_path_and_file
|
adb push local_file remote_path_and_file
|
||||||
|
|
||||||
You can push files to the SD Card at /sdcard, for example:
|
You can push files to the SD Card at /sdcard, for example:
|
||||||
|
|
||||||
adb push moose.dat /sdcard/moose.dat
|
adb push moose.dat /sdcard/moose.dat
|
||||||
|
|
||||||
You can see the files on the SD card with a shell command:
|
You can see the files on the SD card with a shell command:
|
||||||
|
|
||||||
adb shell ls /sdcard/
|
adb shell ls /sdcard/
|
||||||
|
|
||||||
You can start a command shell on the default device with:
|
You can start a command shell on the default device with:
|
||||||
|
|
||||||
adb shell
|
adb shell
|
||||||
|
|
||||||
You can remove the library files of your project (and not the SDL lib files) with:
|
You can remove the library files of your project (and not the SDL lib files) with:
|
||||||
|
|
||||||
ndk-build clean
|
ndk-build clean
|
||||||
|
|
||||||
You can do a build with the following command:
|
You can do a build with the following command:
|
||||||
|
|
||||||
ndk-build
|
ndk-build
|
||||||
|
|
||||||
You can see the complete command line that ndk-build is using by passing V=1 on the command line:
|
You can see the complete command line that ndk-build is using by passing V=1 on the command line:
|
||||||
|
|
||||||
ndk-build V=1
|
ndk-build V=1
|
||||||
|
|
||||||
If your application crashes in native code, you can use ndk-stack to get a symbolic stack trace:
|
If your application crashes in native code, you can use ndk-stack to get a symbolic stack trace:
|
||||||
https://developer.android.com/ndk/guides/ndk-stack
|
https://developer.android.com/ndk/guides/ndk-stack
|
||||||
|
|
||||||
If you want to go through the process manually, you can use addr2line to convert the
|
If you want to go through the process manually, you can use addr2line to convert the
|
||||||
addresses in the stack trace to lines in your code.
|
addresses in the stack trace to lines in your code.
|
||||||
|
|
||||||
For example, if your crash looks like this:
|
For example, if your crash looks like this:
|
||||||
|
|
||||||
I/DEBUG ( 31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0
|
I/DEBUG ( 31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0
|
||||||
I/DEBUG ( 31): r0 00000000 r1 00001000 r2 00000003 r3 400085d4
|
I/DEBUG ( 31): r0 00000000 r1 00001000 r2 00000003 r3 400085d4
|
||||||
I/DEBUG ( 31): r4 400085d0 r5 40008000 r6 afd41504 r7 436c6a7c
|
I/DEBUG ( 31): r4 400085d0 r5 40008000 r6 afd41504 r7 436c6a7c
|
||||||
I/DEBUG ( 31): r8 436c6b30 r9 435c6fb0 10 435c6f9c fp 4168d82c
|
I/DEBUG ( 31): r8 436c6b30 r9 435c6fb0 10 435c6f9c fp 4168d82c
|
||||||
I/DEBUG ( 31): ip 8346aff0 sp 436c6a60 lr afd1c8ff pc afd1c902 cpsr 60000030
|
I/DEBUG ( 31): ip 8346aff0 sp 436c6a60 lr afd1c8ff pc afd1c902 cpsr 60000030
|
||||||
I/DEBUG ( 31): #00 pc 0001c902 /system/lib/libc.so
|
I/DEBUG ( 31): #00 pc 0001c902 /system/lib/libc.so
|
||||||
I/DEBUG ( 31): #01 pc 0001ccf6 /system/lib/libc.so
|
I/DEBUG ( 31): #01 pc 0001ccf6 /system/lib/libc.so
|
||||||
I/DEBUG ( 31): #02 pc 000014bc /data/data/org.libsdl.app/lib/libmain.so
|
I/DEBUG ( 31): #02 pc 000014bc /data/data/org.libsdl.app/lib/libmain.so
|
||||||
I/DEBUG ( 31): #03 pc 00001506 /data/data/org.libsdl.app/lib/libmain.so
|
I/DEBUG ( 31): #03 pc 00001506 /data/data/org.libsdl.app/lib/libmain.so
|
||||||
|
|
||||||
You can see that there's a crash in the C library being called from the main code.
|
You can see that there's a crash in the C library being called from the main code.
|
||||||
I run addr2line with the debug version of my code:
|
I run addr2line with the debug version of my code:
|
||||||
|
|
||||||
arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so
|
arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so
|
||||||
|
|
||||||
and then paste in the number after "pc" in the call stack, from the line that I care about:
|
and then paste in the number after "pc" in the call stack, from the line that I care about:
|
||||||
000014bc
|
000014bc
|
||||||
|
|
||||||
I get output from addr2line showing that it's in the quit function, in testspriteminimal.c, on line 23.
|
I get output from addr2line showing that it's in the quit function, in testspriteminimal.c, on line 23.
|
||||||
|
|
||||||
You can add logging to your code to help show what's happening:
|
You can add logging to your code to help show what's happening:
|
||||||
|
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x);
|
__android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x);
|
||||||
|
|
||||||
If you need to build without optimization turned on, you can create a file called
|
If you need to build without optimization turned on, you can create a file called
|
||||||
"Application.mk" in the jni directory, with the following line in it:
|
"Application.mk" in the jni directory, with the following line in it:
|
||||||
|
|
||||||
APP_OPTIM := debug
|
APP_OPTIM := debug
|
||||||
|
|
||||||
|
|
||||||
Memory debugging
|
Memory debugging
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
The best (and slowest) way to debug memory issues on Android is valgrind.
|
The best (and slowest) way to debug memory issues on Android is valgrind.
|
||||||
Valgrind has support for Android out of the box, just grab code using:
|
Valgrind has support for Android out of the box, just grab code using:
|
||||||
|
|
||||||
svn co svn://svn.valgrind.org/valgrind/trunk valgrind
|
svn co svn://svn.valgrind.org/valgrind/trunk valgrind
|
||||||
|
|
||||||
... and follow the instructions in the file README.android to build it.
|
... and follow the instructions in the file README.android to build it.
|
||||||
|
|
||||||
One thing I needed to do on Mac OS X was change the path to the toolchain,
|
One thing I needed to do on Mac OS X was change the path to the toolchain,
|
||||||
and add ranlib to the environment variables:
|
and add ranlib to the environment variables:
|
||||||
export RANLIB=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-ranlib
|
export RANLIB=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-ranlib
|
||||||
|
|
||||||
Once valgrind is built, you can create a wrapper script to launch your
|
Once valgrind is built, you can create a wrapper script to launch your
|
||||||
application with it, changing org.libsdl.app to your package identifier:
|
application with it, changing org.libsdl.app to your package identifier:
|
||||||
|
|
||||||
--- start_valgrind_app -------------------
|
--- start_valgrind_app -------------------
|
||||||
#!/system/bin/sh
|
#!/system/bin/sh
|
||||||
export TMPDIR=/data/data/org.libsdl.app
|
export TMPDIR=/data/data/org.libsdl.app
|
||||||
exec /data/local/Inst/bin/valgrind --log-file=/sdcard/valgrind.log --error-limit=no $*
|
exec /data/local/Inst/bin/valgrind --log-file=/sdcard/valgrind.log --error-limit=no $*
|
||||||
------------------------------------------
|
------------------------------------------
|
||||||
|
|
||||||
Then push it to the device:
|
Then push it to the device:
|
||||||
|
|
||||||
adb push start_valgrind_app /data/local
|
adb push start_valgrind_app /data/local
|
||||||
|
|
||||||
and make it executable:
|
and make it executable:
|
||||||
|
|
||||||
adb shell chmod 755 /data/local/start_valgrind_app
|
adb shell chmod 755 /data/local/start_valgrind_app
|
||||||
|
|
||||||
and tell Android to use the script to launch your application:
|
and tell Android to use the script to launch your application:
|
||||||
|
|
||||||
adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app"
|
adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app"
|
||||||
|
|
||||||
If the setprop command says "could not set property", it's likely that
|
If the setprop command says "could not set property", it's likely that
|
||||||
your package name is too long and you should make it shorter by changing
|
your package name is too long and you should make it shorter by changing
|
||||||
AndroidManifest.xml and the path to your class file in android-project/src
|
AndroidManifest.xml and the path to your class file in android-project/src
|
||||||
|
|
||||||
You can then launch your application normally and waaaaaaaiiittt for it.
|
You can then launch your application normally and waaaaaaaiiittt for it.
|
||||||
You can monitor the startup process with the logcat command above, and
|
You can monitor the startup process with the logcat command above, and
|
||||||
when it's done (or even while it's running) you can grab the valgrind
|
when it's done (or even while it's running) you can grab the valgrind
|
||||||
output file:
|
output file:
|
||||||
|
|
||||||
adb pull /sdcard/valgrind.log
|
adb pull /sdcard/valgrind.log
|
||||||
|
|
||||||
When you're done instrumenting with valgrind, you can disable the wrapper:
|
When you're done instrumenting with valgrind, you can disable the wrapper:
|
||||||
|
|
||||||
adb shell setprop wrap.org.libsdl.app ""
|
adb shell setprop wrap.org.libsdl.app ""
|
||||||
|
|
||||||
|
|
||||||
Graphics debugging
|
Graphics debugging
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
If you are developing on a compatible Tegra-based tablet, NVidia provides
|
If you are developing on a compatible Tegra-based tablet, NVidia provides
|
||||||
Tegra Graphics Debugger at their website. Because SDL2 dynamically loads EGL
|
Tegra Graphics Debugger at their website. Because SDL2 dynamically loads EGL
|
||||||
and GLES libraries, you must follow their instructions for installing the
|
and GLES libraries, you must follow their instructions for installing the
|
||||||
interposer library on a rooted device. The non-rooted instructions are not
|
interposer library on a rooted device. The non-rooted instructions are not
|
||||||
compatible with applications that use SDL2 for video.
|
compatible with applications that use SDL2 for video.
|
||||||
|
|
||||||
The Tegra Graphics Debugger is available from NVidia here:
|
The Tegra Graphics Debugger is available from NVidia here:
|
||||||
https://developer.nvidia.com/tegra-graphics-debugger
|
https://developer.nvidia.com/tegra-graphics-debugger
|
||||||
|
|
||||||
|
|
||||||
Why is API level 19 the minimum required?
|
Why is API level 19 the minimum required?
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
The latest NDK toolchain doesn't support targeting earlier than API level 19.
|
The latest NDK toolchain doesn't support targeting earlier than API level 19.
|
||||||
As of this writing, according to https://www.composables.com/tools/distribution-chart
|
As of this writing, according to https://www.composables.com/tools/distribution-chart
|
||||||
about 99.7% of the Android devices accessing Google Play support API level 19 or
|
about 99.7% of the Android devices accessing Google Play support API level 19 or
|
||||||
higher (August 2023).
|
higher (August 2023).
|
||||||
|
|
||||||
|
|
||||||
A note regarding the use of the "dirty rectangles" rendering technique
|
A note regarding the use of the "dirty rectangles" rendering technique
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
If your app uses a variation of the "dirty rectangles" rendering technique,
|
If your app uses a variation of the "dirty rectangles" rendering technique,
|
||||||
where you only update a portion of the screen on each frame, you may notice a
|
where you only update a portion of the screen on each frame, you may notice a
|
||||||
variety of visual glitches on Android, that are not present on other platforms.
|
variety of visual glitches on Android, that are not present on other platforms.
|
||||||
This is caused by SDL's use of EGL as the support system to handle OpenGL ES/ES2
|
This is caused by SDL's use of EGL as the support system to handle OpenGL ES/ES2
|
||||||
contexts, in particular the use of the eglSwapBuffers function. As stated in the
|
contexts, in particular the use of the eglSwapBuffers function. As stated in the
|
||||||
documentation for the function "The contents of ancillary buffers are always
|
documentation for the function "The contents of ancillary buffers are always
|
||||||
undefined after calling eglSwapBuffers".
|
undefined after calling eglSwapBuffers".
|
||||||
Setting the EGL_SWAP_BEHAVIOR attribute of the surface to EGL_BUFFER_PRESERVED
|
Setting the EGL_SWAP_BEHAVIOR attribute of the surface to EGL_BUFFER_PRESERVED
|
||||||
is not possible for SDL as it requires EGL 1.4, available only on the API level
|
is not possible for SDL as it requires EGL 1.4, available only on the API level
|
||||||
17+, so the only workaround available on this platform is to redraw the entire
|
17+, so the only workaround available on this platform is to redraw the entire
|
||||||
screen each frame.
|
screen each frame.
|
||||||
|
|
||||||
Reference: http://www.khronos.org/registry/egl/specs/EGLTechNote0001.html
|
Reference: http://www.khronos.org/registry/egl/specs/EGLTechNote0001.html
|
||||||
|
|
||||||
|
|
||||||
Ending your application
|
Ending your application
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
Two legitimate ways:
|
Two legitimate ways:
|
||||||
|
|
||||||
- return from your main() function. Java side will automatically terminate the
|
- return from your main() function. Java side will automatically terminate the
|
||||||
Activity by calling Activity.finish().
|
Activity by calling Activity.finish().
|
||||||
|
|
||||||
- Android OS can decide to terminate your application by calling onDestroy()
|
- Android OS can decide to terminate your application by calling onDestroy()
|
||||||
(see Activity life cycle). Your application will receive a SDL_QUIT event you
|
(see Activity life cycle). Your application will receive a SDL_QUIT event you
|
||||||
can handle to save things and quit.
|
can handle to save things and quit.
|
||||||
|
|
||||||
Don't call exit() as it stops the activity badly.
|
Don't call exit() as it stops the activity badly.
|
||||||
|
|
||||||
NB: "Back button" can be handled as a SDL_KEYDOWN/UP events, with Keycode
|
NB: "Back button" can be handled as a SDL_KEYDOWN/UP events, with Keycode
|
||||||
SDLK_AC_BACK, for any purpose.
|
SDLK_AC_BACK, for any purpose.
|
||||||
|
|
||||||
Known issues
|
Known issues
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
- The number of buttons reported for each joystick is hardcoded to be 36, which
|
- The number of buttons reported for each joystick is hardcoded to be 36, which
|
||||||
is the current maximum number of buttons Android can report.
|
is the current maximum number of buttons Android can report.
|
||||||
|
|
||||||
|
@@ -1,163 +1,163 @@
|
|||||||
# CMake
|
# CMake
|
||||||
|
|
||||||
(www.cmake.org)
|
(www.cmake.org)
|
||||||
|
|
||||||
SDL's build system was traditionally based on autotools. Over time, this
|
SDL's build system was traditionally based on autotools. Over time, this
|
||||||
approach has suffered from several issues across the different supported
|
approach has suffered from several issues across the different supported
|
||||||
platforms.
|
platforms.
|
||||||
To solve these problems, a new build system based on CMake was introduced.
|
To solve these problems, a new build system based on CMake was introduced.
|
||||||
It is developed in parallel to the legacy autotools build system, so users
|
It is developed in parallel to the legacy autotools build system, so users
|
||||||
can experiment with it without complication.
|
can experiment with it without complication.
|
||||||
|
|
||||||
The CMake build system is supported on the following platforms:
|
The CMake build system is supported on the following platforms:
|
||||||
|
|
||||||
* FreeBSD
|
* FreeBSD
|
||||||
* Linux
|
* Linux
|
||||||
* Microsoft Visual C
|
* Microsoft Visual C
|
||||||
* MinGW and Msys
|
* MinGW and Msys
|
||||||
* macOS, iOS, and tvOS, with support for XCode
|
* macOS, iOS, and tvOS, with support for XCode
|
||||||
* Android
|
* Android
|
||||||
* Emscripten
|
* Emscripten
|
||||||
* RiscOS
|
* RiscOS
|
||||||
* Playstation Vita
|
* Playstation Vita
|
||||||
|
|
||||||
## Building SDL
|
## Building SDL
|
||||||
|
|
||||||
Assuming the source for SDL is located at `~/sdl`
|
Assuming the source for SDL is located at `~/sdl`
|
||||||
```sh
|
```sh
|
||||||
cd ~
|
cd ~
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ~/sdl
|
cmake ~/sdl
|
||||||
cmake --build .
|
cmake --build .
|
||||||
```
|
```
|
||||||
|
|
||||||
This will build the static and dynamic versions of SDL in the `~/build` directory.
|
This will build the static and dynamic versions of SDL in the `~/build` directory.
|
||||||
Installation can be done using:
|
Installation can be done using:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cmake --install . # '--install' requires CMake 3.15, or newer
|
cmake --install . # '--install' requires CMake 3.15, or newer
|
||||||
```
|
```
|
||||||
|
|
||||||
## Including SDL in your project
|
## Including SDL in your project
|
||||||
|
|
||||||
SDL can be included in your project in 2 major ways:
|
SDL can be included in your project in 2 major ways:
|
||||||
- using a system SDL library, provided by your (*nix) distribution or a package manager
|
- using a system SDL library, provided by your (*nix) distribution or a package manager
|
||||||
- using a vendored SDL library: this is SDL copied or symlinked in a subfolder.
|
- using a vendored SDL library: this is SDL copied or symlinked in a subfolder.
|
||||||
|
|
||||||
The following CMake script supports both, depending on the value of `MYGAME_VENDORED`.
|
The following CMake script supports both, depending on the value of `MYGAME_VENDORED`.
|
||||||
|
|
||||||
```cmake
|
```cmake
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
project(mygame)
|
project(mygame)
|
||||||
|
|
||||||
# Create an option to switch between a system sdl library and a vendored sdl library
|
# Create an option to switch between a system sdl library and a vendored sdl library
|
||||||
option(MYGAME_VENDORED "Use vendored libraries" OFF)
|
option(MYGAME_VENDORED "Use vendored libraries" OFF)
|
||||||
|
|
||||||
if(MYGAME_VENDORED)
|
if(MYGAME_VENDORED)
|
||||||
add_subdirectory(vendored/sdl EXCLUDE_FROM_ALL)
|
add_subdirectory(vendored/sdl EXCLUDE_FROM_ALL)
|
||||||
else()
|
else()
|
||||||
# 1. Look for a SDL2 package, 2. look for the SDL2 component and 3. fail if none can be found
|
# 1. Look for a SDL2 package, 2. look for the SDL2 component and 3. fail if none can be found
|
||||||
find_package(SDL2 REQUIRED CONFIG REQUIRED COMPONENTS SDL2)
|
find_package(SDL2 REQUIRED CONFIG REQUIRED COMPONENTS SDL2)
|
||||||
|
|
||||||
# 1. Look for a SDL2 package, 2. Look for the SDL2maincomponent and 3. DO NOT fail when SDL2main is not available
|
# 1. Look for a SDL2 package, 2. Look for the SDL2maincomponent and 3. DO NOT fail when SDL2main is not available
|
||||||
find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2main)
|
find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2main)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Create your game executable target as usual
|
# Create your game executable target as usual
|
||||||
add_executable(mygame WIN32 mygame.c)
|
add_executable(mygame WIN32 mygame.c)
|
||||||
|
|
||||||
# SDL2::SDL2main may or may not be available. It is e.g. required by Windows GUI applications
|
# SDL2::SDL2main may or may not be available. It is e.g. required by Windows GUI applications
|
||||||
if(TARGET SDL2::SDL2main)
|
if(TARGET SDL2::SDL2main)
|
||||||
# It has an implicit dependency on SDL2 functions, so it MUST be added before SDL2::SDL2 (or SDL2::SDL2-static)
|
# It has an implicit dependency on SDL2 functions, so it MUST be added before SDL2::SDL2 (or SDL2::SDL2-static)
|
||||||
target_link_libraries(mygame PRIVATE SDL2::SDL2main)
|
target_link_libraries(mygame PRIVATE SDL2::SDL2main)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Link to the actual SDL2 library. SDL2::SDL2 is the shared SDL library, SDL2::SDL2-static is the static SDL libarary.
|
# Link to the actual SDL2 library. SDL2::SDL2 is the shared SDL library, SDL2::SDL2-static is the static SDL libarary.
|
||||||
target_link_libraries(mygame PRIVATE SDL2::SDL2)
|
target_link_libraries(mygame PRIVATE SDL2::SDL2)
|
||||||
```
|
```
|
||||||
|
|
||||||
### A system SDL library
|
### A system SDL library
|
||||||
|
|
||||||
For CMake to find SDL, it must be installed in [a default location CMake is looking for](https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure).
|
For CMake to find SDL, it must be installed in [a default location CMake is looking for](https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure).
|
||||||
|
|
||||||
The following components are available, to be used as an argument of `find_package`.
|
The following components are available, to be used as an argument of `find_package`.
|
||||||
|
|
||||||
| Component name | Description |
|
| Component name | Description |
|
||||||
|----------------|--------------------------------------------------------------------------------------------|
|
|----------------|--------------------------------------------------------------------------------------------|
|
||||||
| SDL2 | The SDL2 shared library, available through the `SDL2::SDL2` target [^SDL_TARGET_EXCEPTION] |
|
| SDL2 | The SDL2 shared library, available through the `SDL2::SDL2` target [^SDL_TARGET_EXCEPTION] |
|
||||||
| SDL2-static | The SDL2 static library, available through the `SDL2::SDL2-static` target |
|
| SDL2-static | The SDL2 static library, available through the `SDL2::SDL2-static` target |
|
||||||
| SDL2main | The SDL2main static library, available through the `SDL2::SDL2main` target |
|
| SDL2main | The SDL2main static library, available through the `SDL2::SDL2main` target |
|
||||||
| SDL2test | The SDL2test static library, available through the `SDL2::SDL2test` target |
|
| SDL2test | The SDL2test static library, available through the `SDL2::SDL2test` target |
|
||||||
|
|
||||||
### Using a vendored SDL
|
### Using a vendored SDL
|
||||||
|
|
||||||
This only requires a copy of SDL in a subdirectory.
|
This only requires a copy of SDL in a subdirectory.
|
||||||
|
|
||||||
## CMake configuration options for platforms
|
## CMake configuration options for platforms
|
||||||
|
|
||||||
### iOS/tvOS
|
### iOS/tvOS
|
||||||
|
|
||||||
CMake 3.14+ natively includes support for iOS and tvOS. SDL binaries may be built
|
CMake 3.14+ natively includes support for iOS and tvOS. SDL binaries may be built
|
||||||
using Xcode or Make, possibly among other build-systems.
|
using Xcode or Make, possibly among other build-systems.
|
||||||
|
|
||||||
When using a recent version of CMake (3.14+), it should be possible to:
|
When using a recent version of CMake (3.14+), it should be possible to:
|
||||||
|
|
||||||
- build SDL for iOS, both static and dynamic
|
- build SDL for iOS, both static and dynamic
|
||||||
- build SDL test apps (as iOS/tvOS .app bundles)
|
- build SDL test apps (as iOS/tvOS .app bundles)
|
||||||
- generate a working SDL_config.h for iOS (using SDL_config.h.cmake as a basis)
|
- generate a working SDL_config.h for iOS (using SDL_config.h.cmake as a basis)
|
||||||
|
|
||||||
To use, set the following CMake variables when running CMake's configuration stage:
|
To use, set the following CMake variables when running CMake's configuration stage:
|
||||||
|
|
||||||
- `CMAKE_SYSTEM_NAME=<OS>` (either `iOS` or `tvOS`)
|
- `CMAKE_SYSTEM_NAME=<OS>` (either `iOS` or `tvOS`)
|
||||||
- `CMAKE_OSX_SYSROOT=<SDK>` (examples: `iphoneos`, `iphonesimulator`, `iphoneos12.4`, `/full/path/to/iPhoneOS.sdk`,
|
- `CMAKE_OSX_SYSROOT=<SDK>` (examples: `iphoneos`, `iphonesimulator`, `iphoneos12.4`, `/full/path/to/iPhoneOS.sdk`,
|
||||||
`appletvos`, `appletvsimulator`, `appletvos12.4`, `/full/path/to/AppleTVOS.sdk`, etc.)
|
`appletvos`, `appletvsimulator`, `appletvos12.4`, `/full/path/to/AppleTVOS.sdk`, etc.)
|
||||||
- `CMAKE_OSX_ARCHITECTURES=<semicolon-separated list of CPU architectures>` (example: "arm64;armv7s;x86_64")
|
- `CMAKE_OSX_ARCHITECTURES=<semicolon-separated list of CPU architectures>` (example: "arm64;armv7s;x86_64")
|
||||||
|
|
||||||
|
|
||||||
#### Examples
|
#### Examples
|
||||||
|
|
||||||
- for iOS-Simulator, using the latest, installed SDK:
|
- for iOS-Simulator, using the latest, installed SDK:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
|
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
|
||||||
```
|
```
|
||||||
|
|
||||||
- for iOS-Device, using the latest, installed SDK, 64-bit only
|
- for iOS-Device, using the latest, installed SDK, 64-bit only
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=arm64
|
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=arm64
|
||||||
```
|
```
|
||||||
|
|
||||||
- for iOS-Device, using the latest, installed SDK, mixed 32/64 bit
|
- for iOS-Device, using the latest, installed SDK, mixed 32/64 bit
|
||||||
|
|
||||||
```cmake
|
```cmake
|
||||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES="arm64;armv7s"
|
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES="arm64;armv7s"
|
||||||
```
|
```
|
||||||
|
|
||||||
- for iOS-Device, using a specific SDK revision (iOS 12.4, in this example):
|
- for iOS-Device, using a specific SDK revision (iOS 12.4, in this example):
|
||||||
|
|
||||||
```cmake
|
```cmake
|
||||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos12.4 -DCMAKE_OSX_ARCHITECTURES=arm64
|
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos12.4 -DCMAKE_OSX_ARCHITECTURES=arm64
|
||||||
```
|
```
|
||||||
|
|
||||||
- for iOS-Simulator, using the latest, installed SDK, and building SDL test apps (as .app bundles):
|
- for iOS-Simulator, using the latest, installed SDK, and building SDL test apps (as .app bundles):
|
||||||
|
|
||||||
```cmake
|
```cmake
|
||||||
cmake ~/sdl -DSDL_TESTS=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
|
cmake ~/sdl -DSDL_TESTS=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
|
||||||
```
|
```
|
||||||
|
|
||||||
- for tvOS-Simulator, using the latest, installed SDK:
|
- for tvOS-Simulator, using the latest, installed SDK:
|
||||||
|
|
||||||
```cmake
|
```cmake
|
||||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvsimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
|
cmake ~/sdl -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvsimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
|
||||||
```
|
```
|
||||||
|
|
||||||
- for tvOS-Device, using the latest, installed SDK:
|
- for tvOS-Device, using the latest, installed SDK:
|
||||||
|
|
||||||
```cmake
|
```cmake
|
||||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_ARCHITECTURES=arm64`
|
cmake ~/sdl -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_ARCHITECTURES=arm64`
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
[^SDL_TARGET_EXCEPTION]: `SDL2::SDL2` can be an ALIAS to a static `SDL2::SDL2-static` target for multiple reasons.
|
[^SDL_TARGET_EXCEPTION]: `SDL2::SDL2` can be an ALIAS to a static `SDL2::SDL2-static` target for multiple reasons.
|
||||||
|
@@ -1,123 +1,123 @@
|
|||||||
DirectFB
|
DirectFB
|
||||||
========
|
========
|
||||||
|
|
||||||
Supports:
|
Supports:
|
||||||
|
|
||||||
- Hardware YUV overlays
|
- Hardware YUV overlays
|
||||||
- OpenGL - software only
|
- OpenGL - software only
|
||||||
- 2D/3D accelerations (depends on directfb driver)
|
- 2D/3D accelerations (depends on directfb driver)
|
||||||
- multiple displays
|
- multiple displays
|
||||||
- windows
|
- windows
|
||||||
|
|
||||||
What you need:
|
What you need:
|
||||||
|
|
||||||
* DirectFB 1.0.1, 1.2.x, 1.3.0
|
* DirectFB 1.0.1, 1.2.x, 1.3.0
|
||||||
* Kernel-Framebuffer support: required: vesafb, radeonfb ....
|
* Kernel-Framebuffer support: required: vesafb, radeonfb ....
|
||||||
* Mesa 7.0.x - optional for OpenGL
|
* Mesa 7.0.x - optional for OpenGL
|
||||||
|
|
||||||
The `/etc/directfbrc` file should contain the following lines to make
|
The `/etc/directfbrc` file should contain the following lines to make
|
||||||
your joystick work and avoid crashes:
|
your joystick work and avoid crashes:
|
||||||
|
|
||||||
```
|
```
|
||||||
disable-module=joystick
|
disable-module=joystick
|
||||||
disable-module=cle266
|
disable-module=cle266
|
||||||
disable-module=cyber5k
|
disable-module=cyber5k
|
||||||
no-linux-input-grab
|
no-linux-input-grab
|
||||||
```
|
```
|
||||||
|
|
||||||
To disable to use x11 backend when DISPLAY variable is found use
|
To disable to use x11 backend when DISPLAY variable is found use
|
||||||
|
|
||||||
```
|
```
|
||||||
export SDL_DIRECTFB_X11_CHECK=0
|
export SDL_DIRECTFB_X11_CHECK=0
|
||||||
```
|
```
|
||||||
|
|
||||||
To disable the use of linux input devices, i.e. multimice/multikeyboard support,
|
To disable the use of linux input devices, i.e. multimice/multikeyboard support,
|
||||||
use
|
use
|
||||||
|
|
||||||
```
|
```
|
||||||
export SDL_DIRECTFB_LINUX_INPUT=0
|
export SDL_DIRECTFB_LINUX_INPUT=0
|
||||||
```
|
```
|
||||||
|
|
||||||
To use hardware accelerated YUV-overlays for YUV-textures, use:
|
To use hardware accelerated YUV-overlays for YUV-textures, use:
|
||||||
|
|
||||||
```
|
```
|
||||||
export SDL_DIRECTFB_YUV_DIRECT=1
|
export SDL_DIRECTFB_YUV_DIRECT=1
|
||||||
```
|
```
|
||||||
|
|
||||||
This is disabled by default. It will only support one
|
This is disabled by default. It will only support one
|
||||||
YUV texture, namely the first. Every other YUV texture will be
|
YUV texture, namely the first. Every other YUV texture will be
|
||||||
rendered in software.
|
rendered in software.
|
||||||
|
|
||||||
In addition, you may use (directfb-1.2.x)
|
In addition, you may use (directfb-1.2.x)
|
||||||
|
|
||||||
```
|
```
|
||||||
export SDL_DIRECTFB_YUV_UNDERLAY=1
|
export SDL_DIRECTFB_YUV_UNDERLAY=1
|
||||||
```
|
```
|
||||||
|
|
||||||
to make the YUV texture an underlay. This will make the cursor to
|
to make the YUV texture an underlay. This will make the cursor to
|
||||||
be shown.
|
be shown.
|
||||||
|
|
||||||
Simple Window Manager
|
Simple Window Manager
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
The driver has support for a very, very basic window manager you may
|
The driver has support for a very, very basic window manager you may
|
||||||
want to use when running with `wm=default`. Use
|
want to use when running with `wm=default`. Use
|
||||||
|
|
||||||
```
|
```
|
||||||
export SDL_DIRECTFB_WM=1
|
export SDL_DIRECTFB_WM=1
|
||||||
```
|
```
|
||||||
|
|
||||||
to enable basic window borders. In order to have the window title rendered,
|
to enable basic window borders. In order to have the window title rendered,
|
||||||
you need to have the following font installed:
|
you need to have the following font installed:
|
||||||
|
|
||||||
```
|
```
|
||||||
/usr/share/fonts/truetype/freefont/FreeSans.ttf
|
/usr/share/fonts/truetype/freefont/FreeSans.ttf
|
||||||
```
|
```
|
||||||
|
|
||||||
OpenGL Support
|
OpenGL Support
|
||||||
==============
|
==============
|
||||||
|
|
||||||
The following instructions will give you *software* OpenGL. However this
|
The following instructions will give you *software* OpenGL. However this
|
||||||
works at least on all directfb supported platforms.
|
works at least on all directfb supported platforms.
|
||||||
|
|
||||||
As of this writing 20100802 you need to pull Mesa from git and do the following:
|
As of this writing 20100802 you need to pull Mesa from git and do the following:
|
||||||
|
|
||||||
```
|
```
|
||||||
git clone git://anongit.freedesktop.org/git/mesa/mesa
|
git clone git://anongit.freedesktop.org/git/mesa/mesa
|
||||||
cd mesa
|
cd mesa
|
||||||
git checkout 2c9fdaf7292423c157fc79b5ce43f0f199dd753a
|
git checkout 2c9fdaf7292423c157fc79b5ce43f0f199dd753a
|
||||||
```
|
```
|
||||||
|
|
||||||
Edit `configs/linux-directfb` so that the Directories-section looks like this:
|
Edit `configs/linux-directfb` so that the Directories-section looks like this:
|
||||||
|
|
||||||
```
|
```
|
||||||
# Directories
|
# Directories
|
||||||
SRC_DIRS = mesa glu
|
SRC_DIRS = mesa glu
|
||||||
GLU_DIRS = sgi
|
GLU_DIRS = sgi
|
||||||
DRIVER_DIRS = directfb
|
DRIVER_DIRS = directfb
|
||||||
PROGRAM_DIRS =
|
PROGRAM_DIRS =
|
||||||
```
|
```
|
||||||
|
|
||||||
Then do the following:
|
Then do the following:
|
||||||
|
|
||||||
```
|
```
|
||||||
make linux-directfb
|
make linux-directfb
|
||||||
make
|
make
|
||||||
|
|
||||||
echo Installing - please enter sudo pw.
|
echo Installing - please enter sudo pw.
|
||||||
|
|
||||||
sudo make install INSTALL_DIR=/usr/local/dfb_GL
|
sudo make install INSTALL_DIR=/usr/local/dfb_GL
|
||||||
cd src/mesa/drivers/directfb
|
cd src/mesa/drivers/directfb
|
||||||
make
|
make
|
||||||
sudo make install INSTALL_DIR=/usr/local/dfb_GL
|
sudo make install INSTALL_DIR=/usr/local/dfb_GL
|
||||||
```
|
```
|
||||||
|
|
||||||
To run the SDL - testprograms:
|
To run the SDL - testprograms:
|
||||||
|
|
||||||
```
|
```
|
||||||
export SDL_VIDEODRIVER=directfb
|
export SDL_VIDEODRIVER=directfb
|
||||||
export LD_LIBRARY_PATH=/usr/local/dfb_GL/lib
|
export LD_LIBRARY_PATH=/usr/local/dfb_GL/lib
|
||||||
export LD_PRELOAD=/usr/local/dfb_GL/libGL.so.7
|
export LD_PRELOAD=/usr/local/dfb_GL/libGL.so.7
|
||||||
|
|
||||||
./testgl
|
./testgl
|
||||||
```
|
```
|
||||||
|
@@ -1,138 +1,138 @@
|
|||||||
# Dynamic API
|
# Dynamic API
|
||||||
|
|
||||||
Originally posted on Ryan's Google+ account.
|
Originally posted on Ryan's Google+ account.
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
|
|
||||||
- The Steam Runtime has (at least in theory) a really kick-ass build of SDL2,
|
- The Steam Runtime has (at least in theory) a really kick-ass build of SDL2,
|
||||||
but developers are shipping their own SDL2 with individual Steam games.
|
but developers are shipping their own SDL2 with individual Steam games.
|
||||||
These games might stop getting updates, but a newer SDL2 might be needed later.
|
These games might stop getting updates, but a newer SDL2 might be needed later.
|
||||||
Certainly we'll always be fixing bugs in SDL, even if a new video target isn't
|
Certainly we'll always be fixing bugs in SDL, even if a new video target isn't
|
||||||
ever needed, and these fixes won't make it to a game shipping its own SDL.
|
ever needed, and these fixes won't make it to a game shipping its own SDL.
|
||||||
- Even if we replace the SDL2 in those games with a compatible one, that is to
|
- Even if we replace the SDL2 in those games with a compatible one, that is to
|
||||||
say, edit a developer's Steam depot (yuck!), there are developers that are
|
say, edit a developer's Steam depot (yuck!), there are developers that are
|
||||||
statically linking SDL2 that we can't do this for. We can't even force the
|
statically linking SDL2 that we can't do this for. We can't even force the
|
||||||
dynamic loader to ignore their SDL2 in this case, of course.
|
dynamic loader to ignore their SDL2 in this case, of course.
|
||||||
- If you don't ship an SDL2 with the game in some form, people that disabled the
|
- If you don't ship an SDL2 with the game in some form, people that disabled the
|
||||||
Steam Runtime, or just tried to run the game from the command line instead of
|
Steam Runtime, or just tried to run the game from the command line instead of
|
||||||
Steam might find themselves unable to run the game, due to a missing dependency.
|
Steam might find themselves unable to run the game, due to a missing dependency.
|
||||||
- If you want to ship on non-Steam platforms like GOG or Humble Bundle, or target
|
- If you want to ship on non-Steam platforms like GOG or Humble Bundle, or target
|
||||||
generic Linux boxes that may or may not have SDL2 installed, you have to ship
|
generic Linux boxes that may or may not have SDL2 installed, you have to ship
|
||||||
the library or risk a total failure to launch. So now, you might have to have
|
the library or risk a total failure to launch. So now, you might have to have
|
||||||
a non-Steam build plus a Steam build (that is, one with and one without SDL2
|
a non-Steam build plus a Steam build (that is, one with and one without SDL2
|
||||||
included), which is inconvenient if you could have had one universal build
|
included), which is inconvenient if you could have had one universal build
|
||||||
that works everywhere.
|
that works everywhere.
|
||||||
- We like the zlib license, but the biggest complaint from the open source
|
- We like the zlib license, but the biggest complaint from the open source
|
||||||
community about the license change is the static linking. The LGPL forced this
|
community about the license change is the static linking. The LGPL forced this
|
||||||
as a legal, not technical issue, but zlib doesn't care. Even those that aren't
|
as a legal, not technical issue, but zlib doesn't care. Even those that aren't
|
||||||
concerned about the GNU freedoms found themselves solving the same problems:
|
concerned about the GNU freedoms found themselves solving the same problems:
|
||||||
swapping in a newer SDL to an older game often times can save the day.
|
swapping in a newer SDL to an older game often times can save the day.
|
||||||
Static linking stops this dead.
|
Static linking stops this dead.
|
||||||
|
|
||||||
So here's what we did:
|
So here's what we did:
|
||||||
|
|
||||||
SDL now has, internally, a table of function pointers. So, this is what SDL_Init
|
SDL now has, internally, a table of function pointers. So, this is what SDL_Init
|
||||||
now looks like:
|
now looks like:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
Uint32 SDL_Init(Uint32 flags)
|
Uint32 SDL_Init(Uint32 flags)
|
||||||
{
|
{
|
||||||
return jump_table.SDL_Init(flags);
|
return jump_table.SDL_Init(flags);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Except that is all done with a bunch of macro magic so we don't have to maintain
|
Except that is all done with a bunch of macro magic so we don't have to maintain
|
||||||
every one of these.
|
every one of these.
|
||||||
|
|
||||||
What is jump_table.SDL_init()? Eventually, that's a function pointer of the real
|
What is jump_table.SDL_init()? Eventually, that's a function pointer of the real
|
||||||
SDL_Init() that you've been calling all this time. But at startup, it looks more
|
SDL_Init() that you've been calling all this time. But at startup, it looks more
|
||||||
like this:
|
like this:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
Uint32 SDL_Init_DEFAULT(Uint32 flags)
|
Uint32 SDL_Init_DEFAULT(Uint32 flags)
|
||||||
{
|
{
|
||||||
SDL_InitDynamicAPI();
|
SDL_InitDynamicAPI();
|
||||||
return jump_table.SDL_Init(flags);
|
return jump_table.SDL_Init(flags);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
SDL_InitDynamicAPI() fills in jump_table with all the actual SDL function
|
SDL_InitDynamicAPI() fills in jump_table with all the actual SDL function
|
||||||
pointers, which means that this `_DEFAULT` function never gets called again.
|
pointers, which means that this `_DEFAULT` function never gets called again.
|
||||||
First call to any SDL function sets the whole thing up.
|
First call to any SDL function sets the whole thing up.
|
||||||
|
|
||||||
So you might be asking, what was the value in that? Isn't this what the operating
|
So you might be asking, what was the value in that? Isn't this what the operating
|
||||||
system's dynamic loader was supposed to do for us? Yes, but now we've got this
|
system's dynamic loader was supposed to do for us? Yes, but now we've got this
|
||||||
level of indirection, we can do things like this:
|
level of indirection, we can do things like this:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export SDL_DYNAMIC_API=/my/actual/libSDL-2.0.so.0
|
export SDL_DYNAMIC_API=/my/actual/libSDL-2.0.so.0
|
||||||
./MyGameThatIsStaticallyLinkedToSDL2
|
./MyGameThatIsStaticallyLinkedToSDL2
|
||||||
```
|
```
|
||||||
|
|
||||||
And now, this game that is statically linked to SDL, can still be overridden
|
And now, this game that is statically linked to SDL, can still be overridden
|
||||||
with a newer, or better, SDL. The statically linked one will only be used as
|
with a newer, or better, SDL. The statically linked one will only be used as
|
||||||
far as calling into the jump table in this case. But in cases where no override
|
far as calling into the jump table in this case. But in cases where no override
|
||||||
is desired, the statically linked version will provide its own jump table,
|
is desired, the statically linked version will provide its own jump table,
|
||||||
and everyone is happy.
|
and everyone is happy.
|
||||||
|
|
||||||
So now:
|
So now:
|
||||||
- Developers can statically link SDL, and users can still replace it.
|
- Developers can statically link SDL, and users can still replace it.
|
||||||
(We'd still rather you ship a shared library, though!)
|
(We'd still rather you ship a shared library, though!)
|
||||||
- Developers can ship an SDL with their game, Valve can override it for, say,
|
- Developers can ship an SDL with their game, Valve can override it for, say,
|
||||||
new features on SteamOS, or distros can override it for their own needs,
|
new features on SteamOS, or distros can override it for their own needs,
|
||||||
but it'll also just work in the default case.
|
but it'll also just work in the default case.
|
||||||
- Developers can ship the same package to everyone (Humble Bundle, GOG, etc),
|
- Developers can ship the same package to everyone (Humble Bundle, GOG, etc),
|
||||||
and it'll do the right thing.
|
and it'll do the right thing.
|
||||||
- End users (and Valve) can update a game's SDL in almost any case,
|
- End users (and Valve) can update a game's SDL in almost any case,
|
||||||
to keep abandoned games running on newer platforms.
|
to keep abandoned games running on newer platforms.
|
||||||
- Everyone develops with SDL exactly as they have been doing all along.
|
- Everyone develops with SDL exactly as they have been doing all along.
|
||||||
Same headers, same ABI. Just get the latest version to enable this magic.
|
Same headers, same ABI. Just get the latest version to enable this magic.
|
||||||
|
|
||||||
|
|
||||||
A little more about SDL_InitDynamicAPI():
|
A little more about SDL_InitDynamicAPI():
|
||||||
|
|
||||||
Internally, InitAPI does some locking to make sure everything waits until a
|
Internally, InitAPI does some locking to make sure everything waits until a
|
||||||
single thread initializes everything (although even SDL_CreateThread() goes
|
single thread initializes everything (although even SDL_CreateThread() goes
|
||||||
through here before spinning a thread, too), and then decides if it should use
|
through here before spinning a thread, too), and then decides if it should use
|
||||||
an external SDL library. If not, it sets up the jump table using the current
|
an external SDL library. If not, it sets up the jump table using the current
|
||||||
SDL's function pointers (which might be statically linked into a program, or in
|
SDL's function pointers (which might be statically linked into a program, or in
|
||||||
a shared library of its own). If so, it loads that library and looks for and
|
a shared library of its own). If so, it loads that library and looks for and
|
||||||
calls a single function:
|
calls a single function:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
Sint32 SDL_DYNAPI_entry(Uint32 version, void *table, Uint32 tablesize);
|
Sint32 SDL_DYNAPI_entry(Uint32 version, void *table, Uint32 tablesize);
|
||||||
```
|
```
|
||||||
|
|
||||||
That function takes a version number (more on that in a moment), the address of
|
That function takes a version number (more on that in a moment), the address of
|
||||||
the jump table, and the size, in bytes, of the table.
|
the jump table, and the size, in bytes, of the table.
|
||||||
Now, we've got policy here: this table's layout never changes; new stuff gets
|
Now, we've got policy here: this table's layout never changes; new stuff gets
|
||||||
added to the end. Therefore SDL_DYNAPI_entry() knows that it can provide all
|
added to the end. Therefore SDL_DYNAPI_entry() knows that it can provide all
|
||||||
the needed functions if tablesize <= sizeof its own jump table. If tablesize is
|
the needed functions if tablesize <= sizeof its own jump table. If tablesize is
|
||||||
bigger (say, SDL 2.0.4 is trying to load SDL 2.0.3), then we know to abort, but
|
bigger (say, SDL 2.0.4 is trying to load SDL 2.0.3), then we know to abort, but
|
||||||
if it's smaller, we know we can provide the entire API that the caller needs.
|
if it's smaller, we know we can provide the entire API that the caller needs.
|
||||||
|
|
||||||
The version variable is a failsafe switch.
|
The version variable is a failsafe switch.
|
||||||
Right now it's always 1. This number changes when there are major API changes
|
Right now it's always 1. This number changes when there are major API changes
|
||||||
(so we know if the tablesize might be smaller, or entries in it have changed).
|
(so we know if the tablesize might be smaller, or entries in it have changed).
|
||||||
Right now SDL_DYNAPI_entry gives up if the version doesn't match, but it's not
|
Right now SDL_DYNAPI_entry gives up if the version doesn't match, but it's not
|
||||||
inconceivable to have a small dispatch library that only supplies this one
|
inconceivable to have a small dispatch library that only supplies this one
|
||||||
function and loads different, otherwise-incompatible SDL libraries and has the
|
function and loads different, otherwise-incompatible SDL libraries and has the
|
||||||
right one initialize the jump table based on the version. For something that
|
right one initialize the jump table based on the version. For something that
|
||||||
must generically catch lots of different versions of SDL over time, like the
|
must generically catch lots of different versions of SDL over time, like the
|
||||||
Steam Client, this isn't a bad option.
|
Steam Client, this isn't a bad option.
|
||||||
|
|
||||||
Finally, I'm sure some people are reading this and thinking,
|
Finally, I'm sure some people are reading this and thinking,
|
||||||
"I don't want that overhead in my project!"
|
"I don't want that overhead in my project!"
|
||||||
|
|
||||||
To which I would point out that the extra function call through the jump table
|
To which I would point out that the extra function call through the jump table
|
||||||
probably wouldn't even show up in a profile, but lucky you: this can all be
|
probably wouldn't even show up in a profile, but lucky you: this can all be
|
||||||
disabled. You can build SDL without this if you absolutely must, but we would
|
disabled. You can build SDL without this if you absolutely must, but we would
|
||||||
encourage you not to do that. However, on heavily locked down platforms like
|
encourage you not to do that. However, on heavily locked down platforms like
|
||||||
iOS, or maybe when debugging, it makes sense to disable it. The way this is
|
iOS, or maybe when debugging, it makes sense to disable it. The way this is
|
||||||
designed in SDL, you just have to change one #define, and the entire system
|
designed in SDL, you just have to change one #define, and the entire system
|
||||||
vaporizes out, and SDL functions exactly like it always did. Most of it is
|
vaporizes out, and SDL functions exactly like it always did. Most of it is
|
||||||
macro magic, so the system is contained to one C file and a few headers.
|
macro magic, so the system is contained to one C file and a few headers.
|
||||||
However, this is on by default and you have to edit a header file to turn it
|
However, this is on by default and you have to edit a header file to turn it
|
||||||
off. Our hopes is that if we make it easy to disable, but not too easy,
|
off. Our hopes is that if we make it easy to disable, but not too easy,
|
||||||
everyone will ultimately be able to get what they want, but we've gently
|
everyone will ultimately be able to get what they want, but we've gently
|
||||||
nudged everyone towards what we think is the best solution.
|
nudged everyone towards what we think is the best solution.
|
||||||
|
@@ -1,374 +1,374 @@
|
|||||||
# Emscripten
|
# Emscripten
|
||||||
|
|
||||||
## The state of things
|
## The state of things
|
||||||
|
|
||||||
(As of September 2023, but things move quickly and we don't update this
|
(As of September 2023, but things move quickly and we don't update this
|
||||||
document often.)
|
document often.)
|
||||||
|
|
||||||
In modern times, all the browsers you probably care about (Chrome, Firefox,
|
In modern times, all the browsers you probably care about (Chrome, Firefox,
|
||||||
Edge, and Safari, on Windows, macOS, Linux, iOS and Android), support some
|
Edge, and Safari, on Windows, macOS, Linux, iOS and Android), support some
|
||||||
reasonable base configurations:
|
reasonable base configurations:
|
||||||
|
|
||||||
- WebAssembly (don't bother with asm.js any more)
|
- WebAssembly (don't bother with asm.js any more)
|
||||||
- WebGL (which will look like OpenGL ES 2 or 3 to your app).
|
- WebGL (which will look like OpenGL ES 2 or 3 to your app).
|
||||||
- Threads (see caveats, though!)
|
- Threads (see caveats, though!)
|
||||||
- Game controllers
|
- Game controllers
|
||||||
- Autoupdating (so you can assume they have a recent version of the browser)
|
- Autoupdating (so you can assume they have a recent version of the browser)
|
||||||
|
|
||||||
All this to say we're at the point where you don't have to make a lot of
|
All this to say we're at the point where you don't have to make a lot of
|
||||||
concessions to get even a fairly complex SDL-based game up and running.
|
concessions to get even a fairly complex SDL-based game up and running.
|
||||||
|
|
||||||
|
|
||||||
## RTFM
|
## RTFM
|
||||||
|
|
||||||
This document is a quick rundown of some high-level details. The
|
This document is a quick rundown of some high-level details. The
|
||||||
documentation at [emscripten.org](https://emscripten.org/) is vast
|
documentation at [emscripten.org](https://emscripten.org/) is vast
|
||||||
and extremely detailed for a wide variety of topics, and you should at
|
and extremely detailed for a wide variety of topics, and you should at
|
||||||
least skim through it at some point.
|
least skim through it at some point.
|
||||||
|
|
||||||
|
|
||||||
## Porting your app to Emscripten
|
## Porting your app to Emscripten
|
||||||
|
|
||||||
Many many things just need some simple adjustments and they'll compile
|
Many many things just need some simple adjustments and they'll compile
|
||||||
like any other C/C++ code, as long as SDL was handling the platform-specific
|
like any other C/C++ code, as long as SDL was handling the platform-specific
|
||||||
work for your program.
|
work for your program.
|
||||||
|
|
||||||
First, you probably need this in at least one of your source files:
|
First, you probably need this in at least one of your source files:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
#include <emscripten.h>
|
#include <emscripten.h>
|
||||||
#endif
|
#endif
|
||||||
```
|
```
|
||||||
|
|
||||||
Second: assembly language code has to go. Replace it with C. You can even use
|
Second: assembly language code has to go. Replace it with C. You can even use
|
||||||
[x86 SIMD intrinsic functions in Emscripten](https://emscripten.org/docs/porting/simd.html)!
|
[x86 SIMD intrinsic functions in Emscripten](https://emscripten.org/docs/porting/simd.html)!
|
||||||
|
|
||||||
Third: Middleware has to go. If you have a third-party library you link
|
Third: Middleware has to go. If you have a third-party library you link
|
||||||
against, you either need an Emscripten port of it, or the source code to it
|
against, you either need an Emscripten port of it, or the source code to it
|
||||||
to compile yourself, or you need to remove it.
|
to compile yourself, or you need to remove it.
|
||||||
|
|
||||||
Fourth: You still start in a function called main(), but you need to get out of
|
Fourth: You still start in a function called main(), but you need to get out of
|
||||||
it and into a function that gets called repeatedly, and returns quickly,
|
it and into a function that gets called repeatedly, and returns quickly,
|
||||||
called a mainloop.
|
called a mainloop.
|
||||||
|
|
||||||
Somewhere in your program, you probably have something that looks like a more
|
Somewhere in your program, you probably have something that looks like a more
|
||||||
complicated version of this:
|
complicated version of this:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
initialize_the_game();
|
initialize_the_game();
|
||||||
while (game_is_still_running) {
|
while (game_is_still_running) {
|
||||||
check_for_new_input();
|
check_for_new_input();
|
||||||
think_about_stuff();
|
think_about_stuff();
|
||||||
draw_the_next_frame();
|
draw_the_next_frame();
|
||||||
}
|
}
|
||||||
deinitialize_the_game();
|
deinitialize_the_game();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This will not work on Emscripten, because the main thread needs to be free
|
This will not work on Emscripten, because the main thread needs to be free
|
||||||
to do stuff and can't sit in this loop forever. So Emscripten lets you set up
|
to do stuff and can't sit in this loop forever. So Emscripten lets you set up
|
||||||
a [mainloop](https://emscripten.org/docs/porting/emscripten-runtime-environment.html#browser-main-loop).
|
a [mainloop](https://emscripten.org/docs/porting/emscripten-runtime-environment.html#browser-main-loop).
|
||||||
|
|
||||||
```c
|
```c
|
||||||
static void mainloop(void) /* this will run often, possibly at the monitor's refresh rate */
|
static void mainloop(void) /* this will run often, possibly at the monitor's refresh rate */
|
||||||
{
|
{
|
||||||
if (!game_is_still_running) {
|
if (!game_is_still_running) {
|
||||||
deinitialize_the_game();
|
deinitialize_the_game();
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
emscripten_cancel_main_loop(); /* this should "kill" the app. */
|
emscripten_cancel_main_loop(); /* this should "kill" the app. */
|
||||||
#else
|
#else
|
||||||
exit(0);
|
exit(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
check_for_new_input();
|
check_for_new_input();
|
||||||
think_about_stuff();
|
think_about_stuff();
|
||||||
draw_the_next_frame();
|
draw_the_next_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
initialize_the_game();
|
initialize_the_game();
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
emscripten_set_main_loop(mainloop, 0, 1);
|
emscripten_set_main_loop(mainloop, 0, 1);
|
||||||
#else
|
#else
|
||||||
while (1) { mainloop(); }
|
while (1) { mainloop(); }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Basically, `emscripten_set_main_loop(mainloop, 0, 1);` says "run
|
Basically, `emscripten_set_main_loop(mainloop, 0, 1);` says "run
|
||||||
`mainloop` over and over until I end the program." The function will
|
`mainloop` over and over until I end the program." The function will
|
||||||
run, and return, freeing the main thread for other tasks, and then
|
run, and return, freeing the main thread for other tasks, and then
|
||||||
run again when it's time. The `1` parameter does some magic to make
|
run again when it's time. The `1` parameter does some magic to make
|
||||||
your main() function end immediately; this is useful because you
|
your main() function end immediately; this is useful because you
|
||||||
don't want any shutdown code that might be sitting below this code
|
don't want any shutdown code that might be sitting below this code
|
||||||
to actually run if main() were to continue on, since we're just
|
to actually run if main() were to continue on, since we're just
|
||||||
getting started.
|
getting started.
|
||||||
|
|
||||||
There's a lot of little details that are beyond the scope of this
|
There's a lot of little details that are beyond the scope of this
|
||||||
document, but that's the biggest intial set of hurdles to porting
|
document, but that's the biggest intial set of hurdles to porting
|
||||||
your app to the web.
|
your app to the web.
|
||||||
|
|
||||||
|
|
||||||
## Do you need threads?
|
## Do you need threads?
|
||||||
|
|
||||||
If you plan to use threads, they work on all major browsers now. HOWEVER,
|
If you plan to use threads, they work on all major browsers now. HOWEVER,
|
||||||
they bring with them a lot of careful considerations. Rendering _must_
|
they bring with them a lot of careful considerations. Rendering _must_
|
||||||
be done on the main thread. This is a general guideline for many
|
be done on the main thread. This is a general guideline for many
|
||||||
platforms, but a hard requirement on the web.
|
platforms, but a hard requirement on the web.
|
||||||
|
|
||||||
Many other things also must happen on the main thread; often times SDL
|
Many other things also must happen on the main thread; often times SDL
|
||||||
and Emscripten make efforts to "proxy" work to the main thread that
|
and Emscripten make efforts to "proxy" work to the main thread that
|
||||||
must be there, but you have to be careful (and read more detailed
|
must be there, but you have to be careful (and read more detailed
|
||||||
documentation than this for the finer points).
|
documentation than this for the finer points).
|
||||||
|
|
||||||
Even when using threads, your main thread needs to set an Emscripten
|
Even when using threads, your main thread needs to set an Emscripten
|
||||||
mainloop that runs quickly and returns, or things will fail to work
|
mainloop that runs quickly and returns, or things will fail to work
|
||||||
correctly.
|
correctly.
|
||||||
|
|
||||||
You should definitely read [Emscripten's pthreads docs](https://emscripten.org/docs/porting/pthreads.html)
|
You should definitely read [Emscripten's pthreads docs](https://emscripten.org/docs/porting/pthreads.html)
|
||||||
for all the finer points. Mostly SDL's thread API will work as expected,
|
for all the finer points. Mostly SDL's thread API will work as expected,
|
||||||
but is built on pthreads, so it shares the same little incompatibilities
|
but is built on pthreads, so it shares the same little incompatibilities
|
||||||
that are documented there, such as where you can use a mutex, and when
|
that are documented there, such as where you can use a mutex, and when
|
||||||
a thread will start running, etc.
|
a thread will start running, etc.
|
||||||
|
|
||||||
|
|
||||||
IMPORTANT: You have to decide to either build something that uses
|
IMPORTANT: You have to decide to either build something that uses
|
||||||
threads or something that doesn't; you can't have one build
|
threads or something that doesn't; you can't have one build
|
||||||
that works everywhere. This is an Emscripten (or maybe WebAssembly?
|
that works everywhere. This is an Emscripten (or maybe WebAssembly?
|
||||||
Or just web browsers in general?) limitation. If you aren't using
|
Or just web browsers in general?) limitation. If you aren't using
|
||||||
threads, it's easier to not enable them at all, at build time.
|
threads, it's easier to not enable them at all, at build time.
|
||||||
|
|
||||||
If you use threads, you _have to_ run from a web server that has
|
If you use threads, you _have to_ run from a web server that has
|
||||||
[COOP/COEP headers set correctly](https://web.dev/why-coop-coep/)
|
[COOP/COEP headers set correctly](https://web.dev/why-coop-coep/)
|
||||||
or your program will fail to start at all.
|
or your program will fail to start at all.
|
||||||
|
|
||||||
If building with threads, `__EMSCRIPTEN_PTHREADS__` will be defined
|
If building with threads, `__EMSCRIPTEN_PTHREADS__` will be defined
|
||||||
for checking with the C preprocessor, so you can build something
|
for checking with the C preprocessor, so you can build something
|
||||||
different depending on what sort of build you're compiling.
|
different depending on what sort of build you're compiling.
|
||||||
|
|
||||||
|
|
||||||
## Audio
|
## Audio
|
||||||
|
|
||||||
Audio works as expected at the API level, but not exactly like other
|
Audio works as expected at the API level, but not exactly like other
|
||||||
platforms.
|
platforms.
|
||||||
|
|
||||||
You'll only see a single default audio device. Audio capture also works;
|
You'll only see a single default audio device. Audio capture also works;
|
||||||
if the browser pops up a prompt to ask for permission to access the
|
if the browser pops up a prompt to ask for permission to access the
|
||||||
microphone, the SDL_OpenAudioDevice call will succeed and start producing
|
microphone, the SDL_OpenAudioDevice call will succeed and start producing
|
||||||
silence at a regular interval. Once the user approves the request, real
|
silence at a regular interval. Once the user approves the request, real
|
||||||
audio data will flow. If the user denies it, the app is not informed and
|
audio data will flow. If the user denies it, the app is not informed and
|
||||||
will just continue to receive silence.
|
will just continue to receive silence.
|
||||||
|
|
||||||
Modern web browsers will not permit web pages to produce sound before the
|
Modern web browsers will not permit web pages to produce sound before the
|
||||||
user has interacted with them (clicked or tapped on them, usually); this is
|
user has interacted with them (clicked or tapped on them, usually); this is
|
||||||
for several reasons, not the least of which being that no one likes when a
|
for several reasons, not the least of which being that no one likes when a
|
||||||
random browser tab suddenly starts making noise and the user has to scramble
|
random browser tab suddenly starts making noise and the user has to scramble
|
||||||
to figure out which and silence it.
|
to figure out which and silence it.
|
||||||
|
|
||||||
SDL will allow you to open the audio device for playback in this
|
SDL will allow you to open the audio device for playback in this
|
||||||
circumstance, and your audio callback will fire, but SDL will throw the audio
|
circumstance, and your audio callback will fire, but SDL will throw the audio
|
||||||
data away until the user interacts with the page. This helps apps that depend
|
data away until the user interacts with the page. This helps apps that depend
|
||||||
on the audio callback to make progress, and also keeps audio playback in sync
|
on the audio callback to make progress, and also keeps audio playback in sync
|
||||||
once the app is finally allowed to make noise.
|
once the app is finally allowed to make noise.
|
||||||
|
|
||||||
There are two reasonable ways to deal with the silence at the app level:
|
There are two reasonable ways to deal with the silence at the app level:
|
||||||
if you are writing some sort of media player thing, where the user expects
|
if you are writing some sort of media player thing, where the user expects
|
||||||
there to be a volume control when you mouseover the canvas, just default
|
there to be a volume control when you mouseover the canvas, just default
|
||||||
that control to a muted state; if the user clicks on the control to unmute
|
that control to a muted state; if the user clicks on the control to unmute
|
||||||
it, on this first click, open the audio device. This allows the media to
|
it, on this first click, open the audio device. This allows the media to
|
||||||
play at start, and the user can reasonably opt-in to listening.
|
play at start, and the user can reasonably opt-in to listening.
|
||||||
|
|
||||||
Many games do not have this sort of UI, and are more rigid about starting
|
Many games do not have this sort of UI, and are more rigid about starting
|
||||||
audio along with everything else at the start of the process. For these, your
|
audio along with everything else at the start of the process. For these, your
|
||||||
best bet is to write a little Javascript that puts up a "Click here to play!"
|
best bet is to write a little Javascript that puts up a "Click here to play!"
|
||||||
UI, and upon the user clicking, remove that UI and then call the Emscripten
|
UI, and upon the user clicking, remove that UI and then call the Emscripten
|
||||||
app's main() function. As far as the application knows, the audio device was
|
app's main() function. As far as the application knows, the audio device was
|
||||||
available to be opened as soon as the program started, and since this magic
|
available to be opened as soon as the program started, and since this magic
|
||||||
happens in a little Javascript, you don't have to change your C/C++ code at
|
happens in a little Javascript, you don't have to change your C/C++ code at
|
||||||
all to make it happen.
|
all to make it happen.
|
||||||
|
|
||||||
Please see the discussion at https://github.com/libsdl-org/SDL/issues/6385
|
Please see the discussion at https://github.com/libsdl-org/SDL/issues/6385
|
||||||
for some Javascript code to steal for this approach.
|
for some Javascript code to steal for this approach.
|
||||||
|
|
||||||
|
|
||||||
## Rendering
|
## Rendering
|
||||||
|
|
||||||
If you use SDL's 2D render API, it will use GLES2 internally, which
|
If you use SDL's 2D render API, it will use GLES2 internally, which
|
||||||
Emscripten will turn into WebGL calls. You can also use OpenGL ES 2
|
Emscripten will turn into WebGL calls. You can also use OpenGL ES 2
|
||||||
directly by creating a GL context and drawing into it.
|
directly by creating a GL context and drawing into it.
|
||||||
|
|
||||||
Calling SDL_RenderPresent (or SDL_GL_SwapWindow) will not actually
|
Calling SDL_RenderPresent (or SDL_GL_SwapWindow) will not actually
|
||||||
present anything on the screen until your return from your mainloop
|
present anything on the screen until your return from your mainloop
|
||||||
function.
|
function.
|
||||||
|
|
||||||
|
|
||||||
## Building SDL/emscripten
|
## Building SDL/emscripten
|
||||||
|
|
||||||
First: do you _really_ need to build SDL from source?
|
First: do you _really_ need to build SDL from source?
|
||||||
|
|
||||||
If you aren't developing SDL itself, have a desire to mess with its source
|
If you aren't developing SDL itself, have a desire to mess with its source
|
||||||
code, or need something on the bleeding edge, don't build SDL. Just use
|
code, or need something on the bleeding edge, don't build SDL. Just use
|
||||||
Emscripten's packaged version!
|
Emscripten's packaged version!
|
||||||
|
|
||||||
Compile and link your app with `-sUSE_SDL=2` and it'll use a build of
|
Compile and link your app with `-sUSE_SDL=2` and it'll use a build of
|
||||||
SDL packaged with Emscripten. This comes from the same source code and
|
SDL packaged with Emscripten. This comes from the same source code and
|
||||||
fixes the Emscripten project makes to SDL are generally merged into SDL's
|
fixes the Emscripten project makes to SDL are generally merged into SDL's
|
||||||
revision control, so often this is much easier for app developers.
|
revision control, so often this is much easier for app developers.
|
||||||
|
|
||||||
`-sUSE_SDL=1` will select Emscripten's JavaScript reimplementation of SDL
|
`-sUSE_SDL=1` will select Emscripten's JavaScript reimplementation of SDL
|
||||||
1.2 instead; if you need SDL 1.2, this might be fine, but we generally
|
1.2 instead; if you need SDL 1.2, this might be fine, but we generally
|
||||||
recommend you don't use SDL 1.2 in modern times.
|
recommend you don't use SDL 1.2 in modern times.
|
||||||
|
|
||||||
|
|
||||||
If you want to build SDL, though...
|
If you want to build SDL, though...
|
||||||
|
|
||||||
SDL currently requires at least Emscripten 3.1.35 to build. Newer versions
|
SDL currently requires at least Emscripten 3.1.35 to build. Newer versions
|
||||||
are likely to work, as well.
|
are likely to work, as well.
|
||||||
|
|
||||||
|
|
||||||
Build:
|
Build:
|
||||||
|
|
||||||
This works on Linux/Unix and macOS. Please send comments about Windows.
|
This works on Linux/Unix and macOS. Please send comments about Windows.
|
||||||
|
|
||||||
Make sure you've [installed emsdk](https://emscripten.org/docs/getting_started/downloads.html)
|
Make sure you've [installed emsdk](https://emscripten.org/docs/getting_started/downloads.html)
|
||||||
first, and run `source emsdk_env.sh` at the command line so it finds the
|
first, and run `source emsdk_env.sh` at the command line so it finds the
|
||||||
tools.
|
tools.
|
||||||
|
|
||||||
(These configure options might be overkill, but this has worked for me.)
|
(These configure options might be overkill, but this has worked for me.)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd SDL
|
cd SDL
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
emconfigure ../configure --host=wasm32-unknown-emscripten --disable-pthreads --disable-assembly --disable-cpuinfo CFLAGS="-sUSE_SDL=0 -O3"
|
emconfigure ../configure --host=wasm32-unknown-emscripten --disable-pthreads --disable-assembly --disable-cpuinfo CFLAGS="-sUSE_SDL=0 -O3"
|
||||||
emmake make -j4
|
emmake make -j4
|
||||||
```
|
```
|
||||||
|
|
||||||
If you want to build with thread support, something like this works:
|
If you want to build with thread support, something like this works:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
emconfigure ../configure --host=wasm32-unknown-emscripten --enable-pthreads --disable-assembly --disable-cpuinfo CFLAGS="-sUSE_SDL=0 -O3 -pthread" LDFLAGS="-pthread"
|
emconfigure ../configure --host=wasm32-unknown-emscripten --enable-pthreads --disable-assembly --disable-cpuinfo CFLAGS="-sUSE_SDL=0 -O3 -pthread" LDFLAGS="-pthread"
|
||||||
```
|
```
|
||||||
|
|
||||||
Or with cmake:
|
Or with cmake:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
emcmake cmake ..
|
emcmake cmake ..
|
||||||
emmake make -j4
|
emmake make -j4
|
||||||
```
|
```
|
||||||
|
|
||||||
To build one of the tests:
|
To build one of the tests:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd test/
|
cd test/
|
||||||
emcc -O2 --js-opts 0 -g4 testdraw2.c -I../include ../build/.libs/libSDL2.a ../build/libSDL2_test.a -o a.html
|
emcc -O2 --js-opts 0 -g4 testdraw2.c -I../include ../build/.libs/libSDL2.a ../build/libSDL2_test.a -o a.html
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building your app
|
## Building your app
|
||||||
|
|
||||||
You need to compile with `emcc` instead of `gcc` or `clang` or whatever, but
|
You need to compile with `emcc` instead of `gcc` or `clang` or whatever, but
|
||||||
mostly it uses the same command line arguments as Clang.
|
mostly it uses the same command line arguments as Clang.
|
||||||
|
|
||||||
Link against the SDL/build/.libs/libSDL2.a file you generated by building SDL,
|
Link against the SDL/build/.libs/libSDL2.a file you generated by building SDL,
|
||||||
link with `-sUSE_SDL=2` to use Emscripten's prepackaged SDL2 build.
|
link with `-sUSE_SDL=2` to use Emscripten's prepackaged SDL2 build.
|
||||||
|
|
||||||
Usually you would produce a binary like this:
|
Usually you would produce a binary like this:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gcc -o mygame mygame.c # or whatever
|
gcc -o mygame mygame.c # or whatever
|
||||||
```
|
```
|
||||||
|
|
||||||
But for Emscripten, you want to output something else:
|
But for Emscripten, you want to output something else:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
emcc -o index.html mygame.c
|
emcc -o index.html mygame.c
|
||||||
```
|
```
|
||||||
|
|
||||||
This will produce several files...support Javascript and WebAssembly (.wasm)
|
This will produce several files...support Javascript and WebAssembly (.wasm)
|
||||||
files. The `-o index.html` will produce a simple HTML page that loads and
|
files. The `-o index.html` will produce a simple HTML page that loads and
|
||||||
runs your app. You will (probably) eventually want to replace or customize
|
runs your app. You will (probably) eventually want to replace or customize
|
||||||
that file and do `-o index.js` instead to just build the code pieces.
|
that file and do `-o index.js` instead to just build the code pieces.
|
||||||
|
|
||||||
If you're working on a program of any serious size, you'll likely need to
|
If you're working on a program of any serious size, you'll likely need to
|
||||||
link with `-sALLOW_MEMORY_GROWTH=1 -sMAXIMUM_MEMORY=1gb` to get access
|
link with `-sALLOW_MEMORY_GROWTH=1 -sMAXIMUM_MEMORY=1gb` to get access
|
||||||
to more memory. If using pthreads, you'll need the `-sMAXIMUM_MEMORY=1gb`
|
to more memory. If using pthreads, you'll need the `-sMAXIMUM_MEMORY=1gb`
|
||||||
or the app will fail to start on iOS browsers, but this might be a bug that
|
or the app will fail to start on iOS browsers, but this might be a bug that
|
||||||
goes away in the future.
|
goes away in the future.
|
||||||
|
|
||||||
|
|
||||||
## Data files
|
## Data files
|
||||||
|
|
||||||
Your game probably has data files. Here's how to access them.
|
Your game probably has data files. Here's how to access them.
|
||||||
|
|
||||||
Filesystem access works like a Unix filesystem; you have a single directory
|
Filesystem access works like a Unix filesystem; you have a single directory
|
||||||
tree, possibly interpolated from several mounted locations, no drive letters,
|
tree, possibly interpolated from several mounted locations, no drive letters,
|
||||||
'/' for a path separator. You can access them with standard file APIs like
|
'/' for a path separator. You can access them with standard file APIs like
|
||||||
open() or fopen() or SDL_RWops. You can read or write from the filesystem.
|
open() or fopen() or SDL_RWops. You can read or write from the filesystem.
|
||||||
|
|
||||||
By default, you probably have a "MEMFS" filesystem (all files are stored in
|
By default, you probably have a "MEMFS" filesystem (all files are stored in
|
||||||
memory, but access to them is immediate and doesn't need to block). There are
|
memory, but access to them is immediate and doesn't need to block). There are
|
||||||
other options, like "IDBFS" (files are stored in a local database, so they
|
other options, like "IDBFS" (files are stored in a local database, so they
|
||||||
don't need to be in RAM all the time and they can persist between runs of the
|
don't need to be in RAM all the time and they can persist between runs of the
|
||||||
program, but access is not synchronous). You can mix and match these file
|
program, but access is not synchronous). You can mix and match these file
|
||||||
systems, mounting a MEMFS filesystem at one place and idbfs elsewhere, etc,
|
systems, mounting a MEMFS filesystem at one place and idbfs elsewhere, etc,
|
||||||
but that's beyond the scope of this document. Please refer to Emscripten's
|
but that's beyond the scope of this document. Please refer to Emscripten's
|
||||||
[page on the topic](https://emscripten.org/docs/porting/files/file_systems_overview.html)
|
[page on the topic](https://emscripten.org/docs/porting/files/file_systems_overview.html)
|
||||||
for more info.
|
for more info.
|
||||||
|
|
||||||
The _easiest_ (but not the best) way to get at your data files is to embed
|
The _easiest_ (but not the best) way to get at your data files is to embed
|
||||||
them in the app itself. Emscripten's linker has support for automating this.
|
them in the app itself. Emscripten's linker has support for automating this.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
emcc -o index.html loopwave.c --embed-file=../test/sample.wav@/sounds/sample.wav
|
emcc -o index.html loopwave.c --embed-file=../test/sample.wav@/sounds/sample.wav
|
||||||
```
|
```
|
||||||
|
|
||||||
This will pack ../test/sample.wav in your app, and make it available at
|
This will pack ../test/sample.wav in your app, and make it available at
|
||||||
"/sounds/sample.wav" at runtime. Emscripten makes sure this data is available
|
"/sounds/sample.wav" at runtime. Emscripten makes sure this data is available
|
||||||
before your main() function runs, and since it's in MEMFS, you can just
|
before your main() function runs, and since it's in MEMFS, you can just
|
||||||
read it like you do on other platforms. `--embed-file` can also accept a
|
read it like you do on other platforms. `--embed-file` can also accept a
|
||||||
directory to pack an entire tree, and you can specify the argument multiple
|
directory to pack an entire tree, and you can specify the argument multiple
|
||||||
times to pack unrelated things into the final installation.
|
times to pack unrelated things into the final installation.
|
||||||
|
|
||||||
Note that this is absolutely the best approach if you have a few small
|
Note that this is absolutely the best approach if you have a few small
|
||||||
files to include and shouldn't worry about the issue further. However, if you
|
files to include and shouldn't worry about the issue further. However, if you
|
||||||
have hundreds of megabytes and/or thousands of files, this is not so great,
|
have hundreds of megabytes and/or thousands of files, this is not so great,
|
||||||
since the user will download it all every time they load your page, and it
|
since the user will download it all every time they load your page, and it
|
||||||
all has to live in memory at runtime.
|
all has to live in memory at runtime.
|
||||||
|
|
||||||
[Emscripten's documentation on the matter](https://emscripten.org/docs/porting/files/packaging_files.html)
|
[Emscripten's documentation on the matter](https://emscripten.org/docs/porting/files/packaging_files.html)
|
||||||
gives other options and details, and is worth a read.
|
gives other options and details, and is worth a read.
|
||||||
|
|
||||||
|
|
||||||
## Debugging
|
## Debugging
|
||||||
|
|
||||||
Debugging web apps is a mixed bag. You should compile and link with
|
Debugging web apps is a mixed bag. You should compile and link with
|
||||||
`-gsource-map`, which embeds a ton of source-level debugging information into
|
`-gsource-map`, which embeds a ton of source-level debugging information into
|
||||||
the build, and make sure _the app source code is available on the web server_,
|
the build, and make sure _the app source code is available on the web server_,
|
||||||
which is often a scary proposition for various reasons.
|
which is often a scary proposition for various reasons.
|
||||||
|
|
||||||
When you debug from the browser's tools and hit a breakpoint, you can step
|
When you debug from the browser's tools and hit a breakpoint, you can step
|
||||||
through the actual C/C++ source code, though, which can be nice.
|
through the actual C/C++ source code, though, which can be nice.
|
||||||
|
|
||||||
If you try debugging in Firefox and it doesn't work well for no apparent
|
If you try debugging in Firefox and it doesn't work well for no apparent
|
||||||
reason, try Chrome, and vice-versa. These tools are still relatively new,
|
reason, try Chrome, and vice-versa. These tools are still relatively new,
|
||||||
and improving all the time.
|
and improving all the time.
|
||||||
|
|
||||||
SDL_Log() (or even plain old printf) will write to the Javascript console,
|
SDL_Log() (or even plain old printf) will write to the Javascript console,
|
||||||
and honestly I find printf-style debugging to be easier than setting up a build
|
and honestly I find printf-style debugging to be easier than setting up a build
|
||||||
for proper debugging, so use whatever tools work best for you.
|
for proper debugging, so use whatever tools work best for you.
|
||||||
|
|
||||||
|
|
||||||
## Questions?
|
## Questions?
|
||||||
|
|
||||||
Please give us feedback on this document at [the SDL bug tracker](https://github.com/libsdl-org/SDL/issues).
|
Please give us feedback on this document at [the SDL bug tracker](https://github.com/libsdl-org/SDL/issues).
|
||||||
If something is wrong or unclear, we want to know!
|
If something is wrong or unclear, we want to know!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,176 +1,176 @@
|
|||||||
GDK
|
GDK
|
||||||
=====
|
=====
|
||||||
|
|
||||||
This port allows SDL applications to run via Microsoft's Game Development Kit (GDK).
|
This port allows SDL applications to run via Microsoft's Game Development Kit (GDK).
|
||||||
|
|
||||||
Windows (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.
|
Windows (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.
|
||||||
|
|
||||||
|
|
||||||
Requirements
|
Requirements
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* Microsoft Visual Studio 2022 (in theory, it should also work in 2017 or 2019, but this has not been tested)
|
* Microsoft Visual Studio 2022 (in theory, it should also work in 2017 or 2019, but this has not been tested)
|
||||||
* Microsoft GDK June 2022 or newer (public release [here](https://github.com/microsoft/GDK/releases/tag/June_2022))
|
* Microsoft GDK June 2022 or newer (public release [here](https://github.com/microsoft/GDK/releases/tag/June_2022))
|
||||||
* For Xbox, you will need the corresponding GDKX version (licensed developers only)
|
* For Xbox, you will need the corresponding GDKX version (licensed developers only)
|
||||||
* 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.
|
* 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.
|
||||||
|
|
||||||
|
|
||||||
Windows GDK Status
|
Windows GDK Status
|
||||||
------
|
------
|
||||||
|
|
||||||
The Windows GDK port supports the full set of Win32 APIs, renderers, controllers, input devices, etc., as the normal Windows x64 build of SDL.
|
The Windows GDK port supports the full set of Win32 APIs, renderers, controllers, input devices, etc., as the normal Windows x64 build of SDL.
|
||||||
|
|
||||||
* Additionally, the GDK port adds the following:
|
* Additionally, the GDK port adds the following:
|
||||||
* 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.)
|
* 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.)
|
||||||
* GDK-specific setup:
|
* GDK-specific setup:
|
||||||
* Initializing/uninitializing the game runtime, and initializing Xbox Live services
|
* 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.
|
* 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 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.
|
* 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.
|
||||||
* Global task queue callbacks are dispatched during `SDL_PumpEvents` (which is also called internally if using `SDL_PollEvent`).
|
* 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).
|
* 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).
|
||||||
|
|
||||||
* Single-player games have some additional features available:
|
* Single-player games have some additional features available:
|
||||||
* Call `SDL_GDKGetDefaultUser` to get the default XUserHandle pointer.
|
* Call `SDL_GDKGetDefaultUser` to get the default XUserHandle pointer.
|
||||||
* `SDL_GetPrefPath` still works, but only for single-player titles.
|
* `SDL_GetPrefPath` still works, but only for single-player titles.
|
||||||
|
|
||||||
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!
|
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!
|
||||||
|
|
||||||
* What doesn't work:
|
* What doesn't work:
|
||||||
* Compilation with anything other than through the included Visual C++ solution file
|
* Compilation with anything other than through the included Visual C++ solution file
|
||||||
|
|
||||||
## VisualC-GDK Solution
|
## VisualC-GDK Solution
|
||||||
|
|
||||||
The included `VisualC-GDK/SDL.sln` solution includes the following targets for the Gaming.Desktop.x64 configuration:
|
The included `VisualC-GDK/SDL.sln` solution includes the following targets for the Gaming.Desktop.x64 configuration:
|
||||||
|
|
||||||
* SDL2 (DLL) - This is the typical SDL2.dll, but for Gaming.Desktop.x64.
|
* SDL2 (DLL) - This is the typical SDL2.dll, but for Gaming.Desktop.x64.
|
||||||
* SDL2main (lib) - This contains a drop-in implementation of `WinMain` that is used as the entry point for GDK programs.
|
* SDL2main (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/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.
|
* 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.
|
*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.
|
||||||
* tests/testsprite2 - Standard SDL test program demonstrating sprite drawing functionality.
|
* tests/testsprite2 - Standard SDL test program demonstrating sprite drawing functionality.
|
||||||
|
|
||||||
If you set one of the test programs as a startup project, you can run it directly from Visual Studio.
|
If you set one of the test programs as a startup project, you can run it directly from Visual Studio.
|
||||||
|
|
||||||
Windows GDK Setup, Detailed Steps
|
Windows GDK Setup, Detailed Steps
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
These 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.
|
These 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.
|
||||||
|
|
||||||
### 1. Add a Gaming.Desktop.x64 Configuration ###
|
### 1. Add a Gaming.Desktop.x64 Configuration ###
|
||||||
|
|
||||||
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.
|
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 SDL2 and SDL2main for GDK ###
|
### 2. Build SDL2 and SDL2main for GDK ###
|
||||||
|
|
||||||
Open `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.
|
Open `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.
|
||||||
|
|
||||||
*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.
|
*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.
|
||||||
|
|
||||||
### 3. Configuring Project Settings ###
|
### 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:
|
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 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 SDL2.lib and SDL2main.lib are
|
* Under Linker > General > Additional Library Directories, make sure to reference the path where the newly-built SDL2.lib and SDL2main.lib are
|
||||||
* Under Linker > Input > Additional Dependencies, you need the following:
|
* Under Linker > Input > Additional Dependencies, you need the following:
|
||||||
* `SDL2.lib`
|
* `SDL2.lib`
|
||||||
* `SDL2main.lib` (unless not using)
|
* `SDL2main.lib` (unless not using)
|
||||||
* `xgameruntime.lib`
|
* `xgameruntime.lib`
|
||||||
* `../Microsoft.Xbox.Services.141.GDK.C.Thunks.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.
|
* 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.
|
||||||
|
|
||||||
### 4. Setting up SDL_main ###
|
### 4. Setting up SDL_main ###
|
||||||
|
|
||||||
Rather 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.
|
Rather 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.
|
||||||
|
|
||||||
### 5. Required DLLs ###
|
### 5. Required DLLs ###
|
||||||
|
|
||||||
The 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:
|
The 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:
|
||||||
|
|
||||||
* Your SDL2.dll
|
* Your SDL2.dll
|
||||||
* "$(Console_GRDKExtLibRoot)Xbox.Services.API.C\DesignTime\CommonConfiguration\Neutral\Lib\Release\Microsoft.Xbox.Services.141.GDK.C.Thunks.dll"
|
* "$(Console_GRDKExtLibRoot)Xbox.Services.API.C\DesignTime\CommonConfiguration\Neutral\Lib\Release\Microsoft.Xbox.Services.141.GDK.C.Thunks.dll"
|
||||||
* XCurl.dll
|
* XCurl.dll
|
||||||
|
|
||||||
You 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.
|
You 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.
|
||||||
|
|
||||||
### 6. Setting up MicrosoftGame.config ###
|
### 6. Setting up MicrosoftGame.config ###
|
||||||
|
|
||||||
You 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.
|
You 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.
|
||||||
|
|
||||||
This 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.
|
This 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.
|
||||||
|
|
||||||
For 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.
|
For 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.
|
||||||
|
|
||||||
Then, you need to set the following values to the values from Partner Center:
|
Then, you need to set the following values to the values from Partner Center:
|
||||||
|
|
||||||
* Identity tag - Name and Publisher attributes
|
* Identity tag - Name and Publisher attributes
|
||||||
* TitleId
|
* TitleId
|
||||||
* MSAAppId
|
* MSAAppId
|
||||||
|
|
||||||
### 7. Adding Required Logos
|
### 7. Adding Required Logos
|
||||||
|
|
||||||
Several 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.
|
Several 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.
|
||||||
|
|
||||||
|
|
||||||
### 8. Copying any Data Files ###
|
### 8. Copying any Data Files ###
|
||||||
|
|
||||||
When 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.
|
When 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.
|
||||||
|
|
||||||
|
|
||||||
### 9. Build and Run from Visual Studio ###
|
### 9. Build and Run from Visual Studio ###
|
||||||
|
|
||||||
At 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.
|
At 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.
|
||||||
|
|
||||||
If you are testing Xbox Live functionality, it's likely you will need to change to the Sandbox for your title. To do this:
|
If you are testing Xbox Live functionality, it's likely you will need to change to the Sandbox for your title. To do this:
|
||||||
|
|
||||||
1. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu
|
1. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu
|
||||||
2. Switch the sandbox name with:
|
2. Switch the sandbox name with:
|
||||||
`XblPCSandbox SANDBOX.#`
|
`XblPCSandbox SANDBOX.#`
|
||||||
3. (To switch back to the retail sandbox):
|
3. (To switch back to the retail sandbox):
|
||||||
`XblPCSandbox RETAIL`
|
`XblPCSandbox RETAIL`
|
||||||
|
|
||||||
### 10. Packaging and Installing Locally
|
### 10. Packaging and Installing Locally
|
||||||
|
|
||||||
You 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.
|
You 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.
|
||||||
|
|
||||||
To create the package:
|
To create the package:
|
||||||
|
|
||||||
1. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu
|
1. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu
|
||||||
2. `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)
|
2. `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)
|
||||||
3. `mkdir Package` to create an output directory
|
3. `mkdir Package` to create an output directory
|
||||||
4. To package the file into the `Package` directory, use:
|
4. To package the file into the `Package` directory, use:
|
||||||
`makepkg pack /f PackageLayout.xml /lt /d . /nogameos /pc /pd Package`
|
`makepkg pack /f PackageLayout.xml /lt /d . /nogameos /pc /pd Package`
|
||||||
5. To install the package, use:
|
5. To install the package, use:
|
||||||
`wdapp install PACKAGENAME.msixvc`
|
`wdapp install PACKAGENAME.msixvc`
|
||||||
6. Once the package is installed, you can run it from the start menu.
|
6. Once the package is installed, you can run it from the start menu.
|
||||||
7. As with when running from Visual Studio, if you need to test any Xbox Live functionality you must switch to the correct sandbox.
|
7. As with when running from Visual Studio, if you need to test any Xbox Live functionality you must switch to the correct sandbox.
|
||||||
|
|
||||||
Xbox GDKX Setup
|
Xbox GDKX Setup
|
||||||
---------------------
|
---------------------
|
||||||
In general, the same process in the Windows GDK instructions work. There are just a few additional notes:
|
In general, the same process in the Windows GDK instructions work. There are just a few additional notes:
|
||||||
* For Xbox One consoles, use the Gaming.Xbox.XboxOne.x64 target
|
* For Xbox One consoles, use the Gaming.Xbox.XboxOne.x64 target
|
||||||
* For Xbox Series consoles, use the Gaming.Xbox.Scarlett.x64 target
|
* For Xbox Series consoles, use the Gaming.Xbox.Scarlett.x64 target
|
||||||
* The Xbox One target sets the `__XBOXONE__` define and the Xbox Series target sets the `__XBOXSERIES__` define
|
* The Xbox One target sets the `__XBOXONE__` define and the Xbox Series target sets the `__XBOXSERIES__` define
|
||||||
* 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)
|
* 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)
|
||||||
* 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)
|
* 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)
|
||||||
* To create a package, use:
|
* To create a package, use:
|
||||||
`makepkg pack /f PackageLayout.xml /lt /d . /pd Package`
|
`makepkg pack /f PackageLayout.xml /lt /d . /pd Package`
|
||||||
* To install the package, use:
|
* To install the package, use:
|
||||||
`xbapp install [PACKAGE].xvc`
|
`xbapp install [PACKAGE].xvc`
|
||||||
* 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
|
* 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
|
||||||
* While there are successful releases of Xbox titles using this port, it is not as extensively tested as other targets
|
* While there are successful releases of Xbox titles using this port, it is not as extensively tested as other targets
|
||||||
|
|
||||||
Troubleshooting
|
Troubleshooting
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
#### Xbox Live Login does not work
|
#### Xbox Live Login does not work
|
||||||
|
|
||||||
As 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.
|
As 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.
|
||||||
|
|
||||||
Furthermore, confirm that your PC is set to the correct sandbox.
|
Furthermore, confirm that your PC is set to the correct sandbox.
|
||||||
|
|
||||||
|
|
||||||
#### "The current user has already installed an unpackaged version of this app. A packaged version cannot replace this." error when installing
|
#### "The current user has already installed an unpackaged version of this app. A packaged version cannot replace this." error when installing
|
||||||
|
|
||||||
Prior 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).
|
Prior 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).
|
||||||
|
@@ -1,71 +1,71 @@
|
|||||||
Dollar Gestures
|
Dollar Gestures
|
||||||
===========================================================================
|
===========================================================================
|
||||||
SDL provides an implementation of the $1 gesture recognition system. This allows for recording, saving, loading, and performing single stroke gestures.
|
SDL provides an implementation of the $1 gesture recognition system. This allows for recording, saving, loading, and performing single stroke gestures.
|
||||||
|
|
||||||
Gestures can be performed with any number of fingers (the centroid of the fingers must follow the path of the gesture), but the number of fingers must be constant (a finger cannot go down in the middle of a gesture). The path of a gesture is considered the path from the time when the final finger went down, to the first time any finger comes up.
|
Gestures can be performed with any number of fingers (the centroid of the fingers must follow the path of the gesture), but the number of fingers must be constant (a finger cannot go down in the middle of a gesture). The path of a gesture is considered the path from the time when the final finger went down, to the first time any finger comes up.
|
||||||
|
|
||||||
Dollar gestures are assigned an Id based on a hash function. This is guaranteed to remain constant for a given gesture. There is a (small) chance that two different gestures will be assigned the same ID. In this case, simply re-recording one of the gestures should result in a different ID.
|
Dollar gestures are assigned an Id based on a hash function. This is guaranteed to remain constant for a given gesture. There is a (small) chance that two different gestures will be assigned the same ID. In this case, simply re-recording one of the gestures should result in a different ID.
|
||||||
|
|
||||||
Recording:
|
Recording:
|
||||||
----------
|
----------
|
||||||
To begin recording on a touch device call:
|
To begin recording on a touch device call:
|
||||||
SDL_RecordGesture(SDL_TouchID touchId), where touchId is the id of the touch device you wish to record on, or -1 to record on all connected devices.
|
SDL_RecordGesture(SDL_TouchID touchId), where touchId is the id of the touch device you wish to record on, or -1 to record on all connected devices.
|
||||||
|
|
||||||
Recording terminates as soon as a finger comes up. Recording is acknowledged by an SDL_DOLLARRECORD event.
|
Recording terminates as soon as a finger comes up. Recording is acknowledged by an SDL_DOLLARRECORD event.
|
||||||
A SDL_DOLLARRECORD event is a dgesture with the following fields:
|
A SDL_DOLLARRECORD event is a dgesture with the following fields:
|
||||||
|
|
||||||
* event.dgesture.touchId - the Id of the touch used to record the gesture.
|
* event.dgesture.touchId - the Id of the touch used to record the gesture.
|
||||||
* event.dgesture.gestureId - the unique id of the recorded gesture.
|
* event.dgesture.gestureId - the unique id of the recorded gesture.
|
||||||
|
|
||||||
|
|
||||||
Performing:
|
Performing:
|
||||||
-----------
|
-----------
|
||||||
As long as there is a dollar gesture assigned to a touch, every finger-up event will also cause an SDL_DOLLARGESTURE event with the following fields:
|
As long as there is a dollar gesture assigned to a touch, every finger-up event will also cause an SDL_DOLLARGESTURE event with the following fields:
|
||||||
|
|
||||||
* event.dgesture.touchId - the Id of the touch which performed the gesture.
|
* event.dgesture.touchId - the Id of the touch which performed the gesture.
|
||||||
* event.dgesture.gestureId - the unique id of the closest gesture to the performed stroke.
|
* event.dgesture.gestureId - the unique id of the closest gesture to the performed stroke.
|
||||||
* event.dgesture.error - the difference between the gesture template and the actual performed gesture. Lower error is a better match.
|
* event.dgesture.error - the difference between the gesture template and the actual performed gesture. Lower error is a better match.
|
||||||
* event.dgesture.numFingers - the number of fingers used to draw the stroke.
|
* event.dgesture.numFingers - the number of fingers used to draw the stroke.
|
||||||
|
|
||||||
Most programs will want to define an appropriate error threshold and check to be sure that the error of a gesture is not abnormally high (an indicator that no gesture was performed).
|
Most programs will want to define an appropriate error threshold and check to be sure that the error of a gesture is not abnormally high (an indicator that no gesture was performed).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Saving:
|
Saving:
|
||||||
-------
|
-------
|
||||||
To save a template, call SDL_SaveDollarTemplate(gestureId, dst) where gestureId is the id of the gesture you want to save, and dst is an SDL_RWops pointer to the file where the gesture will be stored.
|
To save a template, call SDL_SaveDollarTemplate(gestureId, dst) where gestureId is the id of the gesture you want to save, and dst is an SDL_RWops pointer to the file where the gesture will be stored.
|
||||||
|
|
||||||
To save all currently loaded templates, call SDL_SaveAllDollarTemplates(dst) where dst is an SDL_RWops pointer to the file where the gesture will be stored.
|
To save all currently loaded templates, call SDL_SaveAllDollarTemplates(dst) where dst is an SDL_RWops pointer to the file where the gesture will be stored.
|
||||||
|
|
||||||
Both functions return the number of gestures successfully saved.
|
Both functions return the number of gestures successfully saved.
|
||||||
|
|
||||||
|
|
||||||
Loading:
|
Loading:
|
||||||
--------
|
--------
|
||||||
To load templates from a file, call SDL_LoadDollarTemplates(touchId,src) where touchId is the id of the touch to load to (or -1 to load to all touch devices), and src is an SDL_RWops pointer to a gesture save file.
|
To load templates from a file, call SDL_LoadDollarTemplates(touchId,src) where touchId is the id of the touch to load to (or -1 to load to all touch devices), and src is an SDL_RWops pointer to a gesture save file.
|
||||||
|
|
||||||
SDL_LoadDollarTemplates returns the number of templates successfully loaded.
|
SDL_LoadDollarTemplates returns the number of templates successfully loaded.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Multi Gestures
|
Multi Gestures
|
||||||
===========================================================================
|
===========================================================================
|
||||||
SDL provides simple support for pinch/rotate/swipe gestures.
|
SDL provides simple support for pinch/rotate/swipe gestures.
|
||||||
Every time a finger is moved an SDL_MULTIGESTURE event is sent with the following fields:
|
Every time a finger is moved an SDL_MULTIGESTURE event is sent with the following fields:
|
||||||
|
|
||||||
* event.mgesture.touchId - the Id of the touch on which the gesture was performed.
|
* event.mgesture.touchId - the Id of the touch on which the gesture was performed.
|
||||||
* event.mgesture.x - the normalized x coordinate of the gesture. (0..1)
|
* event.mgesture.x - the normalized x coordinate of the gesture. (0..1)
|
||||||
* event.mgesture.y - the normalized y coordinate of the gesture. (0..1)
|
* event.mgesture.y - the normalized y coordinate of the gesture. (0..1)
|
||||||
* event.mgesture.dTheta - the amount that the fingers rotated during this motion.
|
* event.mgesture.dTheta - the amount that the fingers rotated during this motion.
|
||||||
* event.mgesture.dDist - the amount that the fingers pinched during this motion.
|
* event.mgesture.dDist - the amount that the fingers pinched during this motion.
|
||||||
* event.mgesture.numFingers - the number of fingers used in the gesture.
|
* event.mgesture.numFingers - the number of fingers used in the gesture.
|
||||||
|
|
||||||
|
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Notes
|
Notes
|
||||||
===========================================================================
|
===========================================================================
|
||||||
For a complete example see test/testgesture.c
|
For a complete example see test/testgesture.c
|
||||||
|
|
||||||
Please direct questions/comments to:
|
Please direct questions/comments to:
|
||||||
jim.tla+sdl_touch@gmail.com
|
jim.tla+sdl_touch@gmail.com
|
||||||
|
@@ -1,19 +1,19 @@
|
|||||||
git
|
git
|
||||||
=========
|
=========
|
||||||
|
|
||||||
The latest development version of SDL is available via git.
|
The latest development version of SDL is available via git.
|
||||||
Git allows you to get up-to-the-minute fixes and enhancements;
|
Git allows you to get up-to-the-minute fixes and enhancements;
|
||||||
as a developer works on a source tree, you can use "git" to mirror that
|
as a developer works on a source tree, you can use "git" to mirror that
|
||||||
source tree instead of waiting for an official release. Please look
|
source tree instead of waiting for an official release. Please look
|
||||||
at the Git website ( https://git-scm.com/ ) for more
|
at the Git website ( https://git-scm.com/ ) for more
|
||||||
information on using git, where you can also download software for
|
information on using git, where you can also download software for
|
||||||
macOS, Windows, and Unix systems.
|
macOS, Windows, and Unix systems.
|
||||||
|
|
||||||
git clone https://github.com/libsdl-org/SDL
|
git clone https://github.com/libsdl-org/SDL
|
||||||
|
|
||||||
If you are building SDL via configure, you will need to run autogen.sh
|
If you are building SDL via configure, you will need to run autogen.sh
|
||||||
before running configure.
|
before running configure.
|
||||||
|
|
||||||
There is a web interface to the Git repository at:
|
There is a web interface to the Git repository at:
|
||||||
http://github.com/libsdl-org/SDL/
|
http://github.com/libsdl-org/SDL/
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
We are no longer hosted in Mercurial. Please see README-git.md for details.
|
We are no longer hosted in Mercurial. Please see README-git.md for details.
|
||||||
|
|
||||||
Thanks!
|
Thanks!
|
||||||
|
|
||||||
|
@@ -1,307 +1,307 @@
|
|||||||
iOS
|
iOS
|
||||||
======
|
======
|
||||||
|
|
||||||
Building the Simple DirectMedia Layer for iOS 9.0+
|
Building the Simple DirectMedia Layer for iOS 9.0+
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
Requirements: Mac OS X 10.9 or later and the iOS 9.0 or newer SDK.
|
Requirements: Mac OS X 10.9 or later and the iOS 9.0 or newer SDK.
|
||||||
|
|
||||||
Instructions:
|
Instructions:
|
||||||
|
|
||||||
1. Open SDL.xcodeproj (located in Xcode/SDL) in Xcode.
|
1. Open SDL.xcodeproj (located in Xcode/SDL) in Xcode.
|
||||||
2. Select your desired target, and hit build.
|
2. Select your desired target, and hit build.
|
||||||
|
|
||||||
|
|
||||||
Using the Simple DirectMedia Layer for iOS
|
Using the Simple DirectMedia Layer for iOS
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
1. Run Xcode and create a new project using the iOS Game template, selecting the Objective C language and Metal game technology.
|
1. Run Xcode and create a new project using the iOS Game template, selecting the Objective C language and Metal game technology.
|
||||||
2. In the main view, delete all files except for Assets and LaunchScreen
|
2. In the main view, delete all files except for Assets and LaunchScreen
|
||||||
3. Right click the project in the main view, select "Add Files...", and add the SDL project, Xcode/SDL/SDL.xcodeproj
|
3. Right click the project in the main view, select "Add Files...", and add the SDL project, Xcode/SDL/SDL.xcodeproj
|
||||||
4. Select the project in the main view, go to the "Info" tab and under "Custom iOS Target Properties" remove the line "Main storyboard file base name"
|
4. Select the project in the main view, go to the "Info" tab and under "Custom iOS Target Properties" remove the line "Main storyboard file base name"
|
||||||
5. Select the project in the main view, go to the "Build Settings" tab, select "All", and edit "Header Search Path" and drag over the SDL "Public Headers" folder from the left
|
5. Select the project in the main view, go to the "Build Settings" tab, select "All", and edit "Header Search Path" and drag over the SDL "Public Headers" folder from the left
|
||||||
6. Select the project in the main view, go to the "Build Phases" tab, select "Link Binary With Libraries", and add SDL2.framework from "Framework-iOS"
|
6. Select the project in the main view, go to the "Build Phases" tab, select "Link Binary With Libraries", and add SDL2.framework from "Framework-iOS"
|
||||||
7. Select the project in the main view, go to the "General" tab, scroll down to "Frameworks, Libraries, and Embedded Content", and select "Embed & Sign" for the SDL library.
|
7. Select the project in the main view, go to the "General" tab, scroll down to "Frameworks, Libraries, and Embedded Content", and select "Embed & Sign" for the SDL library.
|
||||||
8. In the main view, expand SDL -> Library Source -> main -> uikit and drag SDL_uikit_main.c into your game files
|
8. In the main view, expand SDL -> Library Source -> main -> uikit and drag SDL_uikit_main.c into your game files
|
||||||
9. Add the source files that you would normally have for an SDL program, making sure to have #include "SDL.h" at the top of the file containing your main() function.
|
9. Add the source files that you would normally have for an SDL program, making sure to have #include "SDL.h" at the top of the file containing your main() function.
|
||||||
10. Add any assets that your application needs.
|
10. Add any assets that your application needs.
|
||||||
11. Enjoy!
|
11. Enjoy!
|
||||||
|
|
||||||
|
|
||||||
TODO: Add information regarding App Store requirements such as icons, etc.
|
TODO: Add information regarding App Store requirements such as icons, etc.
|
||||||
|
|
||||||
|
|
||||||
Notes -- Retina / High-DPI and window sizes
|
Notes -- Retina / High-DPI and window sizes
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
Window and display mode sizes in SDL are in "screen coordinates" (or "points",
|
Window and display mode sizes in SDL are in "screen coordinates" (or "points",
|
||||||
in Apple's terminology) rather than in pixels. On iOS this means that a window
|
in Apple's terminology) rather than in pixels. On iOS this means that a window
|
||||||
created on an iPhone 6 will have a size in screen coordinates of 375 x 667,
|
created on an iPhone 6 will have a size in screen coordinates of 375 x 667,
|
||||||
rather than a size in pixels of 750 x 1334. All iOS apps are expected to
|
rather than a size in pixels of 750 x 1334. All iOS apps are expected to
|
||||||
size their content based on screen coordinates / points rather than pixels,
|
size their content based on screen coordinates / points rather than pixels,
|
||||||
as this allows different iOS devices to have different pixel densities
|
as this allows different iOS devices to have different pixel densities
|
||||||
(Retina versus non-Retina screens, etc.) without apps caring too much.
|
(Retina versus non-Retina screens, etc.) without apps caring too much.
|
||||||
|
|
||||||
By default SDL will not use the full pixel density of the screen on
|
By default SDL will not use the full pixel density of the screen on
|
||||||
Retina/high-dpi capable devices. Use the SDL_WINDOW_ALLOW_HIGHDPI flag when
|
Retina/high-dpi capable devices. Use the SDL_WINDOW_ALLOW_HIGHDPI flag when
|
||||||
creating your window to enable high-dpi support.
|
creating your window to enable high-dpi support.
|
||||||
|
|
||||||
When high-dpi support is enabled, SDL_GetWindowSize() and display mode sizes
|
When high-dpi support is enabled, SDL_GetWindowSize() and display mode sizes
|
||||||
will still be in "screen coordinates" rather than pixels, but the window will
|
will still be in "screen coordinates" rather than pixels, but the window will
|
||||||
have a much greater pixel density when the device supports it, and the
|
have a much greater pixel density when the device supports it, and the
|
||||||
SDL_GL_GetDrawableSize() or SDL_GetRendererOutputSize() functions (depending on
|
SDL_GL_GetDrawableSize() or SDL_GetRendererOutputSize() functions (depending on
|
||||||
whether raw OpenGL or the SDL_Render API is used) can be queried to determine
|
whether raw OpenGL or the SDL_Render API is used) can be queried to determine
|
||||||
the size in pixels of the drawable screen framebuffer.
|
the size in pixels of the drawable screen framebuffer.
|
||||||
|
|
||||||
Some OpenGL ES functions such as glViewport expect sizes in pixels rather than
|
Some OpenGL ES functions such as glViewport expect sizes in pixels rather than
|
||||||
sizes in screen coordinates. When doing 2D rendering with OpenGL ES, an
|
sizes in screen coordinates. When doing 2D rendering with OpenGL ES, an
|
||||||
orthographic projection matrix using the size in screen coordinates
|
orthographic projection matrix using the size in screen coordinates
|
||||||
(SDL_GetWindowSize()) can be used in order to display content at the same scale
|
(SDL_GetWindowSize()) can be used in order to display content at the same scale
|
||||||
no matter whether a Retina device is used or not.
|
no matter whether a Retina device is used or not.
|
||||||
|
|
||||||
|
|
||||||
Notes -- Application events
|
Notes -- Application events
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
On iOS the application goes through a fixed life cycle and you will get
|
On iOS the application goes through a fixed life cycle and you will get
|
||||||
notifications of state changes via application events. When these events
|
notifications of state changes via application events. When these events
|
||||||
are delivered you must handle them in an event callback because the OS may
|
are delivered you must handle them in an event callback because the OS may
|
||||||
not give you any processing time after the events are delivered.
|
not give you any processing time after the events are delivered.
|
||||||
|
|
||||||
e.g.
|
e.g.
|
||||||
|
|
||||||
int HandleAppEvents(void *userdata, SDL_Event *event)
|
int HandleAppEvents(void *userdata, SDL_Event *event)
|
||||||
{
|
{
|
||||||
switch (event->type)
|
switch (event->type)
|
||||||
{
|
{
|
||||||
case SDL_APP_TERMINATING:
|
case SDL_APP_TERMINATING:
|
||||||
/* Terminate the app.
|
/* Terminate the app.
|
||||||
Shut everything down before returning from this function.
|
Shut everything down before returning from this function.
|
||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
case SDL_APP_LOWMEMORY:
|
case SDL_APP_LOWMEMORY:
|
||||||
/* You will get this when your app is paused and iOS wants more memory.
|
/* You will get this when your app is paused and iOS wants more memory.
|
||||||
Release as much memory as possible.
|
Release as much memory as possible.
|
||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
case SDL_APP_WILLENTERBACKGROUND:
|
case SDL_APP_WILLENTERBACKGROUND:
|
||||||
/* Prepare your app to go into the background. Stop loops, etc.
|
/* Prepare your app to go into the background. Stop loops, etc.
|
||||||
This gets called when the user hits the home button, or gets a call.
|
This gets called when the user hits the home button, or gets a call.
|
||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
case SDL_APP_DIDENTERBACKGROUND:
|
case SDL_APP_DIDENTERBACKGROUND:
|
||||||
/* This will get called if the user accepted whatever sent your app to the background.
|
/* This will get called if the user accepted whatever sent your app to the background.
|
||||||
If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops.
|
If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops.
|
||||||
When you get this, you have 5 seconds to save all your state or the app will be terminated.
|
When you get this, you have 5 seconds to save all your state or the app will be terminated.
|
||||||
Your app is NOT active at this point.
|
Your app is NOT active at this point.
|
||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
case SDL_APP_WILLENTERFOREGROUND:
|
case SDL_APP_WILLENTERFOREGROUND:
|
||||||
/* This call happens when your app is coming back to the foreground.
|
/* This call happens when your app is coming back to the foreground.
|
||||||
Restore all your state here.
|
Restore all your state here.
|
||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
case SDL_APP_DIDENTERFOREGROUND:
|
case SDL_APP_DIDENTERFOREGROUND:
|
||||||
/* Restart your loops here.
|
/* Restart your loops here.
|
||||||
Your app is interactive and getting CPU again.
|
Your app is interactive and getting CPU again.
|
||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
/* No special processing, add it to the event queue */
|
/* No special processing, add it to the event queue */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
SDL_SetEventFilter(HandleAppEvents, NULL);
|
SDL_SetEventFilter(HandleAppEvents, NULL);
|
||||||
|
|
||||||
... run your main loop
|
... run your main loop
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Notes -- Accelerometer as Joystick
|
Notes -- Accelerometer as Joystick
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
SDL for iPhone supports polling the built in accelerometer as a joystick device. For an example on how to do this, see the accelerometer.c in the demos directory.
|
SDL for iPhone supports polling the built in accelerometer as a joystick device. For an example on how to do this, see the accelerometer.c in the demos directory.
|
||||||
|
|
||||||
The main thing to note when using the accelerometer with SDL is that while the iPhone natively reports accelerometer as floating point values in units of g-force, SDL_JoystickGetAxis() reports joystick values as signed integers. Hence, in order to convert between the two, some clamping and scaling is necessary on the part of the iPhone SDL joystick driver. To convert SDL_JoystickGetAxis() reported values BACK to units of g-force, simply multiply the values by SDL_IPHONE_MAX_GFORCE / 0x7FFF.
|
The main thing to note when using the accelerometer with SDL is that while the iPhone natively reports accelerometer as floating point values in units of g-force, SDL_JoystickGetAxis() reports joystick values as signed integers. Hence, in order to convert between the two, some clamping and scaling is necessary on the part of the iPhone SDL joystick driver. To convert SDL_JoystickGetAxis() reported values BACK to units of g-force, simply multiply the values by SDL_IPHONE_MAX_GFORCE / 0x7FFF.
|
||||||
|
|
||||||
|
|
||||||
Notes -- OpenGL ES
|
Notes -- OpenGL ES
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
Your SDL application for iOS uses OpenGL ES for video by default.
|
Your SDL application for iOS uses OpenGL ES for video by default.
|
||||||
|
|
||||||
OpenGL ES for iOS supports several display pixel formats, such as RGBA8 and RGB565, which provide a 32 bit and 16 bit color buffer respectively. By default, the implementation uses RGB565, but you may use RGBA8 by setting each color component to 8 bits in SDL_GL_SetAttribute().
|
OpenGL ES for iOS supports several display pixel formats, such as RGBA8 and RGB565, which provide a 32 bit and 16 bit color buffer respectively. By default, the implementation uses RGB565, but you may use RGBA8 by setting each color component to 8 bits in SDL_GL_SetAttribute().
|
||||||
|
|
||||||
If your application doesn't use OpenGL's depth buffer, you may find significant performance improvement by setting SDL_GL_DEPTH_SIZE to 0.
|
If your application doesn't use OpenGL's depth buffer, you may find significant performance improvement by setting SDL_GL_DEPTH_SIZE to 0.
|
||||||
|
|
||||||
Finally, if your application completely redraws the screen each frame, you may find significant performance improvement by setting the attribute SDL_GL_RETAINED_BACKING to 0.
|
Finally, if your application completely redraws the screen each frame, you may find significant performance improvement by setting the attribute SDL_GL_RETAINED_BACKING to 0.
|
||||||
|
|
||||||
OpenGL ES on iOS doesn't use the traditional system-framebuffer setup provided in other operating systems. Special care must be taken because of this:
|
OpenGL ES on iOS doesn't use the traditional system-framebuffer setup provided in other operating systems. Special care must be taken because of this:
|
||||||
|
|
||||||
- The drawable Renderbuffer must be bound to the GL_RENDERBUFFER binding point when SDL_GL_SwapWindow() is called.
|
- The drawable Renderbuffer must be bound to the GL_RENDERBUFFER binding point when SDL_GL_SwapWindow() is called.
|
||||||
- The drawable Framebuffer Object must be bound while rendering to the screen and when SDL_GL_SwapWindow() is called.
|
- The drawable Framebuffer Object must be bound while rendering to the screen and when SDL_GL_SwapWindow() is called.
|
||||||
- If multisample antialiasing (MSAA) is used and glReadPixels is used on the screen, the drawable framebuffer must be resolved to the MSAA resolve framebuffer (via glBlitFramebuffer or glResolveMultisampleFramebufferAPPLE), and the MSAA resolve framebuffer must be bound to the GL_READ_FRAMEBUFFER binding point, before glReadPixels is called.
|
- If multisample antialiasing (MSAA) is used and glReadPixels is used on the screen, the drawable framebuffer must be resolved to the MSAA resolve framebuffer (via glBlitFramebuffer or glResolveMultisampleFramebufferAPPLE), and the MSAA resolve framebuffer must be bound to the GL_READ_FRAMEBUFFER binding point, before glReadPixels is called.
|
||||||
|
|
||||||
The above objects can be obtained via SDL_GetWindowWMInfo() (in SDL_syswm.h).
|
The above objects can be obtained via SDL_GetWindowWMInfo() (in SDL_syswm.h).
|
||||||
|
|
||||||
|
|
||||||
Notes -- Keyboard
|
Notes -- Keyboard
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
The SDL keyboard API has been extended to support on-screen keyboards:
|
The SDL keyboard API has been extended to support on-screen keyboards:
|
||||||
|
|
||||||
void SDL_StartTextInput()
|
void SDL_StartTextInput()
|
||||||
-- enables text events and reveals the onscreen keyboard.
|
-- enables text events and reveals the onscreen keyboard.
|
||||||
|
|
||||||
void SDL_StopTextInput()
|
void SDL_StopTextInput()
|
||||||
-- disables text events and hides the onscreen keyboard.
|
-- disables text events and hides the onscreen keyboard.
|
||||||
|
|
||||||
SDL_bool SDL_IsTextInputActive()
|
SDL_bool SDL_IsTextInputActive()
|
||||||
-- returns whether or not text events are enabled (and the onscreen keyboard is visible)
|
-- returns whether or not text events are enabled (and the onscreen keyboard is visible)
|
||||||
|
|
||||||
|
|
||||||
Notes -- Mouse
|
Notes -- Mouse
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
iOS now supports Bluetooth mice on iPad, but by default will provide the mouse input as touch. In order for SDL to see the real mouse events, you should set the key UIApplicationSupportsIndirectInputEvents to true in your Info.plist
|
iOS now supports Bluetooth mice on iPad, but by default will provide the mouse input as touch. In order for SDL to see the real mouse events, you should set the key UIApplicationSupportsIndirectInputEvents to true in your Info.plist
|
||||||
|
|
||||||
|
|
||||||
Notes -- Reading and Writing files
|
Notes -- Reading and Writing files
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
Each application installed on iPhone resides in a sandbox which includes its own Application Home directory. Your application may not access files outside this directory.
|
Each application installed on iPhone resides in a sandbox which includes its own Application Home directory. Your application may not access files outside this directory.
|
||||||
|
|
||||||
Once your application is installed its directory tree looks like:
|
Once your application is installed its directory tree looks like:
|
||||||
|
|
||||||
MySDLApp Home/
|
MySDLApp Home/
|
||||||
MySDLApp.app
|
MySDLApp.app
|
||||||
Documents/
|
Documents/
|
||||||
Library/
|
Library/
|
||||||
Preferences/
|
Preferences/
|
||||||
tmp/
|
tmp/
|
||||||
|
|
||||||
When your SDL based iPhone application starts up, it sets the working directory to the main bundle (MySDLApp Home/MySDLApp.app), where your application resources are stored. You cannot write to this directory. Instead, I advise you to write document files to "../Documents/" and preferences to "../Library/Preferences".
|
When your SDL based iPhone application starts up, it sets the working directory to the main bundle (MySDLApp Home/MySDLApp.app), where your application resources are stored. You cannot write to this directory. Instead, I advise you to write document files to "../Documents/" and preferences to "../Library/Preferences".
|
||||||
|
|
||||||
More information on this subject is available here:
|
More information on this subject is available here:
|
||||||
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html
|
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html
|
||||||
|
|
||||||
|
|
||||||
Notes -- xcFramework
|
Notes -- xcFramework
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
The SDL.xcodeproj file now includes a target to build SDL2.xcframework. An xcframework is a new (Xcode 11) uber-framework which can handle any combination of processor type and target OS platform.
|
The SDL.xcodeproj file now includes a target to build SDL2.xcframework. An xcframework is a new (Xcode 11) uber-framework which can handle any combination of processor type and target OS platform.
|
||||||
|
|
||||||
In the past, iOS devices were always an ARM variant processor, and the simulator was always i386 or x86_64, and thus libraries could be combined into a single framework for both simulator and device. With the introduction of the Apple Silicon ARM-based machines, regular frameworks would collide as CPU type was no longer sufficient to differentiate the platform. So Apple created the new xcframework library package.
|
In the past, iOS devices were always an ARM variant processor, and the simulator was always i386 or x86_64, and thus libraries could be combined into a single framework for both simulator and device. With the introduction of the Apple Silicon ARM-based machines, regular frameworks would collide as CPU type was no longer sufficient to differentiate the platform. So Apple created the new xcframework library package.
|
||||||
|
|
||||||
The xcframework target builds into a Products directory alongside the SDL.xcodeproj file, as SDL2.xcframework. This can be brought in to any iOS project and will function properly for both simulator and device, no matter their CPUs. Note that Intel Macs cannot cross-compile for Apple Silicon Macs. If you need AS compatibility, perform this build on an Apple Silicon Mac.
|
The xcframework target builds into a Products directory alongside the SDL.xcodeproj file, as SDL2.xcframework. This can be brought in to any iOS project and will function properly for both simulator and device, no matter their CPUs. Note that Intel Macs cannot cross-compile for Apple Silicon Macs. If you need AS compatibility, perform this build on an Apple Silicon Mac.
|
||||||
|
|
||||||
This target requires Xcode 11 or later. The target will simply fail to build if attempted on older Xcodes.
|
This target requires Xcode 11 or later. The target will simply fail to build if attempted on older Xcodes.
|
||||||
|
|
||||||
In addition, on Apple platforms, main() cannot be in a dynamically loaded library. This means that iOS apps which used the statically-linked libSDL2.lib and now link with the xcframwork will need to define their own main() to call SDL_UIKitRunApp(), like this:
|
In addition, on Apple platforms, main() cannot be in a dynamically loaded library. This means that iOS apps which used the statically-linked libSDL2.lib and now link with the xcframwork will need to define their own main() to call SDL_UIKitRunApp(), like this:
|
||||||
|
|
||||||
#ifndef SDL_MAIN_HANDLED
|
#ifndef SDL_MAIN_HANDLED
|
||||||
#ifdef main
|
#ifdef main
|
||||||
#undef main
|
#undef main
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
return SDL_UIKitRunApp(argc, argv, SDL_main);
|
return SDL_UIKitRunApp(argc, argv, SDL_main);
|
||||||
}
|
}
|
||||||
#endif /* !SDL_MAIN_HANDLED */
|
#endif /* !SDL_MAIN_HANDLED */
|
||||||
|
|
||||||
Using an xcFramework is similar to using a regular framework. However, issues have been seen with the build system not seeing the headers in the xcFramework. To remedy this, add the path to the xcFramework in your app's target ==> Build Settings ==> Framework Search Paths and mark it recursive (this is critical). Also critical is to remove "*.framework" from Build Settings ==> Sub-Directories to Exclude in Recursive Searches. Clean the build folder, and on your next build the build system should be able to see any of these in your code, as expected:
|
Using an xcFramework is similar to using a regular framework. However, issues have been seen with the build system not seeing the headers in the xcFramework. To remedy this, add the path to the xcFramework in your app's target ==> Build Settings ==> Framework Search Paths and mark it recursive (this is critical). Also critical is to remove "*.framework" from Build Settings ==> Sub-Directories to Exclude in Recursive Searches. Clean the build folder, and on your next build the build system should be able to see any of these in your code, as expected:
|
||||||
|
|
||||||
#include "SDL_main.h"
|
#include "SDL_main.h"
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_main.h>
|
#include <SDL_main.h>
|
||||||
|
|
||||||
|
|
||||||
Notes -- iPhone SDL limitations
|
Notes -- iPhone SDL limitations
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
Windows:
|
Windows:
|
||||||
Full-size, single window applications only. You cannot create multi-window SDL applications for iPhone OS. The application window will fill the display, though you have the option of turning on or off the menu-bar (pass SDL_CreateWindow() the flag SDL_WINDOW_BORDERLESS).
|
Full-size, single window applications only. You cannot create multi-window SDL applications for iPhone OS. The application window will fill the display, though you have the option of turning on or off the menu-bar (pass SDL_CreateWindow() the flag SDL_WINDOW_BORDERLESS).
|
||||||
|
|
||||||
Textures:
|
Textures:
|
||||||
The optimal texture formats on iOS are SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, and SDL_PIXELFORMAT_RGB24 pixel formats.
|
The optimal texture formats on iOS are SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, and SDL_PIXELFORMAT_RGB24 pixel formats.
|
||||||
|
|
||||||
Loading Shared Objects:
|
Loading Shared Objects:
|
||||||
This is disabled by default since it seems to break the terms of the iOS SDK agreement for iOS versions prior to iOS 8. It can be re-enabled in SDL_config_iphoneos.h.
|
This is disabled by default since it seems to break the terms of the iOS SDK agreement for iOS versions prior to iOS 8. It can be re-enabled in SDL_config_iphoneos.h.
|
||||||
|
|
||||||
|
|
||||||
Notes -- CoreBluetooth.framework
|
Notes -- CoreBluetooth.framework
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
SDL_JOYSTICK_HIDAPI is disabled by default. It can give you access to a lot
|
SDL_JOYSTICK_HIDAPI is disabled by default. It can give you access to a lot
|
||||||
more game controller devices, but it requires permission from the user before
|
more game controller devices, but it requires permission from the user before
|
||||||
your app will be able to talk to the Bluetooth hardware. "Made For iOS"
|
your app will be able to talk to the Bluetooth hardware. "Made For iOS"
|
||||||
branded controllers do not need this as we don't have to speak to them
|
branded controllers do not need this as we don't have to speak to them
|
||||||
directly with raw bluetooth, so many apps can live without this.
|
directly with raw bluetooth, so many apps can live without this.
|
||||||
|
|
||||||
You'll need to link with CoreBluetooth.framework and add something like this
|
You'll need to link with CoreBluetooth.framework and add something like this
|
||||||
to your Info.plist:
|
to your Info.plist:
|
||||||
|
|
||||||
<key>NSBluetoothPeripheralUsageDescription</key>
|
<key>NSBluetoothPeripheralUsageDescription</key>
|
||||||
<string>MyApp would like to remain connected to nearby bluetooth Game Controllers and Game Pads even when you're not using the app.</string>
|
<string>MyApp would like to remain connected to nearby bluetooth Game Controllers and Game Pads even when you're not using the app.</string>
|
||||||
|
|
||||||
|
|
||||||
Game Center
|
Game Center
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
Game Center integration might require that you break up your main loop in order to yield control back to the system. In other words, instead of running an endless main loop, you run each frame in a callback function, using:
|
Game Center integration might require that you break up your main loop in order to yield control back to the system. In other words, instead of running an endless main loop, you run each frame in a callback function, using:
|
||||||
|
|
||||||
int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
|
int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
|
||||||
|
|
||||||
This will set up the given function to be called back on the animation callback, and then you have to return from main() to let the Cocoa event loop run.
|
This will set up the given function to be called back on the animation callback, and then you have to return from main() to let the Cocoa event loop run.
|
||||||
|
|
||||||
e.g.
|
e.g.
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
void ShowFrame(void*)
|
void ShowFrame(void*)
|
||||||
{
|
{
|
||||||
... do event handling, frame logic and rendering ...
|
... do event handling, frame logic and rendering ...
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
... initialize game ...
|
... initialize game ...
|
||||||
|
|
||||||
#ifdef __IPHONEOS__
|
#ifdef __IPHONEOS__
|
||||||
// Initialize the Game Center for scoring and matchmaking
|
// Initialize the Game Center for scoring and matchmaking
|
||||||
InitGameCenter();
|
InitGameCenter();
|
||||||
|
|
||||||
// Set up the game to run in the window animation callback on iOS
|
// Set up the game to run in the window animation callback on iOS
|
||||||
// so that Game Center and so forth works correctly.
|
// so that Game Center and so forth works correctly.
|
||||||
SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL);
|
SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL);
|
||||||
#else
|
#else
|
||||||
while ( running ) {
|
while ( running ) {
|
||||||
ShowFrame(0);
|
ShowFrame(0);
|
||||||
DelayFrame();
|
DelayFrame();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Deploying to older versions of iOS
|
Deploying to older versions of iOS
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
SDL supports deploying to older versions of iOS than are supported by the latest version of Xcode, all the way back to iOS 8.0
|
SDL supports deploying to older versions of iOS than are supported by the latest version of Xcode, all the way back to iOS 8.0
|
||||||
|
|
||||||
In order to do that you need to download an older version of Xcode:
|
In order to do that you need to download an older version of Xcode:
|
||||||
https://developer.apple.com/download/more/?name=Xcode
|
https://developer.apple.com/download/more/?name=Xcode
|
||||||
|
|
||||||
Open the package contents of the older Xcode and your newer version of Xcode and copy over the folders in Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
|
Open the package contents of the older Xcode and your newer version of Xcode and copy over the folders in Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
|
||||||
|
|
||||||
Then open the file Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/SDKSettings.plist and add the versions of iOS you want to deploy to the key Root/DefaultProperties/DEPLOYMENT_TARGET_SUGGESTED_VALUES
|
Then open the file Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/SDKSettings.plist and add the versions of iOS you want to deploy to the key Root/DefaultProperties/DEPLOYMENT_TARGET_SUGGESTED_VALUES
|
||||||
|
|
||||||
Open your project and set your deployment target to the desired version of iOS
|
Open your project and set your deployment target to the desired version of iOS
|
||||||
|
|
||||||
Finally, remove GameController from the list of frameworks linked by your application and edit the build settings for "Other Linker Flags" and add -weak_framework GameController
|
Finally, remove GameController from the list of frameworks linked by your application and edit the build settings for "Other Linker Flags" and add -weak_framework GameController
|
||||||
|
@@ -1,27 +1,27 @@
|
|||||||
KMSDRM on *BSD
|
KMSDRM on *BSD
|
||||||
==================================================
|
==================================================
|
||||||
|
|
||||||
KMSDRM is supported on FreeBSD and OpenBSD. DragonFlyBSD works but requires being a root user. NetBSD isn't supported yet because the application will crash when creating the KMSDRM screen.
|
KMSDRM is supported on FreeBSD and OpenBSD. DragonFlyBSD works but requires being a root user. NetBSD isn't supported yet because the application will crash when creating the KMSDRM screen.
|
||||||
|
|
||||||
WSCONS support has been brought back, but only as an input backend. It will not be brought back as a video backend to ease maintenance.
|
WSCONS support has been brought back, but only as an input backend. It will not be brought back as a video backend to ease maintenance.
|
||||||
|
|
||||||
OpenBSD note: Note that the video backend assumes that the user has read/write permissions to the /dev/drm* devices.
|
OpenBSD note: Note that the video backend assumes that the user has read/write permissions to the /dev/drm* devices.
|
||||||
|
|
||||||
|
|
||||||
SDL2 WSCONS input backend features
|
SDL2 WSCONS input backend features
|
||||||
===================================================
|
===================================================
|
||||||
1. It is keymap-aware; it will work properly with different keymaps.
|
1. It is keymap-aware; it will work properly with different keymaps.
|
||||||
2. It has mouse support.
|
2. It has mouse support.
|
||||||
3. Accent input is supported.
|
3. Accent input is supported.
|
||||||
4. Compose keys are supported.
|
4. Compose keys are supported.
|
||||||
5. AltGr and Meta Shift keys work as intended.
|
5. AltGr and Meta Shift keys work as intended.
|
||||||
|
|
||||||
Partially working or no input on OpenBSD/NetBSD.
|
Partially working or no input on OpenBSD/NetBSD.
|
||||||
==================================================
|
==================================================
|
||||||
|
|
||||||
The WSCONS input backend needs read/write access to the /dev/wskbd* devices, without which it will not work properly. /dev/wsmouse must also be read/write accessible, otherwise mouse input will not work.
|
The WSCONS input backend needs read/write access to the /dev/wskbd* devices, without which it will not work properly. /dev/wsmouse must also be read/write accessible, otherwise mouse input will not work.
|
||||||
|
|
||||||
Partially working or no input on FreeBSD.
|
Partially working or no input on FreeBSD.
|
||||||
==================================================
|
==================================================
|
||||||
|
|
||||||
The evdev devices are only accessible to the root user by default. Edit devfs rules to allow access to such devices. The /dev/kbd* devices are also only accessible to the root user by default. Edit devfs rules to allow access to such devices.
|
The evdev devices are only accessible to the root user by default. Edit devfs rules to allow access to such devices. The /dev/kbd* devices are also only accessible to the root user by default. Edit devfs rules to allow access to such devices.
|
||||||
|
@@ -1,96 +1,96 @@
|
|||||||
Linux
|
Linux
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
By default SDL will only link against glibc, the rest of the features will be
|
By default SDL will only link against glibc, the rest of the features will be
|
||||||
enabled dynamically at runtime depending on the available features on the target
|
enabled dynamically at runtime depending on the available features on the target
|
||||||
system. So, for example if you built SDL with XRandR support and the target
|
system. So, for example if you built SDL with XRandR support and the target
|
||||||
system does not have the XRandR libraries installed, it will be disabled
|
system does not have the XRandR libraries installed, it will be disabled
|
||||||
at runtime, and you won't get a missing library error, at least with the
|
at runtime, and you won't get a missing library error, at least with the
|
||||||
default configuration parameters.
|
default configuration parameters.
|
||||||
|
|
||||||
|
|
||||||
Build Dependencies
|
Build Dependencies
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
Ubuntu 18.04, all available features enabled:
|
Ubuntu 18.04, all available features enabled:
|
||||||
|
|
||||||
sudo apt-get install build-essential git make autoconf automake libtool \
|
sudo apt-get install build-essential git make autoconf automake libtool \
|
||||||
pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
|
pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
|
||||||
libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
|
libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
|
||||||
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
|
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
|
||||||
libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
|
libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
|
||||||
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
|
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
|
||||||
|
|
||||||
Ubuntu 22.04+ can also add `libpipewire-0.3-dev libdecor-0-dev` to that command line.
|
Ubuntu 22.04+ can also add `libpipewire-0.3-dev libdecor-0-dev` to that command line.
|
||||||
|
|
||||||
Fedora 35, all available features enabled:
|
Fedora 35, all available features enabled:
|
||||||
|
|
||||||
sudo yum install gcc git-core make cmake autoconf automake libtool \
|
sudo yum install gcc git-core make cmake autoconf automake libtool \
|
||||||
alsa-lib-devel pulseaudio-libs-devel nas-devel pipewire-devel \
|
alsa-lib-devel pulseaudio-libs-devel nas-devel pipewire-devel \
|
||||||
libX11-devel libXext-devel libXrandr-devel libXcursor-devel libXfixes-devel \
|
libX11-devel libXext-devel libXrandr-devel libXcursor-devel libXfixes-devel \
|
||||||
libXi-devel libXScrnSaver-devel dbus-devel ibus-devel fcitx-devel \
|
libXi-devel libXScrnSaver-devel dbus-devel ibus-devel fcitx-devel \
|
||||||
systemd-devel mesa-libGL-devel libxkbcommon-devel mesa-libGLES-devel \
|
systemd-devel mesa-libGL-devel libxkbcommon-devel mesa-libGLES-devel \
|
||||||
mesa-libEGL-devel vulkan-devel wayland-devel wayland-protocols-devel \
|
mesa-libEGL-devel vulkan-devel wayland-devel wayland-protocols-devel \
|
||||||
libdrm-devel mesa-libgbm-devel libusb-devel libdecor-devel \
|
libdrm-devel mesa-libgbm-devel libusb-devel libdecor-devel \
|
||||||
libsamplerate-devel pipewire-jack-audio-connection-kit-devel \
|
libsamplerate-devel pipewire-jack-audio-connection-kit-devel \
|
||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
- This includes all the audio targets except arts and esd, because Ubuntu
|
- This includes all the audio targets except arts and esd, because Ubuntu
|
||||||
(and/or Debian) pulled their packages, but in theory SDL still supports them.
|
(and/or Debian) pulled their packages, but in theory SDL still supports them.
|
||||||
The sndio audio target is also unavailable on Fedora.
|
The sndio audio target is also unavailable on Fedora.
|
||||||
- libsamplerate0-dev lets SDL optionally link to libresamplerate at runtime
|
- libsamplerate0-dev lets SDL optionally link to libresamplerate at runtime
|
||||||
for higher-quality audio resampling. SDL will work without it if the library
|
for higher-quality audio resampling. SDL will work without it if the library
|
||||||
is missing, so it's safe to build in support even if the end user doesn't
|
is missing, so it's safe to build in support even if the end user doesn't
|
||||||
have this library installed.
|
have this library installed.
|
||||||
- DirectFB isn't included because the configure script (currently) fails to find
|
- DirectFB isn't included because the configure script (currently) fails to find
|
||||||
it at all. You can do "sudo apt-get install libdirectfb-dev" and fix the
|
it at all. You can do "sudo apt-get install libdirectfb-dev" and fix the
|
||||||
configure script to include DirectFB support. Send patches. :)
|
configure script to include DirectFB support. Send patches. :)
|
||||||
|
|
||||||
|
|
||||||
Joystick does not work
|
Joystick does not work
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
If you compiled or are using a version of SDL with udev support (and you should!)
|
If you compiled or are using a version of SDL with udev support (and you should!)
|
||||||
there's a few issues that may cause SDL to fail to detect your joystick. To
|
there's a few issues that may cause SDL to fail to detect your joystick. To
|
||||||
debug this, start by installing the evtest utility. On Ubuntu/Debian:
|
debug this, start by installing the evtest utility. On Ubuntu/Debian:
|
||||||
|
|
||||||
sudo apt-get install evtest
|
sudo apt-get install evtest
|
||||||
|
|
||||||
Then run:
|
Then run:
|
||||||
|
|
||||||
sudo evtest
|
sudo evtest
|
||||||
|
|
||||||
You'll hopefully see your joystick listed along with a name like "/dev/input/eventXX"
|
You'll hopefully see your joystick listed along with a name like "/dev/input/eventXX"
|
||||||
Now run:
|
Now run:
|
||||||
|
|
||||||
cat /dev/input/event/XX
|
cat /dev/input/event/XX
|
||||||
|
|
||||||
If you get a permission error, you need to set a udev rule to change the mode of
|
If you get a permission error, you need to set a udev rule to change the mode of
|
||||||
your device (see below)
|
your device (see below)
|
||||||
|
|
||||||
Also, try:
|
Also, try:
|
||||||
|
|
||||||
sudo udevadm info --query=all --name=input/eventXX
|
sudo udevadm info --query=all --name=input/eventXX
|
||||||
|
|
||||||
If you see a line stating ID_INPUT_JOYSTICK=1, great, if you don't see it,
|
If you see a line stating ID_INPUT_JOYSTICK=1, great, if you don't see it,
|
||||||
you need to set up an udev rule to force this variable.
|
you need to set up an udev rule to force this variable.
|
||||||
|
|
||||||
A combined rule for the Saitek Pro Flight Rudder Pedals to fix both issues looks
|
A combined rule for the Saitek Pro Flight Rudder Pedals to fix both issues looks
|
||||||
like:
|
like:
|
||||||
|
|
||||||
SUBSYSTEM=="input", ATTRS{idProduct}=="0763", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"
|
SUBSYSTEM=="input", ATTRS{idProduct}=="0763", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"
|
||||||
SUBSYSTEM=="input", ATTRS{idProduct}=="0764", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"
|
SUBSYSTEM=="input", ATTRS{idProduct}=="0764", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"
|
||||||
|
|
||||||
You can set up similar rules for your device by changing the values listed in
|
You can set up similar rules for your device by changing the values listed in
|
||||||
idProduct and idVendor. To obtain these values, try:
|
idProduct and idVendor. To obtain these values, try:
|
||||||
|
|
||||||
sudo udevadm info -a --name=input/eventXX | grep idVendor
|
sudo udevadm info -a --name=input/eventXX | grep idVendor
|
||||||
sudo udevadm info -a --name=input/eventXX | grep idProduct
|
sudo udevadm info -a --name=input/eventXX | grep idProduct
|
||||||
|
|
||||||
If multiple values come up for each of these, the one you want is the first one of each.
|
If multiple values come up for each of these, the one you want is the first one of each.
|
||||||
|
|
||||||
On other systems which ship with an older udev (such as CentOS), you may need
|
On other systems which ship with an older udev (such as CentOS), you may need
|
||||||
to set up a rule such as:
|
to set up a rule such as:
|
||||||
|
|
||||||
SUBSYSTEM=="input", ENV{ID_CLASS}=="joystick", ENV{ID_INPUT_JOYSTICK}="1"
|
SUBSYSTEM=="input", ENV{ID_CLASS}=="joystick", ENV{ID_INPUT_JOYSTICK}="1"
|
||||||
|
|
||||||
|
@@ -1,285 +1,285 @@
|
|||||||
# Mac OS X (aka macOS).
|
# Mac OS X (aka macOS).
|
||||||
|
|
||||||
These instructions are for people using Apple's Mac OS X (pronounced
|
These instructions are for people using Apple's Mac OS X (pronounced
|
||||||
"ten"), which in newer versions is just referred to as "macOS".
|
"ten"), which in newer versions is just referred to as "macOS".
|
||||||
|
|
||||||
From the developer's point of view, macOS is a sort of hybrid Mac and
|
From the developer's point of view, macOS is a sort of hybrid Mac and
|
||||||
Unix system, and you have the option of using either traditional
|
Unix system, and you have the option of using either traditional
|
||||||
command line tools or Apple's IDE Xcode.
|
command line tools or Apple's IDE Xcode.
|
||||||
|
|
||||||
# Command Line Build
|
# Command Line Build
|
||||||
|
|
||||||
To build SDL using the command line, use the standard configure and make
|
To build SDL using the command line, use the standard configure and make
|
||||||
process:
|
process:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
../configure
|
../configure
|
||||||
make
|
make
|
||||||
sudo make install
|
sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
CMake is also known to work, although it continues to be a work in progress:
|
CMake is also known to work, although it continues to be a work in progress:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||||
make
|
make
|
||||||
sudo make install
|
sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
You can also build SDL as a Universal library (a single binary for both
|
You can also build SDL as a Universal library (a single binary for both
|
||||||
64-bit Intel and ARM architectures), by using the build-scripts/clang-fat.sh
|
64-bit Intel and ARM architectures), by using the build-scripts/clang-fat.sh
|
||||||
script.
|
script.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
CC=$PWD/../build-scripts/clang-fat.sh ../configure
|
CC=$PWD/../build-scripts/clang-fat.sh ../configure
|
||||||
make
|
make
|
||||||
sudo make install
|
sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
This script builds SDL with 10.9 ABI compatibility on 64-bit Intel and 11.0
|
This script builds SDL with 10.9 ABI compatibility on 64-bit Intel and 11.0
|
||||||
ABI compatibility on ARM64 architectures. For best compatibility you
|
ABI compatibility on ARM64 architectures. For best compatibility you
|
||||||
should compile your application the same way.
|
should compile your application the same way.
|
||||||
|
|
||||||
Please note that building SDL requires at least Xcode 6 and the 10.9 SDK.
|
Please note that building SDL requires at least Xcode 6 and the 10.9 SDK.
|
||||||
PowerPC support for macOS has been officially dropped as of SDL 2.0.2.
|
PowerPC support for macOS has been officially dropped as of SDL 2.0.2.
|
||||||
32-bit Intel and macOS 10.8 runtime support has been officially dropped as
|
32-bit Intel and macOS 10.8 runtime support has been officially dropped as
|
||||||
of SDL 2.24.0.
|
of SDL 2.24.0.
|
||||||
|
|
||||||
To use the library once it's built, you essential have two possibilities:
|
To use the library once it's built, you essential have two possibilities:
|
||||||
use the traditional autoconf/automake/make method, or use Xcode.
|
use the traditional autoconf/automake/make method, or use Xcode.
|
||||||
|
|
||||||
|
|
||||||
# Caveats for using SDL with Mac OS X
|
# Caveats for using SDL with Mac OS X
|
||||||
|
|
||||||
If you register your own NSApplicationDelegate (using [NSApp setDelegate:]),
|
If you register your own NSApplicationDelegate (using [NSApp setDelegate:]),
|
||||||
SDL will not register its own. This means that SDL will not terminate using
|
SDL will not register its own. This means that SDL will not terminate using
|
||||||
SDL_Quit if it receives a termination request, it will terminate like a
|
SDL_Quit if it receives a termination request, it will terminate like a
|
||||||
normal app, and it will not send a SDL_DROPFILE when you request to open a
|
normal app, and it will not send a SDL_DROPFILE when you request to open a
|
||||||
file with the app. To solve these issues, put the following code in your
|
file with the app. To solve these issues, put the following code in your
|
||||||
NSApplicationDelegate implementation:
|
NSApplicationDelegate implementation:
|
||||||
|
|
||||||
|
|
||||||
```objc
|
```objc
|
||||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
||||||
{
|
{
|
||||||
if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
|
if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.type = SDL_QUIT;
|
event.type = SDL_QUIT;
|
||||||
SDL_PushEvent(&event);
|
SDL_PushEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NSTerminateCancel;
|
return NSTerminateCancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||||
{
|
{
|
||||||
if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
|
if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.type = SDL_DROPFILE;
|
event.type = SDL_DROPFILE;
|
||||||
event.drop.file = SDL_strdup([filename UTF8String]);
|
event.drop.file = SDL_strdup([filename UTF8String]);
|
||||||
return (SDL_PushEvent(&event) > 0);
|
return (SDL_PushEvent(&event) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
# Using the Simple DirectMedia Layer with a traditional Makefile
|
# Using the Simple DirectMedia Layer with a traditional Makefile
|
||||||
|
|
||||||
An existing autoconf/automake build system for your SDL app has good chances
|
An existing autoconf/automake build system for your SDL app has good chances
|
||||||
to work almost unchanged on macOS. However, to produce a "real" Mac binary
|
to work almost unchanged on macOS. However, to produce a "real" Mac binary
|
||||||
that you can distribute to users, you need to put the generated binary into a
|
that you can distribute to users, you need to put the generated binary into a
|
||||||
so called "bundle", which is basically a fancy folder with a name like
|
so called "bundle", which is basically a fancy folder with a name like
|
||||||
"MyCoolGame.app".
|
"MyCoolGame.app".
|
||||||
|
|
||||||
To get this build automatically, add something like the following rule to
|
To get this build automatically, add something like the following rule to
|
||||||
your Makefile.am:
|
your Makefile.am:
|
||||||
|
|
||||||
```make
|
```make
|
||||||
bundle_contents = APP_NAME.app/Contents
|
bundle_contents = APP_NAME.app/Contents
|
||||||
APP_NAME_bundle: EXE_NAME
|
APP_NAME_bundle: EXE_NAME
|
||||||
mkdir -p $(bundle_contents)/MacOS
|
mkdir -p $(bundle_contents)/MacOS
|
||||||
mkdir -p $(bundle_contents)/Resources
|
mkdir -p $(bundle_contents)/Resources
|
||||||
echo "APPL????" > $(bundle_contents)/PkgInfo
|
echo "APPL????" > $(bundle_contents)/PkgInfo
|
||||||
$(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/
|
$(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/
|
||||||
```
|
```
|
||||||
|
|
||||||
You should replace `EXE_NAME` with the name of the executable. `APP_NAME` is
|
You should replace `EXE_NAME` with the name of the executable. `APP_NAME` is
|
||||||
what will be visible to the user in the Finder. Usually it will be the same
|
what will be visible to the user in the Finder. Usually it will be the same
|
||||||
as `EXE_NAME` but capitalized. E.g. if `EXE_NAME` is "testgame" then `APP_NAME`
|
as `EXE_NAME` but capitalized. E.g. if `EXE_NAME` is "testgame" then `APP_NAME`
|
||||||
usually is "TestGame". You might also want to use `@PACKAGE@` to use the
|
usually is "TestGame". You might also want to use `@PACKAGE@` to use the
|
||||||
package name as specified in your configure.ac file.
|
package name as specified in your configure.ac file.
|
||||||
|
|
||||||
If your project builds more than one application, you will have to do a bit
|
If your project builds more than one application, you will have to do a bit
|
||||||
more. For each of your target applications, you need a separate rule.
|
more. For each of your target applications, you need a separate rule.
|
||||||
|
|
||||||
If you want the created bundles to be installed, you may want to add this
|
If you want the created bundles to be installed, you may want to add this
|
||||||
rule to your Makefile.am:
|
rule to your Makefile.am:
|
||||||
|
|
||||||
```make
|
```make
|
||||||
install-exec-hook: APP_NAME_bundle
|
install-exec-hook: APP_NAME_bundle
|
||||||
rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app
|
rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app
|
||||||
mkdir -p $(DESTDIR)$(prefix)/Applications/
|
mkdir -p $(DESTDIR)$(prefix)/Applications/
|
||||||
cp -r $< /$(DESTDIR)$(prefix)Applications/
|
cp -r $< /$(DESTDIR)$(prefix)Applications/
|
||||||
```
|
```
|
||||||
|
|
||||||
This rule takes the Bundle created by the rule from step 3 and installs them
|
This rule takes the Bundle created by the rule from step 3 and installs them
|
||||||
into "$(DESTDIR)$(prefix)/Applications/".
|
into "$(DESTDIR)$(prefix)/Applications/".
|
||||||
|
|
||||||
Again, if you want to install multiple applications, you will have to augment
|
Again, if you want to install multiple applications, you will have to augment
|
||||||
the make rule accordingly.
|
the make rule accordingly.
|
||||||
|
|
||||||
But beware! That is only part of the story! With the above, you end up with
|
But beware! That is only part of the story! With the above, you end up with
|
||||||
a barebones .app bundle, which is double-clickable from the Finder. But
|
a barebones .app bundle, which is double-clickable from the Finder. But
|
||||||
there are some more things you should do before shipping your product...
|
there are some more things you should do before shipping your product...
|
||||||
|
|
||||||
1. The bundle right now probably is dynamically linked against SDL. That
|
1. The bundle right now probably is dynamically linked against SDL. That
|
||||||
means that when you copy it to another computer, *it will not run*,
|
means that when you copy it to another computer, *it will not run*,
|
||||||
unless you also install SDL on that other computer. A good solution
|
unless you also install SDL on that other computer. A good solution
|
||||||
for this dilemma is to static link against SDL. On OS X, you can
|
for this dilemma is to static link against SDL. On OS X, you can
|
||||||
achieve that by linking against the libraries listed by
|
achieve that by linking against the libraries listed by
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sdl-config --static-libs
|
sdl-config --static-libs
|
||||||
```
|
```
|
||||||
|
|
||||||
instead of those listed by
|
instead of those listed by
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sdl-config --libs
|
sdl-config --libs
|
||||||
```
|
```
|
||||||
|
|
||||||
Depending on how exactly SDL is integrated into your build systems, the
|
Depending on how exactly SDL is integrated into your build systems, the
|
||||||
way to achieve that varies, so I won't describe it here in detail
|
way to achieve that varies, so I won't describe it here in detail
|
||||||
|
|
||||||
2. Add an 'Info.plist' to your application. That is a special XML file which
|
2. Add an 'Info.plist' to your application. That is a special XML file which
|
||||||
contains some meta-information about your application (like some copyright
|
contains some meta-information about your application (like some copyright
|
||||||
information, the version of your app, the name of an optional icon file,
|
information, the version of your app, the name of an optional icon file,
|
||||||
and other things). Part of that information is displayed by the Finder
|
and other things). Part of that information is displayed by the Finder
|
||||||
when you click on the .app, or if you look at the "Get Info" window.
|
when you click on the .app, or if you look at the "Get Info" window.
|
||||||
More information about Info.plist files can be found on Apple's homepage.
|
More information about Info.plist files can be found on Apple's homepage.
|
||||||
|
|
||||||
|
|
||||||
As a final remark, let me add that I use some of the techniques (and some
|
As a final remark, let me add that I use some of the techniques (and some
|
||||||
variations of them) in [Exult](https://github.com/exult/exult) and
|
variations of them) in [Exult](https://github.com/exult/exult) and
|
||||||
[ScummVM](https://github.com/scummvm/scummvm); both are available in source on
|
[ScummVM](https://github.com/scummvm/scummvm); both are available in source on
|
||||||
the net, so feel free to take a peek at them for inspiration!
|
the net, so feel free to take a peek at them for inspiration!
|
||||||
|
|
||||||
|
|
||||||
# Using the Simple DirectMedia Layer with Xcode
|
# Using the Simple DirectMedia Layer with Xcode
|
||||||
|
|
||||||
These instructions are for using Apple's Xcode IDE to build SDL applications.
|
These instructions are for using Apple's Xcode IDE to build SDL applications.
|
||||||
|
|
||||||
## First steps
|
## First steps
|
||||||
|
|
||||||
The first thing to do is to unpack the Xcode.tar.gz archive in the
|
The first thing to do is to unpack the Xcode.tar.gz archive in the
|
||||||
top level SDL directory (where the Xcode.tar.gz archive resides).
|
top level SDL directory (where the Xcode.tar.gz archive resides).
|
||||||
Because Stuffit Expander will unpack the archive into a subdirectory,
|
Because Stuffit Expander will unpack the archive into a subdirectory,
|
||||||
you should unpack the archive manually from the command line:
|
you should unpack the archive manually from the command line:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd [path_to_SDL_source]
|
cd [path_to_SDL_source]
|
||||||
tar zxf Xcode.tar.gz
|
tar zxf Xcode.tar.gz
|
||||||
```
|
```
|
||||||
|
|
||||||
This will create a new folder called Xcode, which you can browse
|
This will create a new folder called Xcode, which you can browse
|
||||||
normally from the Finder.
|
normally from the Finder.
|
||||||
|
|
||||||
## Building the Framework
|
## Building the Framework
|
||||||
|
|
||||||
The SDL Library is packaged as a framework bundle, an organized
|
The SDL Library is packaged as a framework bundle, an organized
|
||||||
relocatable folder hierarchy of executable code, interface headers,
|
relocatable folder hierarchy of executable code, interface headers,
|
||||||
and additional resources. For practical purposes, you can think of a
|
and additional resources. For practical purposes, you can think of a
|
||||||
framework as a more user and system-friendly shared library, whose library
|
framework as a more user and system-friendly shared library, whose library
|
||||||
file behaves more or less like a standard UNIX shared library.
|
file behaves more or less like a standard UNIX shared library.
|
||||||
|
|
||||||
To build the framework, simply open the framework project and build it.
|
To build the framework, simply open the framework project and build it.
|
||||||
By default, the framework bundle "SDL.framework" is installed in
|
By default, the framework bundle "SDL.framework" is installed in
|
||||||
/Library/Frameworks. Therefore, the testers and project stationary expect
|
/Library/Frameworks. Therefore, the testers and project stationary expect
|
||||||
it to be located there. However, it will function the same in any of the
|
it to be located there. However, it will function the same in any of the
|
||||||
following locations:
|
following locations:
|
||||||
|
|
||||||
* ~/Library/Frameworks
|
* ~/Library/Frameworks
|
||||||
* /Local/Library/Frameworks
|
* /Local/Library/Frameworks
|
||||||
* /System/Library/Frameworks
|
* /System/Library/Frameworks
|
||||||
|
|
||||||
## Build Options
|
## Build Options
|
||||||
|
|
||||||
There are two "Build Styles" (See the "Targets" tab) for SDL.
|
There are two "Build Styles" (See the "Targets" tab) for SDL.
|
||||||
"Deployment" should be used if you aren't tweaking the SDL library.
|
"Deployment" should be used if you aren't tweaking the SDL library.
|
||||||
"Development" should be used to debug SDL apps or the library itself.
|
"Development" should be used to debug SDL apps or the library itself.
|
||||||
|
|
||||||
## Building the Testers
|
## Building the Testers
|
||||||
|
|
||||||
Open the SDLTest project and build away!
|
Open the SDLTest project and build away!
|
||||||
|
|
||||||
## Using the Project Stationary
|
## Using the Project Stationary
|
||||||
|
|
||||||
Copy the stationary to the indicated folders to access it from
|
Copy the stationary to the indicated folders to access it from
|
||||||
the "New Project" and "Add target" menus. What could be easier?
|
the "New Project" and "Add target" menus. What could be easier?
|
||||||
|
|
||||||
## Setting up a new project by hand
|
## Setting up a new project by hand
|
||||||
|
|
||||||
Some of you won't want to use the Stationary so I'll give some tips:
|
Some of you won't want to use the Stationary so I'll give some tips:
|
||||||
|
|
||||||
(this is accurate as of Xcode 12.5.)
|
(this is accurate as of Xcode 12.5.)
|
||||||
|
|
||||||
* Click "File" -> "New" -> "Project...
|
* Click "File" -> "New" -> "Project...
|
||||||
* Choose "macOS" and then "App" from the "Application" section.
|
* Choose "macOS" and then "App" from the "Application" section.
|
||||||
* Fill out the options in the next window. User interface is "XIB" and
|
* Fill out the options in the next window. User interface is "XIB" and
|
||||||
Language is "Objective-C".
|
Language is "Objective-C".
|
||||||
* Remove "main.m" from your project
|
* Remove "main.m" from your project
|
||||||
* Remove "MainMenu.xib" from your project
|
* Remove "MainMenu.xib" from your project
|
||||||
* Remove "AppDelegates.*" from your project
|
* Remove "AppDelegates.*" from your project
|
||||||
* Add "\$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path
|
* Add "\$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path
|
||||||
* Add "\$(HOME)/Library/Frameworks" to the frameworks search path
|
* Add "\$(HOME)/Library/Frameworks" to the frameworks search path
|
||||||
* Add "-framework SDL -framework Foundation -framework AppKit" to "OTHER_LDFLAGS"
|
* Add "-framework SDL -framework Foundation -framework AppKit" to "OTHER_LDFLAGS"
|
||||||
* Add your files
|
* Add your files
|
||||||
* Clean and build
|
* Clean and build
|
||||||
|
|
||||||
## Building from command line
|
## Building from command line
|
||||||
|
|
||||||
Use `xcode-build` in the same directory as your .pbxproj file
|
Use `xcode-build` in the same directory as your .pbxproj file
|
||||||
|
|
||||||
## Running your app
|
## Running your app
|
||||||
|
|
||||||
You can send command line args to your app by either invoking it from
|
You can send command line args to your app by either invoking it from
|
||||||
the command line (in *.app/Contents/MacOS) or by entering them in the
|
the command line (in *.app/Contents/MacOS) or by entering them in the
|
||||||
Executables" panel of the target settings.
|
Executables" panel of the target settings.
|
||||||
|
|
||||||
# Implementation Notes
|
# Implementation Notes
|
||||||
|
|
||||||
Some things that may be of interest about how it all works...
|
Some things that may be of interest about how it all works...
|
||||||
|
|
||||||
## Working directory
|
## Working directory
|
||||||
|
|
||||||
In SDL 1.2, the working directory of your SDL app is by default set to its
|
In SDL 1.2, the working directory of your SDL app is by default set to its
|
||||||
parent, but this is no longer the case in SDL 2.0. SDL2 does change the
|
parent, but this is no longer the case in SDL 2.0. SDL2 does change the
|
||||||
working directory, which means it'll be whatever the command line prompt
|
working directory, which means it'll be whatever the command line prompt
|
||||||
that launched the program was using, or if launched by double-clicking in
|
that launched the program was using, or if launched by double-clicking in
|
||||||
the finger, it will be "/", the _root of the filesystem_. Plan accordingly!
|
the finger, it will be "/", the _root of the filesystem_. Plan accordingly!
|
||||||
You can use SDL_GetBasePath() to find where the program is running from and
|
You can use SDL_GetBasePath() to find where the program is running from and
|
||||||
chdir() there directly.
|
chdir() there directly.
|
||||||
|
|
||||||
|
|
||||||
## You have a Cocoa App!
|
## You have a Cocoa App!
|
||||||
|
|
||||||
Your SDL app is essentially a Cocoa application. When your app
|
Your SDL app is essentially a Cocoa application. When your app
|
||||||
starts up and the libraries finish loading, a Cocoa procedure is called,
|
starts up and the libraries finish loading, a Cocoa procedure is called,
|
||||||
which sets up the working directory and calls your main() method.
|
which sets up the working directory and calls your main() method.
|
||||||
You are free to modify your Cocoa app with generally no consequence
|
You are free to modify your Cocoa app with generally no consequence
|
||||||
to SDL. You cannot, however, easily change the SDL window itself.
|
to SDL. You cannot, however, easily change the SDL window itself.
|
||||||
Functionality may be added in the future to help this.
|
Functionality may be added in the future to help this.
|
||||||
|
|
||||||
# Bug reports
|
# Bug reports
|
||||||
|
|
||||||
Bugs are tracked at [the GitHub issue tracker](https://github.com/libsdl-org/SDL/issues/).
|
Bugs are tracked at [the GitHub issue tracker](https://github.com/libsdl-org/SDL/issues/).
|
||||||
Please feel free to report bugs there!
|
Please feel free to report bugs there!
|
||||||
|
|
||||||
|
@@ -1,28 +1,28 @@
|
|||||||
# Nintendo 3DS
|
# Nintendo 3DS
|
||||||
|
|
||||||
SDL port for the Nintendo 3DS [Homebrew toolchain](https://devkitpro.org/) contributed by:
|
SDL port for the Nintendo 3DS [Homebrew toolchain](https://devkitpro.org/) contributed by:
|
||||||
|
|
||||||
- [Pierre Wendling](https://github.com/FtZPetruska)
|
- [Pierre Wendling](https://github.com/FtZPetruska)
|
||||||
|
|
||||||
Credits to:
|
Credits to:
|
||||||
|
|
||||||
- The awesome people who ported SDL to other homebrew platforms.
|
- The awesome people who ported SDL to other homebrew platforms.
|
||||||
- The Devkitpro team for making all the tools necessary to achieve this.
|
- The Devkitpro team for making all the tools necessary to achieve this.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
To build for the Nintendo 3DS, make sure you have devkitARM and cmake installed and run:
|
To build for the Nintendo 3DS, make sure you have devkitARM and cmake installed and run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/3DS.cmake" -DCMAKE_BUILD_TYPE=Release
|
cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/3DS.cmake" -DCMAKE_BUILD_TYPE=Release
|
||||||
cmake --build build
|
cmake --build build
|
||||||
cmake --install build
|
cmake --install build
|
||||||
```
|
```
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- Currently only software rendering is supported.
|
- Currently only software rendering is supported.
|
||||||
- SDL2main should be used to ensure ROMFS is enabled.
|
- SDL2main 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.
|
- 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.
|
- `SDL_GetBasePath` returns the romfs root instead of the executable's directory.
|
||||||
- The Nintendo 3DS uses a cooperative threading model on a single core, meaning a thread will never yield unless done manually through the `SDL_Delay` functions, or blocking waits (`SDL_LockMutex`, `SDL_SemWait`, `SDL_CondWait`, `SDL_WaitThread`). To avoid starving other threads, `SDL_SemTryWait` and `SDL_SemWaitTimeout` will yield if they fail to acquire the semaphore, see https://github.com/libsdl-org/SDL/pull/6776 for more information.
|
- The Nintendo 3DS uses a cooperative threading model on a single core, meaning a thread will never yield unless done manually through the `SDL_Delay` functions, or blocking waits (`SDL_LockMutex`, `SDL_SemWait`, `SDL_CondWait`, `SDL_WaitThread`). To avoid starving other threads, `SDL_SemTryWait` and `SDL_SemWaitTimeout` will yield if they fail to acquire the semaphore, see https://github.com/libsdl-org/SDL/pull/6776 for more information.
|
||||||
|
@@ -1,103 +1,103 @@
|
|||||||
Native Client
|
Native Client
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
|
|
||||||
* Native Client SDK (https://developer.chrome.com/native-client),
|
* Native Client SDK (https://developer.chrome.com/native-client),
|
||||||
(tested with Pepper version 33 or higher).
|
(tested with Pepper version 33 or higher).
|
||||||
|
|
||||||
The SDL backend for Chrome's Native Client has been tested only with the PNaCl
|
The SDL backend for Chrome's Native Client has been tested only with the PNaCl
|
||||||
toolchain, which generates binaries designed to run on ARM and x86_32/64
|
toolchain, which generates binaries designed to run on ARM and x86_32/64
|
||||||
platforms. This does not mean it won't work with the other toolchains!
|
platforms. This does not mean it won't work with the other toolchains!
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
Building SDL for NaCl
|
Building SDL for NaCl
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
Set up the right environment variables (see naclbuild.sh), then configure SDL with:
|
Set up the right environment variables (see naclbuild.sh), then configure SDL with:
|
||||||
|
|
||||||
configure --host=pnacl --prefix some/install/destination
|
configure --host=pnacl --prefix some/install/destination
|
||||||
|
|
||||||
Then "make".
|
Then "make".
|
||||||
|
|
||||||
As an example of how to create a deployable app a Makefile project is provided
|
As an example of how to create a deployable app a Makefile project is provided
|
||||||
in test/nacl/Makefile, which includes some monkey patching of the common.mk file
|
in test/nacl/Makefile, which includes some monkey patching of the common.mk file
|
||||||
provided by NaCl, without which linking properly to SDL won't work (the search
|
provided by NaCl, without which linking properly to SDL won't work (the search
|
||||||
path can't be modified externally, so the linker won't find SDL's binaries unless
|
path can't be modified externally, so the linker won't find SDL's binaries unless
|
||||||
you dump them into the SDK path, which is inconvenient).
|
you dump them into the SDK path, which is inconvenient).
|
||||||
Also provided in test/nacl is the required support file, such as index.html,
|
Also provided in test/nacl is the required support file, such as index.html,
|
||||||
manifest.json, etc.
|
manifest.json, etc.
|
||||||
SDL apps for NaCl run on a worker thread using the ppapi_simple infrastructure.
|
SDL apps for NaCl run on a worker thread using the ppapi_simple infrastructure.
|
||||||
This allows for blocking calls on all the relevant systems (OpenGL ES, filesystem),
|
This allows for blocking calls on all the relevant systems (OpenGL ES, filesystem),
|
||||||
hiding the asynchronous nature of the browser behind the scenes...which is not the
|
hiding the asynchronous nature of the browser behind the scenes...which is not the
|
||||||
same as making it disappear!
|
same as making it disappear!
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
Running tests
|
Running tests
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
Due to the nature of NaCl programs, building and running SDL tests is not as
|
Due to the nature of NaCl programs, building and running SDL tests is not as
|
||||||
straightforward as one would hope. The script naclbuild.sh in build-scripts
|
straightforward as one would hope. The script naclbuild.sh in build-scripts
|
||||||
automates the process and should serve as a guide for users of SDL trying to build
|
automates the process and should serve as a guide for users of SDL trying to build
|
||||||
their own applications.
|
their own applications.
|
||||||
|
|
||||||
Basic usage:
|
Basic usage:
|
||||||
|
|
||||||
./naclbuild.sh path/to/pepper/toolchain (i.e. ~/naclsdk/pepper_35)
|
./naclbuild.sh path/to/pepper/toolchain (i.e. ~/naclsdk/pepper_35)
|
||||||
|
|
||||||
This will build testgles2.c by default.
|
This will build testgles2.c by default.
|
||||||
|
|
||||||
If you want to build a different test, for example testrendercopyex.c:
|
If you want to build a different test, for example testrendercopyex.c:
|
||||||
|
|
||||||
SOURCES=~/sdl/SDL/test/testrendercopyex.c ./naclbuild.sh ~/naclsdk/pepper_35
|
SOURCES=~/sdl/SDL/test/testrendercopyex.c ./naclbuild.sh ~/naclsdk/pepper_35
|
||||||
|
|
||||||
Once the build finishes, you have to serve the contents with a web server (the
|
Once the build finishes, you have to serve the contents with a web server (the
|
||||||
script will give you instructions on how to do that with Python).
|
script will give you instructions on how to do that with Python).
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
RWops and nacl_io
|
RWops and nacl_io
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
SDL_RWops work transparently with nacl_io. Two functions control the mount points:
|
SDL_RWops work transparently with nacl_io. Two functions control the mount points:
|
||||||
|
|
||||||
int mount(const char* source, const char* target,
|
int mount(const char* source, const char* target,
|
||||||
const char* filesystemtype,
|
const char* filesystemtype,
|
||||||
unsigned long mountflags, const void *data);
|
unsigned long mountflags, const void *data);
|
||||||
int umount(const char *target);
|
int umount(const char *target);
|
||||||
|
|
||||||
For convenience, SDL will by default mount an httpfs tree at / before calling
|
For convenience, SDL will by default mount an httpfs tree at / before calling
|
||||||
the app's main function. Such setting can be overridden by calling:
|
the app's main function. Such setting can be overridden by calling:
|
||||||
|
|
||||||
umount("/");
|
umount("/");
|
||||||
|
|
||||||
And then mounting a different filesystem at /
|
And then mounting a different filesystem at /
|
||||||
|
|
||||||
It's important to consider that the asynchronous nature of file operations on a
|
It's important to consider that the asynchronous nature of file operations on a
|
||||||
browser is hidden from the application, effectively providing the developer with
|
browser is hidden from the application, effectively providing the developer with
|
||||||
a set of blocking file operations just like you get in a regular desktop
|
a set of blocking file operations just like you get in a regular desktop
|
||||||
environment, which eases the job of porting to Native Client, but also introduces
|
environment, which eases the job of porting to Native Client, but also introduces
|
||||||
a set of challenges of its own, in particular when big file sizes and slow
|
a set of challenges of its own, in particular when big file sizes and slow
|
||||||
connections are involved.
|
connections are involved.
|
||||||
|
|
||||||
For more information on how nacl_io and mount points work, see:
|
For more information on how nacl_io and mount points work, see:
|
||||||
|
|
||||||
https://developer.chrome.com/native-client/devguide/coding/nacl_io
|
https://developer.chrome.com/native-client/devguide/coding/nacl_io
|
||||||
https://src.chromium.org/chrome/trunk/src/native_client_sdk/src/libraries/nacl_io/nacl_io.h
|
https://src.chromium.org/chrome/trunk/src/native_client_sdk/src/libraries/nacl_io/nacl_io.h
|
||||||
|
|
||||||
To be able to save into the directory "/save/" (like backup of game) :
|
To be able to save into the directory "/save/" (like backup of game) :
|
||||||
|
|
||||||
mount("", "/save", "html5fs", 0, "type=PERSISTENT");
|
mount("", "/save", "html5fs", 0, "type=PERSISTENT");
|
||||||
|
|
||||||
And add to manifest.json :
|
And add to manifest.json :
|
||||||
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"unlimitedStorage"
|
"unlimitedStorage"
|
||||||
]
|
]
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
TODO - Known Issues
|
TODO - Known Issues
|
||||||
================================================================================
|
================================================================================
|
||||||
* Testing of all systems with a real application (something other than SDL's tests)
|
* Testing of all systems with a real application (something other than SDL's tests)
|
||||||
* Key events don't seem to work properly
|
* Key events don't seem to work properly
|
||||||
|
|
||||||
|
@@ -1,44 +1,44 @@
|
|||||||
Nokia N-Gage
|
Nokia N-Gage
|
||||||
============
|
============
|
||||||
|
|
||||||
SDL2 port for Symbian S60v1 and v2 with a main focus on the Nokia N-Gage
|
SDL2 port for Symbian S60v1 and v2 with a main focus on the Nokia N-Gage
|
||||||
(Classic and QD) by [Michael Fitzmayer](https://github.com/mupfdev).
|
(Classic and QD) by [Michael Fitzmayer](https://github.com/mupfdev).
|
||||||
|
|
||||||
Compiling
|
Compiling
|
||||||
---------
|
---------
|
||||||
|
|
||||||
SDL is part of the [N-Gage SDK.](https://github.com/ngagesdk) project.
|
SDL is part of the [N-Gage SDK.](https://github.com/ngagesdk) project.
|
||||||
The library is included in the
|
The library is included in the
|
||||||
[toolchain](https://github.com/ngagesdk/ngage-toolchain) as a
|
[toolchain](https://github.com/ngagesdk/ngage-toolchain) as a
|
||||||
sub-module.
|
sub-module.
|
||||||
|
|
||||||
A complete example project based on SDL2 can be found in the GitHub
|
A complete example project based on SDL2 can be found in the GitHub
|
||||||
account of the SDK: [Wordle](https://github.com/ngagesdk/wordle).
|
account of the SDK: [Wordle](https://github.com/ngagesdk/wordle).
|
||||||
|
|
||||||
Current level of implementation
|
Current level of implementation
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
||||||
The video driver currently provides full screen video support with
|
The video driver currently provides full screen video support with
|
||||||
keyboard input.
|
keyboard input.
|
||||||
|
|
||||||
At the moment only the software renderer works.
|
At the moment only the software renderer works.
|
||||||
|
|
||||||
Audio is not yet implemented.
|
Audio is not yet implemented.
|
||||||
|
|
||||||
Acknowledgements
|
Acknowledgements
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
Thanks to Hannu Viitala, Kimmo Kinnunen and Markus Mertama for the
|
Thanks to Hannu Viitala, Kimmo Kinnunen and Markus Mertama for the
|
||||||
valuable insight into Symbian programming. Without the SDL 1.2 port
|
valuable insight into Symbian programming. Without the SDL 1.2 port
|
||||||
which was specially developed for CDoom (Doom for the Nokia 9210), this
|
which was specially developed for CDoom (Doom for the Nokia 9210), this
|
||||||
adaptation would not have been possible.
|
adaptation would not have been possible.
|
||||||
|
|
||||||
I would like to thank my friends
|
I would like to thank my friends
|
||||||
[Razvan](https://twitter.com/bewarerazvan) and [Dan
|
[Razvan](https://twitter.com/bewarerazvan) and [Dan
|
||||||
Whelan](https://danwhelan.ie/), for their continuous support. Without
|
Whelan](https://danwhelan.ie/), for their continuous support. Without
|
||||||
you and the [N-Gage community](https://discord.gg/dbUzqJ26vs), I would
|
you and the [N-Gage community](https://discord.gg/dbUzqJ26vs), I would
|
||||||
have lost my patience long ago.
|
have lost my patience long ago.
|
||||||
|
|
||||||
Last but not least, I would like to thank the development team of
|
Last but not least, I would like to thank the development team of
|
||||||
[EKA2L1](https://12z1.com/) (an experimental Symbian OS emulator). Your
|
[EKA2L1](https://12z1.com/) (an experimental Symbian OS emulator). Your
|
||||||
patience and support in troubleshooting helped me a lot.
|
patience and support in troubleshooting helped me a lot.
|
||||||
|
@@ -1,92 +1,92 @@
|
|||||||
Simple DirectMedia Layer 2 for OS/2 & eComStation
|
Simple DirectMedia Layer 2 for OS/2 & eComStation
|
||||||
================================================================================
|
================================================================================
|
||||||
SDL port for OS/2, authored by Andrey Vasilkin <digi@os2.snc.ru>, 2016
|
SDL port for OS/2, authored by Andrey Vasilkin <digi@os2.snc.ru>, 2016
|
||||||
|
|
||||||
|
|
||||||
OpenGL not supported by this port.
|
OpenGL not supported by this port.
|
||||||
|
|
||||||
Additional optional environment variables:
|
Additional optional environment variables:
|
||||||
|
|
||||||
SDL_AUDIO_SHARE
|
SDL_AUDIO_SHARE
|
||||||
Values: 0 or 1, default is 0
|
Values: 0 or 1, default is 0
|
||||||
Initializes the device as shareable or exclusively acquired.
|
Initializes the device as shareable or exclusively acquired.
|
||||||
|
|
||||||
SDL_VIDEODRIVER
|
SDL_VIDEODRIVER
|
||||||
Values: DIVE or VMAN, default is DIVE
|
Values: DIVE or VMAN, default is DIVE
|
||||||
Use video subsystem: Direct interface video extensions (DIVE) or
|
Use video subsystem: Direct interface video extensions (DIVE) or
|
||||||
Video Manager (VMAN).
|
Video Manager (VMAN).
|
||||||
|
|
||||||
You may significantly increase video output speed with OS4 kernel and patched
|
You may significantly increase video output speed with OS4 kernel and patched
|
||||||
files vman.dll and dive.dll or with latest versions of ACPI support and video
|
files vman.dll and dive.dll or with latest versions of ACPI support and video
|
||||||
driver Panorama.
|
driver Panorama.
|
||||||
|
|
||||||
Latest versions of OS/4 kernel:
|
Latest versions of OS/4 kernel:
|
||||||
http://gus.biysk.ru/os4/
|
http://gus.biysk.ru/os4/
|
||||||
(Info: https://www.os2world.com/wiki/index.php/Phoenix_OS/4)
|
(Info: https://www.os2world.com/wiki/index.php/Phoenix_OS/4)
|
||||||
|
|
||||||
Patched files vman.dll and dive.dll:
|
Patched files vman.dll and dive.dll:
|
||||||
http://gus.biysk.ru/os4/test/pached_dll/PATCHED_DLL.RAR
|
http://gus.biysk.ru/os4/test/pached_dll/PATCHED_DLL.RAR
|
||||||
|
|
||||||
|
|
||||||
Compiling:
|
Compiling:
|
||||||
----------
|
----------
|
||||||
|
|
||||||
Open Watcom 1.9 or newer is tested. For the new Open Watcom V2 fork, see:
|
Open Watcom 1.9 or newer is tested. For the new Open Watcom V2 fork, see:
|
||||||
https://github.com/open-watcom/ and https://open-watcom.github.io
|
https://github.com/open-watcom/ and https://open-watcom.github.io
|
||||||
WATCOM environment variable must to be set to the Open Watcom install
|
WATCOM environment variable must to be set to the Open Watcom install
|
||||||
directory. To compile, run: wmake -f Makefile.os2
|
directory. To compile, run: wmake -f Makefile.os2
|
||||||
|
|
||||||
|
|
||||||
Installing:
|
Installing:
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
- eComStation:
|
- eComStation:
|
||||||
|
|
||||||
If you have previously installed SDL2, make a Backup copy of SDL2.dll
|
If you have previously installed SDL2, make a Backup copy of SDL2.dll
|
||||||
located in D:\ecs\dll (where D: is disk on which installed eComStation).
|
located in D:\ecs\dll (where D: is disk on which installed eComStation).
|
||||||
Stop all programs running with SDL2. Copy SDL2.dll to D:\ecs\dll
|
Stop all programs running with SDL2. Copy SDL2.dll to D:\ecs\dll
|
||||||
|
|
||||||
- OS/2:
|
- OS/2:
|
||||||
|
|
||||||
Copy SDL2.dll to any directory on your LIBPATH. If you have a previous
|
Copy SDL2.dll to any directory on your LIBPATH. If you have a previous
|
||||||
version installed, close all SDL2 applications before replacing the old
|
version installed, close all SDL2 applications before replacing the old
|
||||||
copy. Also make sure that any other older versions of DLLs are removed
|
copy. Also make sure that any other older versions of DLLs are removed
|
||||||
from your system.
|
from your system.
|
||||||
|
|
||||||
|
|
||||||
Joysticks in SDL2:
|
Joysticks in SDL2:
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
The joystick code in SDL2 is a direct forward-port from the SDL-1.2 version.
|
The joystick code in SDL2 is a direct forward-port from the SDL-1.2 version.
|
||||||
Here is the original documentation from SDL-1.2:
|
Here is the original documentation from SDL-1.2:
|
||||||
|
|
||||||
The Joystick detection only works for standard joysticks (2 buttons, 2 axes
|
The Joystick detection only works for standard joysticks (2 buttons, 2 axes
|
||||||
and the like). Therefore, if you use a non-standard joystick, you should
|
and the like). Therefore, if you use a non-standard joystick, you should
|
||||||
specify its features in the SDL_OS2_JOYSTICK environment variable in a batch
|
specify its features in the SDL_OS2_JOYSTICK environment variable in a batch
|
||||||
file or CONFIG.SYS, so SDL applications can provide full capability to your
|
file or CONFIG.SYS, so SDL applications can provide full capability to your
|
||||||
device. The syntax is:
|
device. The syntax is:
|
||||||
|
|
||||||
SET SDL_OS2_JOYSTICK=[JOYSTICK_NAME] [AXES] [BUTTONS] [HATS] [BALLS]
|
SET SDL_OS2_JOYSTICK=[JOYSTICK_NAME] [AXES] [BUTTONS] [HATS] [BALLS]
|
||||||
|
|
||||||
So, it you have a Gravis GamePad with 4 axes, 2 buttons, 2 hats and 0 balls,
|
So, it you have a Gravis GamePad with 4 axes, 2 buttons, 2 hats and 0 balls,
|
||||||
the line should be:
|
the line should be:
|
||||||
|
|
||||||
SET SDL_OS2_JOYSTICK=Gravis_GamePad 4 2 2 0
|
SET SDL_OS2_JOYSTICK=Gravis_GamePad 4 2 2 0
|
||||||
|
|
||||||
If you want to add spaces in your joystick name, just surround it with
|
If you want to add spaces in your joystick name, just surround it with
|
||||||
quotes or double-quotes:
|
quotes or double-quotes:
|
||||||
|
|
||||||
SET SDL_OS2_JOYSTICK='Gravis GamePad' 4 2 2 0
|
SET SDL_OS2_JOYSTICK='Gravis GamePad' 4 2 2 0
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
SET SDL_OS2_JOYSTICK="Gravis GamePad" 4 2 2 0
|
SET SDL_OS2_JOYSTICK="Gravis GamePad" 4 2 2 0
|
||||||
|
|
||||||
Note however that Balls and Hats are not supported under OS/2, and the
|
Note however that Balls and Hats are not supported under OS/2, and the
|
||||||
value will be ignored... but it is wise to define these correctly because
|
value will be ignored... but it is wise to define these correctly because
|
||||||
in the future those can be supported.
|
in the future those can be supported.
|
||||||
|
|
||||||
Also the number of buttons is limited to 2 when using two joysticks,
|
Also the number of buttons is limited to 2 when using two joysticks,
|
||||||
4 when using one joystick with 4 axes, 6 when using a joystick with 3 axes
|
4 when using one joystick with 4 axes, 6 when using a joystick with 3 axes
|
||||||
and 8 when using a joystick with 2 axes. Notice however these are limitations
|
and 8 when using a joystick with 2 axes. Notice however these are limitations
|
||||||
of the Joystick Port hardware, not OS/2.
|
of the Joystick Port hardware, not OS/2.
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
Pandora
|
Pandora
|
||||||
=====================================================================
|
=====================================================================
|
||||||
|
|
||||||
( http://openpandora.org/ )
|
( http://openpandora.org/ )
|
||||||
- A pandora specific video driver was written to allow SDL 2.0 with OpenGL ES
|
- A pandora specific video driver was written to allow SDL 2.0 with OpenGL ES
|
||||||
support to work on the pandora under the framebuffer. This driver do not have
|
support to work on the pandora under the framebuffer. This driver do not have
|
||||||
input support for now, so if you use it you will have to add your own control code.
|
input support for now, so if you use it you will have to add your own control code.
|
||||||
The video driver name is "pandora" so if you have problem running it from
|
The video driver name is "pandora" so if you have problem running it from
|
||||||
the framebuffer, try to set the following variable before starting your application :
|
the framebuffer, try to set the following variable before starting your application :
|
||||||
"export SDL_VIDEODRIVER=pandora"
|
"export SDL_VIDEODRIVER=pandora"
|
||||||
|
|
||||||
- OpenGL ES support was added to the x11 driver, so it's working like the normal
|
- OpenGL ES support was added to the x11 driver, so it's working like the normal
|
||||||
x11 driver one with OpenGLX support, with SDL input event's etc..
|
x11 driver one with OpenGLX support, with SDL input event's etc..
|
||||||
|
|
||||||
|
|
||||||
David Carré (Cpasjuste)
|
David Carré (Cpasjuste)
|
||||||
cpasjuste@gmail.com
|
cpasjuste@gmail.com
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
Platforms
|
Platforms
|
||||||
=========
|
=========
|
||||||
|
|
||||||
We maintain the list of supported platforms on our wiki now, and how to
|
We maintain the list of supported platforms on our wiki now, and how to
|
||||||
build and install SDL for those platforms:
|
build and install SDL for those platforms:
|
||||||
|
|
||||||
https://wiki.libsdl.org/Installation
|
https://wiki.libsdl.org/Installation
|
||||||
|
|
||||||
|
@@ -1,68 +1,68 @@
|
|||||||
Porting
|
Porting
|
||||||
=======
|
=======
|
||||||
|
|
||||||
* Porting To A New Platform
|
* Porting To A New Platform
|
||||||
|
|
||||||
The first thing you have to do when porting to a new platform, is look at
|
The first thing you have to do when porting to a new platform, is look at
|
||||||
include/SDL_platform.h and create an entry there for your operating system.
|
include/SDL_platform.h and create an entry there for your operating system.
|
||||||
The standard format is "__PLATFORM__", where PLATFORM is the name of the OS.
|
The standard format is "__PLATFORM__", where PLATFORM is the name of the OS.
|
||||||
Ideally SDL_platform.h will be able to auto-detect the system it's building
|
Ideally SDL_platform.h will be able to auto-detect the system it's building
|
||||||
on based on C preprocessor symbols.
|
on based on C preprocessor symbols.
|
||||||
|
|
||||||
There are two basic ways of building SDL at the moment:
|
There are two basic ways of building SDL at the moment:
|
||||||
|
|
||||||
1. The "UNIX" way: ./configure; make; make install
|
1. The "UNIX" way: ./configure; make; make install
|
||||||
|
|
||||||
If you have a GNUish system, then you might try this. Edit configure.ac,
|
If you have a GNUish system, then you might try this. Edit configure.ac,
|
||||||
take a look at the large section labelled:
|
take a look at the large section labelled:
|
||||||
|
|
||||||
"Set up the configuration based on the host platform!"
|
"Set up the configuration based on the host platform!"
|
||||||
|
|
||||||
Add a section for your platform, and then re-run autogen.sh and build!
|
Add a section for your platform, and then re-run autogen.sh and build!
|
||||||
|
|
||||||
2. Using an IDE:
|
2. Using an IDE:
|
||||||
|
|
||||||
If you're using an IDE or other non-configure build system, you'll probably
|
If you're using an IDE or other non-configure build system, you'll probably
|
||||||
want to create a custom SDL_config.h for your platform. Edit SDL_config.h,
|
want to create a custom SDL_config.h for your platform. Edit SDL_config.h,
|
||||||
add a section for your platform, and create a custom SDL_config_{platform}.h,
|
add a section for your platform, and create a custom SDL_config_{platform}.h,
|
||||||
based on SDL_config_minimal.h and SDL_config.h.in
|
based on SDL_config_minimal.h and SDL_config.h.in
|
||||||
|
|
||||||
Add the top level include directory to the header search path, and then add
|
Add the top level include directory to the header search path, and then add
|
||||||
the following sources to the project:
|
the following sources to the project:
|
||||||
|
|
||||||
src/*.c
|
src/*.c
|
||||||
src/atomic/*.c
|
src/atomic/*.c
|
||||||
src/audio/*.c
|
src/audio/*.c
|
||||||
src/cpuinfo/*.c
|
src/cpuinfo/*.c
|
||||||
src/events/*.c
|
src/events/*.c
|
||||||
src/file/*.c
|
src/file/*.c
|
||||||
src/haptic/*.c
|
src/haptic/*.c
|
||||||
src/joystick/*.c
|
src/joystick/*.c
|
||||||
src/power/*.c
|
src/power/*.c
|
||||||
src/render/*.c
|
src/render/*.c
|
||||||
src/render/software/*.c
|
src/render/software/*.c
|
||||||
src/stdlib/*.c
|
src/stdlib/*.c
|
||||||
src/thread/*.c
|
src/thread/*.c
|
||||||
src/timer/*.c
|
src/timer/*.c
|
||||||
src/video/*.c
|
src/video/*.c
|
||||||
src/audio/disk/*.c
|
src/audio/disk/*.c
|
||||||
src/audio/dummy/*.c
|
src/audio/dummy/*.c
|
||||||
src/filesystem/dummy/*.c
|
src/filesystem/dummy/*.c
|
||||||
src/video/dummy/*.c
|
src/video/dummy/*.c
|
||||||
src/haptic/dummy/*.c
|
src/haptic/dummy/*.c
|
||||||
src/joystick/dummy/*.c
|
src/joystick/dummy/*.c
|
||||||
src/main/dummy/*.c
|
src/main/dummy/*.c
|
||||||
src/thread/generic/*.c
|
src/thread/generic/*.c
|
||||||
src/timer/dummy/*.c
|
src/timer/dummy/*.c
|
||||||
src/loadso/dummy/*.c
|
src/loadso/dummy/*.c
|
||||||
|
|
||||||
|
|
||||||
Once you have a working library without any drivers, you can go back to each
|
Once you have a working library without any drivers, you can go back to each
|
||||||
of the major subsystems and start implementing drivers for your platform.
|
of the major subsystems and start implementing drivers for your platform.
|
||||||
|
|
||||||
If you have any questions, don't hesitate to ask on the SDL mailing list:
|
If you have any questions, don't hesitate to ask on the SDL mailing list:
|
||||||
http://www.libsdl.org/mailing-list.php
|
http://www.libsdl.org/mailing-list.php
|
||||||
|
|
||||||
Enjoy!
|
Enjoy!
|
||||||
Sam Lantinga (slouken@libsdl.org)
|
Sam Lantinga (slouken@libsdl.org)
|
||||||
|
|
||||||
|
@@ -1,51 +1,51 @@
|
|||||||
PS2
|
PS2
|
||||||
======
|
======
|
||||||
SDL2 port for the Sony Playstation 2 contributed by:
|
SDL2 port for the Sony Playstation 2 contributed by:
|
||||||
- Francisco Javier Trujillo Mata
|
- Francisco Javier Trujillo Mata
|
||||||
|
|
||||||
|
|
||||||
Credit to
|
Credit to
|
||||||
- The guys that ported SDL to PSP & Vita because I'm taking them as reference.
|
- The guys that ported SDL to PSP & Vita because I'm taking them as reference.
|
||||||
- David G. F. for helping me with several issues and tests.
|
- David G. F. for helping me with several issues and tests.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
To build SDL2 library for the PS2, make sure you have the latest PS2Dev status and run:
|
To build SDL2 library for the PS2, make sure you have the latest PS2Dev status and run:
|
||||||
```bash
|
```bash
|
||||||
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PS2DEV/ps2sdk/ps2dev.cmake
|
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PS2DEV/ps2sdk/ps2dev.cmake
|
||||||
cmake --build build
|
cmake --build build
|
||||||
cmake --install build
|
cmake --install build
|
||||||
```
|
```
|
||||||
|
|
||||||
## Hints
|
## Hints
|
||||||
The PS2 port has a special Hint for having a dynamic VSYNC. The Hint is `SDL_HINT_PS2_DYNAMIC_VSYNC`.
|
The PS2 port has a special Hint for having a dynamic VSYNC. The Hint is `SDL_HINT_PS2_DYNAMIC_VSYNC`.
|
||||||
If you enabled the dynamic vsync having as well `SDL_RENDERER_PRESENTVSYNC` enabled, then if the app is not able to run at 60 FPS, automatically the `vsync` will be disabled having a better performance, instead of droping FPS to 30.
|
If you enabled the dynamic vsync having as well `SDL_RENDERER_PRESENTVSYNC` enabled, then if the app is not able to run at 60 FPS, automatically the `vsync` will be disabled having a better performance, instead of droping FPS to 30.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
If you trying to debug a SDL app through [ps2client](https://github.com/ps2dev/ps2client) you need to avoid the IOP reset, otherwise you will lose the conection with your computer.
|
If you trying to debug a SDL app through [ps2client](https://github.com/ps2dev/ps2client) you need to avoid the IOP reset, otherwise you will lose the conection with your computer.
|
||||||
So to avoid the reset of the IOP CPU, you need to call to the macro `SDL_PS2_SKIP_IOP_RESET();`.
|
So to avoid the reset of the IOP CPU, you need to call to the macro `SDL_PS2_SKIP_IOP_RESET();`.
|
||||||
It could be something similar as:
|
It could be something similar as:
|
||||||
```c
|
```c
|
||||||
.....
|
.....
|
||||||
|
|
||||||
SDL_PS2_SKIP_IOP_RESET();
|
SDL_PS2_SKIP_IOP_RESET();
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
.....
|
.....
|
||||||
```
|
```
|
||||||
For a release binary is recommendable to reset the IOP always.
|
For a release binary is recommendable to reset the IOP always.
|
||||||
|
|
||||||
Remember to do a clean compilation everytime you enable or disable the `SDL_PS2_SKIP_IOP_RESET` otherwise the change won't be reflected.
|
Remember to do a clean compilation everytime you enable or disable the `SDL_PS2_SKIP_IOP_RESET` otherwise the change won't be reflected.
|
||||||
|
|
||||||
## Getting PS2 Dev
|
## Getting PS2 Dev
|
||||||
[Installing PS2 Dev](https://github.com/ps2dev/ps2dev)
|
[Installing PS2 Dev](https://github.com/ps2dev/ps2dev)
|
||||||
|
|
||||||
## Running on PCSX2 Emulator
|
## Running on PCSX2 Emulator
|
||||||
[PCSX2](https://github.com/PCSX2/pcsx2)
|
[PCSX2](https://github.com/PCSX2/pcsx2)
|
||||||
|
|
||||||
[More PCSX2 information](https://pcsx2.net/)
|
[More PCSX2 information](https://pcsx2.net/)
|
||||||
|
|
||||||
## To Do
|
## To Do
|
||||||
- PS2 Screen Keyboard
|
- PS2 Screen Keyboard
|
||||||
- Dialogs
|
- Dialogs
|
||||||
- Others
|
- Others
|
||||||
|
@@ -1,36 +1,36 @@
|
|||||||
PSP
|
PSP
|
||||||
======
|
======
|
||||||
SDL2 port for the Sony PSP contributed by:
|
SDL2 port for the Sony PSP contributed by:
|
||||||
- Captian Lex
|
- Captian Lex
|
||||||
- Francisco Javier Trujillo Mata
|
- Francisco Javier Trujillo Mata
|
||||||
- Wouter Wijsman
|
- Wouter Wijsman
|
||||||
|
|
||||||
|
|
||||||
Credit to
|
Credit to
|
||||||
Marcus R.Brown,Jim Paris,Matthew H for the original SDL 1.2 for PSP
|
Marcus R.Brown,Jim Paris,Matthew H for the original SDL 1.2 for PSP
|
||||||
Geecko for his PSP GU lib "Glib2d"
|
Geecko for his PSP GU lib "Glib2d"
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
To build SDL2 library for the PSP, make sure you have the latest PSPDev status and run:
|
To build SDL2 library for the PSP, make sure you have the latest PSPDev status and run:
|
||||||
```bash
|
```bash
|
||||||
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PSPDEV/psp/share/pspdev.cmake
|
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PSPDEV/psp/share/pspdev.cmake
|
||||||
cmake --build build
|
cmake --build build
|
||||||
cmake --install build
|
cmake --install build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Getting PSP Dev
|
## Getting PSP Dev
|
||||||
[Installing PSP Dev](https://github.com/pspdev/pspdev)
|
[Installing PSP Dev](https://github.com/pspdev/pspdev)
|
||||||
|
|
||||||
## Running on PPSSPP Emulator
|
## Running on PPSSPP Emulator
|
||||||
[PPSSPP](https://github.com/hrydgard/ppsspp)
|
[PPSSPP](https://github.com/hrydgard/ppsspp)
|
||||||
|
|
||||||
[Build Instructions](https://github.com/hrydgard/ppsspp/wiki/Build-instructions)
|
[Build Instructions](https://github.com/hrydgard/ppsspp/wiki/Build-instructions)
|
||||||
|
|
||||||
|
|
||||||
## Compiling a HelloWorld
|
## Compiling a HelloWorld
|
||||||
[PSP Hello World](https://psp-dev.org/doku.php?id=tutorial:hello_world)
|
[PSP Hello World](https://psp-dev.org/doku.php?id=tutorial:hello_world)
|
||||||
|
|
||||||
## To Do
|
## To Do
|
||||||
- PSP Screen Keyboard
|
- PSP Screen Keyboard
|
||||||
- Dialogs
|
- Dialogs
|
||||||
|
@@ -1,180 +1,180 @@
|
|||||||
Raspberry Pi
|
Raspberry Pi
|
||||||
============
|
============
|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
|
|
||||||
Raspbian (other Linux distros may work as well).
|
Raspbian (other Linux distros may work as well).
|
||||||
|
|
||||||
Features
|
Features
|
||||||
--------
|
--------
|
||||||
|
|
||||||
* Works without X11
|
* Works without X11
|
||||||
* Hardware accelerated OpenGL ES 2.x
|
* Hardware accelerated OpenGL ES 2.x
|
||||||
* Sound via ALSA
|
* Sound via ALSA
|
||||||
* Input (mouse/keyboard/joystick) via EVDEV
|
* Input (mouse/keyboard/joystick) via EVDEV
|
||||||
* Hotplugging of input devices via UDEV
|
* Hotplugging of input devices via UDEV
|
||||||
|
|
||||||
|
|
||||||
Raspbian Build Dependencies
|
Raspbian Build Dependencies
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
sudo apt-get install libudev-dev libasound2-dev libdbus-1-dev
|
sudo apt-get install libudev-dev libasound2-dev libdbus-1-dev
|
||||||
|
|
||||||
You also need the VideoCore binary stuff that ships in /opt/vc for EGL and
|
You also need the VideoCore binary stuff that ships in /opt/vc for EGL and
|
||||||
OpenGL ES 2.x, it usually comes pre-installed, but in any case:
|
OpenGL ES 2.x, it usually comes pre-installed, but in any case:
|
||||||
|
|
||||||
sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev
|
sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev
|
||||||
|
|
||||||
|
|
||||||
NEON
|
NEON
|
||||||
----
|
----
|
||||||
|
|
||||||
If your Pi has NEON support, make sure you add -mfpu=neon to your CFLAGS so
|
If your Pi has NEON support, make sure you add -mfpu=neon to your CFLAGS so
|
||||||
that SDL will select some otherwise-disabled highly-optimized code. The
|
that SDL will select some otherwise-disabled highly-optimized code. The
|
||||||
original Pi units don't have NEON, the Pi2 probably does, and the Pi3
|
original Pi units don't have NEON, the Pi2 probably does, and the Pi3
|
||||||
definitely does.
|
definitely does.
|
||||||
|
|
||||||
|
|
||||||
Cross compiling from x86 Linux
|
Cross compiling from x86 Linux
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
To cross compile SDL for Raspbian from your desktop machine, you'll need a
|
To cross compile SDL for Raspbian from your desktop machine, you'll need a
|
||||||
Raspbian system root and the cross compilation tools. We'll assume these tools
|
Raspbian system root and the cross compilation tools. We'll assume these tools
|
||||||
will be placed in /opt/rpi-tools
|
will be placed in /opt/rpi-tools
|
||||||
|
|
||||||
sudo git clone --depth 1 https://github.com/raspberrypi/tools /opt/rpi-tools
|
sudo git clone --depth 1 https://github.com/raspberrypi/tools /opt/rpi-tools
|
||||||
|
|
||||||
You'll also need a Raspbian binary image.
|
You'll also need a Raspbian binary image.
|
||||||
Get it from: http://downloads.raspberrypi.org/raspbian_latest
|
Get it from: http://downloads.raspberrypi.org/raspbian_latest
|
||||||
After unzipping, you'll get file with a name like: "<date>-wheezy-raspbian.img"
|
After unzipping, you'll get file with a name like: "<date>-wheezy-raspbian.img"
|
||||||
Let's assume the sysroot will be built in /opt/rpi-sysroot.
|
Let's assume the sysroot will be built in /opt/rpi-sysroot.
|
||||||
|
|
||||||
export SYSROOT=/opt/rpi-sysroot
|
export SYSROOT=/opt/rpi-sysroot
|
||||||
sudo kpartx -a -v <path_to_raspbian_image>.img
|
sudo kpartx -a -v <path_to_raspbian_image>.img
|
||||||
sudo mount -o loop /dev/mapper/loop0p2 /mnt
|
sudo mount -o loop /dev/mapper/loop0p2 /mnt
|
||||||
sudo cp -r /mnt $SYSROOT
|
sudo cp -r /mnt $SYSROOT
|
||||||
sudo apt-get install qemu binfmt-support qemu-user-static
|
sudo apt-get install qemu binfmt-support qemu-user-static
|
||||||
sudo cp /usr/bin/qemu-arm-static $SYSROOT/usr/bin
|
sudo cp /usr/bin/qemu-arm-static $SYSROOT/usr/bin
|
||||||
sudo mount --bind /dev $SYSROOT/dev
|
sudo mount --bind /dev $SYSROOT/dev
|
||||||
sudo mount --bind /proc $SYSROOT/proc
|
sudo mount --bind /proc $SYSROOT/proc
|
||||||
sudo mount --bind /sys $SYSROOT/sys
|
sudo mount --bind /sys $SYSROOT/sys
|
||||||
|
|
||||||
Now, before chrooting into the ARM sysroot, you'll need to apply a workaround,
|
Now, before chrooting into the ARM sysroot, you'll need to apply a workaround,
|
||||||
edit $SYSROOT/etc/ld.so.preload and comment out all lines in it.
|
edit $SYSROOT/etc/ld.so.preload and comment out all lines in it.
|
||||||
|
|
||||||
sudo chroot $SYSROOT
|
sudo chroot $SYSROOT
|
||||||
apt-get install libudev-dev libasound2-dev libdbus-1-dev libraspberrypi0 libraspberrypi-bin libraspberrypi-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev
|
apt-get install libudev-dev libasound2-dev libdbus-1-dev libraspberrypi0 libraspberrypi-bin libraspberrypi-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev
|
||||||
exit
|
exit
|
||||||
sudo umount $SYSROOT/dev
|
sudo umount $SYSROOT/dev
|
||||||
sudo umount $SYSROOT/proc
|
sudo umount $SYSROOT/proc
|
||||||
sudo umount $SYSROOT/sys
|
sudo umount $SYSROOT/sys
|
||||||
sudo umount /mnt
|
sudo umount /mnt
|
||||||
|
|
||||||
There's one more fix required, as the libdl.so symlink uses an absolute path
|
There's one more fix required, as the libdl.so symlink uses an absolute path
|
||||||
which doesn't quite work in our setup.
|
which doesn't quite work in our setup.
|
||||||
|
|
||||||
sudo rm -rf $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
|
sudo rm -rf $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
|
||||||
sudo ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
|
sudo ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
|
||||||
|
|
||||||
The final step is compiling SDL itself.
|
The final step is compiling SDL itself.
|
||||||
|
|
||||||
export CC="/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux"
|
export CC="/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux"
|
||||||
cd <SDL SOURCE>
|
cd <SDL SOURCE>
|
||||||
mkdir -p build;cd build
|
mkdir -p build;cd build
|
||||||
LDFLAGS="-L$SYSROOT/opt/vc/lib" ../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd
|
LDFLAGS="-L$SYSROOT/opt/vc/lib" ../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd
|
||||||
make
|
make
|
||||||
make install
|
make install
|
||||||
|
|
||||||
To be able to deploy this to /usr/local in the Raspbian system you need to fix up a few paths:
|
To be able to deploy this to /usr/local in the Raspbian system you need to fix up a few paths:
|
||||||
|
|
||||||
perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/lib/libSDL2.la ./rpi-sdl2-installed/lib/pkgconfig/sdl2.pc ./rpi-sdl2-installed/bin/sdl2-config
|
perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/lib/libSDL2.la ./rpi-sdl2-installed/lib/pkgconfig/sdl2.pc ./rpi-sdl2-installed/bin/sdl2-config
|
||||||
|
|
||||||
Apps don't work or poor video/audio performance
|
Apps don't work or poor video/audio performance
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
|
|
||||||
If you get sound problems, buffer underruns, etc, run "sudo rpi-update" to
|
If you get sound problems, buffer underruns, etc, run "sudo rpi-update" to
|
||||||
update the RPi's firmware. Note that doing so will fix these problems, but it
|
update the RPi's firmware. Note that doing so will fix these problems, but it
|
||||||
will also render the CMA - Dynamic Memory Split functionality useless.
|
will also render the CMA - Dynamic Memory Split functionality useless.
|
||||||
|
|
||||||
Also, by default the Raspbian distro configures the GPU RAM at 64MB, this is too
|
Also, by default the Raspbian distro configures the GPU RAM at 64MB, this is too
|
||||||
low in general, specially if a 1080p TV is hooked up.
|
low in general, specially if a 1080p TV is hooked up.
|
||||||
|
|
||||||
See here how to configure this setting: http://elinux.org/RPiconfig
|
See here how to configure this setting: http://elinux.org/RPiconfig
|
||||||
|
|
||||||
Using a fixed gpu_mem=128 is the best option (specially if you updated the
|
Using a fixed gpu_mem=128 is the best option (specially if you updated the
|
||||||
firmware, using CMA probably won't work, at least it's the current case).
|
firmware, using CMA probably won't work, at least it's the current case).
|
||||||
|
|
||||||
No input
|
No input
|
||||||
--------
|
--------
|
||||||
|
|
||||||
Make sure you belong to the "input" group.
|
Make sure you belong to the "input" group.
|
||||||
|
|
||||||
sudo usermod -aG input `whoami`
|
sudo usermod -aG input `whoami`
|
||||||
|
|
||||||
No HDMI Audio
|
No HDMI Audio
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
If you notice that ALSA works but there's no audio over HDMI, try adding:
|
If you notice that ALSA works but there's no audio over HDMI, try adding:
|
||||||
|
|
||||||
hdmi_drive=2
|
hdmi_drive=2
|
||||||
|
|
||||||
to your config.txt file and reboot.
|
to your config.txt file and reboot.
|
||||||
|
|
||||||
Reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062
|
Reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062
|
||||||
|
|
||||||
Text Input API support
|
Text Input API support
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
The Text Input API is supported, with translation of scan codes done via the
|
The Text Input API is supported, with translation of scan codes done via the
|
||||||
kernel symbol tables. For this to work, SDL needs access to a valid console.
|
kernel symbol tables. For this to work, SDL needs access to a valid console.
|
||||||
If you notice there's no SDL_TEXTINPUT message being emitted, double check that
|
If you notice there's no SDL_TEXTINPUT message being emitted, double check that
|
||||||
your app has read access to one of the following:
|
your app has read access to one of the following:
|
||||||
|
|
||||||
* /proc/self/fd/0
|
* /proc/self/fd/0
|
||||||
* /dev/tty
|
* /dev/tty
|
||||||
* /dev/tty[0...6]
|
* /dev/tty[0...6]
|
||||||
* /dev/vc/0
|
* /dev/vc/0
|
||||||
* /dev/console
|
* /dev/console
|
||||||
|
|
||||||
This is usually not a problem if you run from the physical terminal (as opposed
|
This is usually not a problem if you run from the physical terminal (as opposed
|
||||||
to running from a pseudo terminal, such as via SSH). If running from a PTS, a
|
to running from a pseudo terminal, such as via SSH). If running from a PTS, a
|
||||||
quick workaround is to run your app as root or add yourself to the tty group,
|
quick workaround is to run your app as root or add yourself to the tty group,
|
||||||
then re-login to the system.
|
then re-login to the system.
|
||||||
|
|
||||||
sudo usermod -aG tty `whoami`
|
sudo usermod -aG tty `whoami`
|
||||||
|
|
||||||
The keyboard layout used by SDL is the same as the one the kernel uses.
|
The keyboard layout used by SDL is the same as the one the kernel uses.
|
||||||
To configure the layout on Raspbian:
|
To configure the layout on Raspbian:
|
||||||
|
|
||||||
sudo dpkg-reconfigure keyboard-configuration
|
sudo dpkg-reconfigure keyboard-configuration
|
||||||
|
|
||||||
To configure the locale, which controls which keys are interpreted as letters,
|
To configure the locale, which controls which keys are interpreted as letters,
|
||||||
this determining the CAPS LOCK behavior:
|
this determining the CAPS LOCK behavior:
|
||||||
|
|
||||||
sudo dpkg-reconfigure locales
|
sudo dpkg-reconfigure locales
|
||||||
|
|
||||||
|
|
||||||
OpenGL problems
|
OpenGL problems
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
If you have desktop OpenGL headers installed at build time in your RPi or cross
|
If you have desktop OpenGL headers installed at build time in your RPi or cross
|
||||||
compilation environment, support for it will be built in. However, the chipset
|
compilation environment, support for it will be built in. However, the chipset
|
||||||
does not actually have support for it, which causes issues in certain SDL apps
|
does not actually have support for it, which causes issues in certain SDL apps
|
||||||
since the presence of OpenGL support supersedes the ES/ES2 variants.
|
since the presence of OpenGL support supersedes the ES/ES2 variants.
|
||||||
The workaround is to disable OpenGL at configuration time:
|
The workaround is to disable OpenGL at configuration time:
|
||||||
|
|
||||||
./configure --disable-video-opengl
|
./configure --disable-video-opengl
|
||||||
|
|
||||||
Or if the application uses the Render functions, you can use the SDL_RENDER_DRIVER
|
Or if the application uses the Render functions, you can use the SDL_RENDER_DRIVER
|
||||||
environment variable:
|
environment variable:
|
||||||
|
|
||||||
export SDL_RENDER_DRIVER=opengles2
|
export SDL_RENDER_DRIVER=opengles2
|
||||||
|
|
||||||
Notes
|
Notes
|
||||||
-----
|
-----
|
||||||
|
|
||||||
* When launching apps remotely (via SSH), SDL can prevent local keystrokes from
|
* When launching apps remotely (via SSH), SDL can prevent local keystrokes from
|
||||||
leaking into the console only if it has root privileges. Launching apps locally
|
leaking into the console only if it has root privileges. Launching apps locally
|
||||||
does not suffer from this issue.
|
does not suffer from this issue.
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,41 +1,41 @@
|
|||||||
RISC OS
|
RISC OS
|
||||||
=======
|
=======
|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
|
|
||||||
* RISC OS 3.5 or later.
|
* RISC OS 3.5 or later.
|
||||||
* [SharedUnixLibrary](http://www.riscos.info/packages/LibraryDetails.html#SharedUnixLibraryarm).
|
* [SharedUnixLibrary](http://www.riscos.info/packages/LibraryDetails.html#SharedUnixLibraryarm).
|
||||||
* [DigitalRenderer](http://www.riscos.info/packages/LibraryDetails.html#DRendererarm), for audio support.
|
* [DigitalRenderer](http://www.riscos.info/packages/LibraryDetails.html#DRendererarm), for audio support.
|
||||||
* [Iconv](http://www.netsurf-browser.org/projects/iconv/), for `SDL_iconv` and related functions.
|
* [Iconv](http://www.netsurf-browser.org/projects/iconv/), for `SDL_iconv` and related functions.
|
||||||
|
|
||||||
|
|
||||||
Compiling:
|
Compiling:
|
||||||
----------
|
----------
|
||||||
|
|
||||||
Currently, SDL2 for RISC OS only supports compiling with GCCSDK under Linux. Both the autoconf and CMake build systems are supported.
|
Currently, SDL2 for RISC OS only supports compiling with GCCSDK under Linux. Both the autoconf and CMake build systems are supported.
|
||||||
|
|
||||||
The following commands can be used to build SDL2 for RISC OS using autoconf:
|
The following commands can be used to build SDL2 for RISC OS using autoconf:
|
||||||
|
|
||||||
./configure --host=arm-unknown-riscos --prefix=$GCCSDK_INSTALL_ENV --disable-gcc-atomics
|
./configure --host=arm-unknown-riscos --prefix=$GCCSDK_INSTALL_ENV --disable-gcc-atomics
|
||||||
make
|
make
|
||||||
make install
|
make install
|
||||||
|
|
||||||
The following commands can be used to build SDL2 for RISC OS using CMake:
|
The following commands can be used to build SDL2 for RISC OS using CMake:
|
||||||
|
|
||||||
cmake -Bbuild-riscos -DCMAKE_TOOLCHAIN_FILE=$GCCSDK_INSTALL_ENV/toolchain-riscos.cmake -DRISCOS=ON -DCMAKE_INSTALL_PREFIX=$GCCSDK_INSTALL_ENV -DCMAKE_BUILD_TYPE=Release -DSDL_GCC_ATOMICS=OFF
|
cmake -Bbuild-riscos -DCMAKE_TOOLCHAIN_FILE=$GCCSDK_INSTALL_ENV/toolchain-riscos.cmake -DRISCOS=ON -DCMAKE_INSTALL_PREFIX=$GCCSDK_INSTALL_ENV -DCMAKE_BUILD_TYPE=Release -DSDL_GCC_ATOMICS=OFF
|
||||||
cmake --build build-riscos
|
cmake --build build-riscos
|
||||||
cmake --build build-riscos --target install
|
cmake --build build-riscos --target install
|
||||||
|
|
||||||
|
|
||||||
Current level of implementation
|
Current level of implementation
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
||||||
The video driver currently provides full screen video support with keyboard and mouse input. Windowed mode is not yet supported, but is planned in the future. Only software rendering is supported.
|
The video driver currently provides full screen video support with keyboard and mouse input. Windowed mode is not yet supported, but is planned in the future. Only software rendering is supported.
|
||||||
|
|
||||||
The filesystem APIs return either Unix-style paths or RISC OS-style paths based on the value of the `__riscosify_control` symbol, as is standard for UnixLib functions.
|
The filesystem APIs return either Unix-style paths or RISC OS-style paths based on the value of the `__riscosify_control` symbol, as is standard for UnixLib functions.
|
||||||
|
|
||||||
The audio, loadso, thread and timer APIs are currently provided by UnixLib.
|
The audio, loadso, thread and timer APIs are currently provided by UnixLib.
|
||||||
|
|
||||||
GCC atomics are currently broken on some platforms, meaning it's currently necessary to compile with `--disable-gcc-atomics` using autotools or `-DSDL_GCC_ATOMICS=OFF` using CMake.
|
GCC atomics are currently broken on some platforms, meaning it's currently necessary to compile with `--disable-gcc-atomics` using autotools or `-DSDL_GCC_ATOMICS=OFF` using CMake.
|
||||||
|
|
||||||
The joystick, locale and power APIs are not yet implemented.
|
The joystick, locale and power APIs are not yet implemented.
|
||||||
|
@@ -1,86 +1,86 @@
|
|||||||
Touch
|
Touch
|
||||||
===========================================================================
|
===========================================================================
|
||||||
System Specific Notes
|
System Specific Notes
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Linux:
|
Linux:
|
||||||
The linux touch system is currently based off event streams, and proc/bus/devices. The active user must be given permissions to read /dev/input/TOUCHDEVICE, where TOUCHDEVICE is the event stream for your device. Currently only Wacom tablets are supported. If you have an unsupported tablet contact me at jim.tla+sdl_touch@gmail.com and I will help you get support for it.
|
The linux touch system is currently based off event streams, and proc/bus/devices. The active user must be given permissions to read /dev/input/TOUCHDEVICE, where TOUCHDEVICE is the event stream for your device. Currently only Wacom tablets are supported. If you have an unsupported tablet contact me at jim.tla+sdl_touch@gmail.com and I will help you get support for it.
|
||||||
|
|
||||||
Mac:
|
Mac:
|
||||||
The Mac and iPhone APIs are pretty. If your touch device supports them then you'll be fine. If it doesn't, then there isn't much we can do.
|
The Mac and iPhone APIs are pretty. If your touch device supports them then you'll be fine. If it doesn't, then there isn't much we can do.
|
||||||
|
|
||||||
iPhone:
|
iPhone:
|
||||||
Works out of box.
|
Works out of box.
|
||||||
|
|
||||||
Windows:
|
Windows:
|
||||||
Unfortunately there is no windows support as of yet. Support for Windows 7 is planned, but we currently have no way to test. If you have a Windows 7 WM_TOUCH supported device, and are willing to help test please contact me at jim.tla+sdl_touch@gmail.com
|
Unfortunately there is no windows support as of yet. Support for Windows 7 is planned, but we currently have no way to test. If you have a Windows 7 WM_TOUCH supported device, and are willing to help test please contact me at jim.tla+sdl_touch@gmail.com
|
||||||
|
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Events
|
Events
|
||||||
===========================================================================
|
===========================================================================
|
||||||
SDL_FINGERDOWN:
|
SDL_FINGERDOWN:
|
||||||
Sent when a finger (or stylus) is placed on a touch device.
|
Sent when a finger (or stylus) is placed on a touch device.
|
||||||
Fields:
|
Fields:
|
||||||
* event.tfinger.touchId - the Id of the touch device.
|
* event.tfinger.touchId - the Id of the touch device.
|
||||||
* event.tfinger.fingerId - the Id of the finger which just went down.
|
* event.tfinger.fingerId - the Id of the finger which just went down.
|
||||||
* event.tfinger.x - the x coordinate of the touch (0..1)
|
* event.tfinger.x - the x coordinate of the touch (0..1)
|
||||||
* event.tfinger.y - the y coordinate of the touch (0..1)
|
* event.tfinger.y - the y coordinate of the touch (0..1)
|
||||||
* event.tfinger.pressure - the pressure of the touch (0..1)
|
* event.tfinger.pressure - the pressure of the touch (0..1)
|
||||||
|
|
||||||
SDL_FINGERMOTION:
|
SDL_FINGERMOTION:
|
||||||
Sent when a finger (or stylus) is moved on the touch device.
|
Sent when a finger (or stylus) is moved on the touch device.
|
||||||
Fields:
|
Fields:
|
||||||
Same as SDL_FINGERDOWN but with additional:
|
Same as SDL_FINGERDOWN but with additional:
|
||||||
* event.tfinger.dx - change in x coordinate during this motion event.
|
* event.tfinger.dx - change in x coordinate during this motion event.
|
||||||
* event.tfinger.dy - change in y coordinate during this motion event.
|
* event.tfinger.dy - change in y coordinate during this motion event.
|
||||||
|
|
||||||
SDL_FINGERUP:
|
SDL_FINGERUP:
|
||||||
Sent when a finger (or stylus) is lifted from the touch device.
|
Sent when a finger (or stylus) is lifted from the touch device.
|
||||||
Fields:
|
Fields:
|
||||||
Same as SDL_FINGERDOWN.
|
Same as SDL_FINGERDOWN.
|
||||||
|
|
||||||
|
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Functions
|
Functions
|
||||||
===========================================================================
|
===========================================================================
|
||||||
SDL provides the ability to access the underlying SDL_Finger structures.
|
SDL provides the ability to access the underlying SDL_Finger structures.
|
||||||
These structures should _never_ be modified.
|
These structures should _never_ be modified.
|
||||||
|
|
||||||
The following functions are included from SDL_touch.h
|
The following functions are included from SDL_touch.h
|
||||||
|
|
||||||
To get a SDL_TouchID call SDL_GetTouchDevice(int index).
|
To get a SDL_TouchID call SDL_GetTouchDevice(int index).
|
||||||
This returns a SDL_TouchID.
|
This returns a SDL_TouchID.
|
||||||
IMPORTANT: If the touch has been removed, or there is no touch with the given index, SDL_GetTouchDevice() will return 0. Be sure to check for this!
|
IMPORTANT: If the touch has been removed, or there is no touch with the given index, SDL_GetTouchDevice() will return 0. Be sure to check for this!
|
||||||
|
|
||||||
The number of touch devices can be queried with SDL_GetNumTouchDevices().
|
The number of touch devices can be queried with SDL_GetNumTouchDevices().
|
||||||
|
|
||||||
A SDL_TouchID may be used to get pointers to SDL_Finger.
|
A SDL_TouchID may be used to get pointers to SDL_Finger.
|
||||||
|
|
||||||
SDL_GetNumTouchFingers(touchID) may be used to get the number of fingers currently down on the device.
|
SDL_GetNumTouchFingers(touchID) may be used to get the number of fingers currently down on the device.
|
||||||
|
|
||||||
The most common reason to access SDL_Finger is to query the fingers outside the event. In most cases accessing the fingers is using the event. This would be accomplished by code like the following:
|
The most common reason to access SDL_Finger is to query the fingers outside the event. In most cases accessing the fingers is using the event. This would be accomplished by code like the following:
|
||||||
|
|
||||||
float x = event.tfinger.x;
|
float x = event.tfinger.x;
|
||||||
float y = event.tfinger.y;
|
float y = event.tfinger.y;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
To get a SDL_Finger, call SDL_GetTouchFinger(SDL_TouchID touchID, int index), where touchID is a SDL_TouchID, and index is the requested finger.
|
To get a SDL_Finger, call SDL_GetTouchFinger(SDL_TouchID touchID, int index), where touchID is a SDL_TouchID, and index is the requested finger.
|
||||||
This returns a SDL_Finger *, or NULL if the finger does not exist, or has been removed.
|
This returns a SDL_Finger *, or NULL if the finger does not exist, or has been removed.
|
||||||
A SDL_Finger is guaranteed to be persistent for the duration of a touch, but it will be de-allocated as soon as the finger is removed. This occurs when the SDL_FINGERUP event is _added_ to the event queue, and thus _before_ the SDL_FINGERUP event is polled.
|
A SDL_Finger is guaranteed to be persistent for the duration of a touch, but it will be de-allocated as soon as the finger is removed. This occurs when the SDL_FINGERUP event is _added_ to the event queue, and thus _before_ the SDL_FINGERUP event is polled.
|
||||||
As a result, be very careful to check for NULL return values.
|
As a result, be very careful to check for NULL return values.
|
||||||
|
|
||||||
A SDL_Finger has the following fields:
|
A SDL_Finger has the following fields:
|
||||||
* x, y:
|
* x, y:
|
||||||
The current coordinates of the touch.
|
The current coordinates of the touch.
|
||||||
* pressure:
|
* pressure:
|
||||||
The pressure of the touch.
|
The pressure of the touch.
|
||||||
|
|
||||||
|
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Notes
|
Notes
|
||||||
===========================================================================
|
===========================================================================
|
||||||
For a complete example see test/testgesture.c
|
For a complete example see test/testgesture.c
|
||||||
|
|
||||||
Please direct questions/comments to:
|
Please direct questions/comments to:
|
||||||
jim.tla+sdl_touch@gmail.com
|
jim.tla+sdl_touch@gmail.com
|
||||||
(original author, API was changed since)
|
(original author, API was changed since)
|
||||||
|
@@ -1,60 +1,60 @@
|
|||||||
# Versioning
|
# Versioning
|
||||||
|
|
||||||
## Since 2.23.0
|
## Since 2.23.0
|
||||||
|
|
||||||
SDL follows an "odd/even" versioning policy, similar to GLib, GTK, Flatpak
|
SDL follows an "odd/even" versioning policy, similar to GLib, GTK, Flatpak
|
||||||
and older versions of the Linux kernel:
|
and older versions of the Linux kernel:
|
||||||
|
|
||||||
* The major version (first part) increases when backwards compatibility
|
* The major version (first part) increases when backwards compatibility
|
||||||
is broken, which will happen infrequently.
|
is broken, which will happen infrequently.
|
||||||
|
|
||||||
* If the minor version (second part) is divisible by 2
|
* If the minor version (second part) is divisible by 2
|
||||||
(for example 2.24.x, 2.26.x), this indicates a version of SDL that
|
(for example 2.24.x, 2.26.x), this indicates a version of SDL that
|
||||||
is believed to be stable and suitable for production use.
|
is believed to be stable and suitable for production use.
|
||||||
|
|
||||||
* In stable releases, the patchlevel or micro version (third part)
|
* In stable releases, the patchlevel or micro version (third part)
|
||||||
indicates bugfix releases. Bugfix releases should not add or
|
indicates bugfix releases. Bugfix releases should not add or
|
||||||
remove ABI, so the ".0" release (for example 2.24.0) should be
|
remove ABI, so the ".0" release (for example 2.24.0) should be
|
||||||
forwards-compatible with all the bugfix releases from the
|
forwards-compatible with all the bugfix releases from the
|
||||||
same cycle (for example 2.24.1).
|
same cycle (for example 2.24.1).
|
||||||
|
|
||||||
* The minor version increases when new API or ABI is added, or when
|
* The minor version increases when new API or ABI is added, or when
|
||||||
other significant changes are made. Newer minor versions are
|
other significant changes are made. Newer minor versions are
|
||||||
backwards-compatible, but not fully forwards-compatible.
|
backwards-compatible, but not fully forwards-compatible.
|
||||||
For example, programs built against SDL 2.24.x should work fine
|
For example, programs built against SDL 2.24.x should work fine
|
||||||
with SDL 2.26.x, but programs built against SDL 2.26.x will not
|
with SDL 2.26.x, but programs built against SDL 2.26.x will not
|
||||||
necessarily work with 2.24.x.
|
necessarily work with 2.24.x.
|
||||||
|
|
||||||
* If the minor version (second part) is not divisible by 2
|
* If the minor version (second part) is not divisible by 2
|
||||||
(for example 2.23.x, 2.25.x), this indicates a development prerelease
|
(for example 2.23.x, 2.25.x), this indicates a development prerelease
|
||||||
of SDL that is not suitable for stable software distributions.
|
of SDL that is not suitable for stable software distributions.
|
||||||
Use with caution.
|
Use with caution.
|
||||||
|
|
||||||
* The patchlevel or micro version (third part) increases with
|
* The patchlevel or micro version (third part) increases with
|
||||||
each prerelease.
|
each prerelease.
|
||||||
|
|
||||||
* Each prerelease might add new API and/or ABI.
|
* Each prerelease might add new API and/or ABI.
|
||||||
|
|
||||||
* Prereleases are backwards-compatible with older stable branches.
|
* Prereleases are backwards-compatible with older stable branches.
|
||||||
For example, 2.25.x will be backwards-compatible with 2.24.x.
|
For example, 2.25.x will be backwards-compatible with 2.24.x.
|
||||||
|
|
||||||
* Prereleases are not guaranteed to be backwards-compatible with
|
* Prereleases are not guaranteed to be backwards-compatible with
|
||||||
each other. For example, new API or ABI added in 2.25.1
|
each other. For example, new API or ABI added in 2.25.1
|
||||||
might be removed or changed in 2.25.2.
|
might be removed or changed in 2.25.2.
|
||||||
If this would be a problem for you, please do not use prereleases.
|
If this would be a problem for you, please do not use prereleases.
|
||||||
|
|
||||||
* Only upgrade to a prerelease if you can guarantee that you will
|
* Only upgrade to a prerelease if you can guarantee that you will
|
||||||
promptly upgrade to the stable release that follows it.
|
promptly upgrade to the stable release that follows it.
|
||||||
For example, do not upgrade to 2.23.x unless you will be able to
|
For example, do not upgrade to 2.23.x unless you will be able to
|
||||||
upgrade to 2.24.0 when it becomes available.
|
upgrade to 2.24.0 when it becomes available.
|
||||||
|
|
||||||
* Software distributions that have a freeze policy (in particular Linux
|
* Software distributions that have a freeze policy (in particular Linux
|
||||||
distributions with a release cycle, such as Debian and Fedora)
|
distributions with a release cycle, such as Debian and Fedora)
|
||||||
should usually only package stable releases, and not prereleases.
|
should usually only package stable releases, and not prereleases.
|
||||||
|
|
||||||
## Before 2.23.0
|
## Before 2.23.0
|
||||||
|
|
||||||
Older versions of SDL followed a similar policy, but instead of the
|
Older versions of SDL followed a similar policy, but instead of the
|
||||||
odd/even rule applying to the minor version, it applied to the patchlevel
|
odd/even rule applying to the minor version, it applied to the patchlevel
|
||||||
(micro version, third part). For example, 2.0.22 was a stable release
|
(micro version, third part). For example, 2.0.22 was a stable release
|
||||||
and 2.0.21 was a prerelease.
|
and 2.0.21 was a prerelease.
|
||||||
|
@@ -1,114 +1,114 @@
|
|||||||
Using SDL with Microsoft Visual C++
|
Using SDL with Microsoft Visual C++
|
||||||
===================================
|
===================================
|
||||||
|
|
||||||
### by Lion Kimbro with additions by James Turk
|
### by Lion Kimbro with additions by James Turk
|
||||||
|
|
||||||
You can either use the precompiled libraries from the [SDL](https://www.libsdl.org/download.php) web site, or you can build SDL
|
You can either use the precompiled libraries from the [SDL](https://www.libsdl.org/download.php) web site, or you can build SDL
|
||||||
yourself.
|
yourself.
|
||||||
|
|
||||||
### Building SDL
|
### Building SDL
|
||||||
|
|
||||||
0. To build SDL, your machine must, at a minimum, have the DirectX9.0c SDK installed. It may or may not be retrievable from
|
0. To build SDL, your machine must, at a minimum, have the DirectX9.0c SDK installed. It may or may not be retrievable from
|
||||||
the [Microsoft](https://www.microsoft.com) website, so you might need to locate it [online](https://duckduckgo.com/?q=directx9.0c+sdk+download&t=h_&ia=web).
|
the [Microsoft](https://www.microsoft.com) website, so you might need to locate it [online](https://duckduckgo.com/?q=directx9.0c+sdk+download&t=h_&ia=web).
|
||||||
_Editor's note: I've been able to successfully build SDL using Visual Studio 2019 **without** the DX9.0c SDK_
|
_Editor's note: I've been able to successfully build SDL using Visual Studio 2019 **without** the DX9.0c SDK_
|
||||||
|
|
||||||
1. Open the Visual Studio solution file at `./VisualC/SDL.sln`.
|
1. Open the Visual Studio solution file at `./VisualC/SDL.sln`.
|
||||||
|
|
||||||
2. Your IDE will likely prompt you to upgrade this solution file to whatever later version of the IDE you're using. In the `Retarget Projects` dialog,
|
2. Your IDE will likely prompt you to upgrade this solution file to whatever later version of the IDE you're using. In the `Retarget Projects` dialog,
|
||||||
all of the affected project files should be checked allowing you to use the latest `Windows SDK Version` you have installed, along with
|
all of the affected project files should be checked allowing you to use the latest `Windows SDK Version` you have installed, along with
|
||||||
the `Platform Toolset`.
|
the `Platform Toolset`.
|
||||||
|
|
||||||
If you choose *NOT* to upgrade to use the latest `Windows SDK Version` or `Platform Toolset`, then you'll need the `Visual Studio 2010 Platform Toolset`.
|
If you choose *NOT* to upgrade to use the latest `Windows SDK Version` or `Platform Toolset`, then you'll need the `Visual Studio 2010 Platform Toolset`.
|
||||||
|
|
||||||
3. Build the `.dll` and `.lib` files by right clicking on each project in turn (Projects are listed in the _Workspace_
|
3. Build the `.dll` and `.lib` files by right clicking on each project in turn (Projects are listed in the _Workspace_
|
||||||
panel in the _FileView_ tab), and selecting `Build`.
|
panel in the _FileView_ tab), and selecting `Build`.
|
||||||
|
|
||||||
You may get a few warnings, but you should not get any errors.
|
You may get a few warnings, but you should not get any errors.
|
||||||
|
|
||||||
Later, we will refer to the following `.lib` and `.dll` files that have just been generated:
|
Later, we will refer to the following `.lib` and `.dll` files that have just been generated:
|
||||||
|
|
||||||
- `./VisualC/Win32/Debug/SDL2.dll` or `./VisualC/Win32/Release/SDL2.dll`
|
- `./VisualC/Win32/Debug/SDL2.dll` or `./VisualC/Win32/Release/SDL2.dll`
|
||||||
- `./VisualC/Win32/Debug/SDL2.lib` or `./VisualC/Win32/Release/SDL2.lib`
|
- `./VisualC/Win32/Debug/SDL2.lib` or `./VisualC/Win32/Release/SDL2.lib`
|
||||||
- `./VisualC/Win32/Debug/SDL2main.lib` or `./VisualC/Win32/Release/SDL2main.lib`
|
- `./VisualC/Win32/Debug/SDL2main.lib` or `./VisualC/Win32/Release/SDL2main.lib`
|
||||||
|
|
||||||
_Note for the `x64` versions, just replace `Win32` in the path with `x64`_
|
_Note for the `x64` versions, just replace `Win32` in the path with `x64`_
|
||||||
|
|
||||||
### Creating a Project with SDL
|
### Creating a Project with SDL
|
||||||
|
|
||||||
- Create a project as a `Win32 Application`.
|
- Create a project as a `Win32 Application`.
|
||||||
|
|
||||||
- Create a C++ file for your project.
|
- Create a C++ file for your project.
|
||||||
|
|
||||||
- Set the C runtime to `Multi-threaded DLL` in the menu:
|
- Set the C runtime to `Multi-threaded DLL` in the menu:
|
||||||
`Project|Settings|C/C++ tab|Code Generation|Runtime Library `.
|
`Project|Settings|C/C++ tab|Code Generation|Runtime Library `.
|
||||||
|
|
||||||
- Add the SDL `include` directory to your list of includes in the menu:
|
- Add the SDL `include` directory to your list of includes in the menu:
|
||||||
`Project|Settings|C/C++ tab|Preprocessor|Additional include directories `
|
`Project|Settings|C/C++ tab|Preprocessor|Additional include directories `
|
||||||
|
|
||||||
*VC7 Specific: Instead of doing this, I find it easier to add the
|
*VC7 Specific: Instead of doing this, I find it easier to add the
|
||||||
include and library directories to the list that VC7 keeps. Do this by
|
include and library directories to the list that VC7 keeps. Do this by
|
||||||
selecting Tools|Options|Projects|VC++ Directories and under the "Show
|
selecting Tools|Options|Projects|VC++ Directories and under the "Show
|
||||||
Directories For:" dropbox select "Include Files", and click the "New
|
Directories For:" dropbox select "Include Files", and click the "New
|
||||||
Directory Icon" and add the [SDLROOT]\\include directory (e.g. If you
|
Directory Icon" and add the [SDLROOT]\\include directory (e.g. If you
|
||||||
installed to c:\\SDL\\ add c:\\SDL\\include). Proceed to change the
|
installed to c:\\SDL\\ add c:\\SDL\\include). Proceed to change the
|
||||||
dropbox selection to "Library Files" and add [SDLROOT]\\lib.*
|
dropbox selection to "Library Files" and add [SDLROOT]\\lib.*
|
||||||
|
|
||||||
The "include directory" I am referring to is the `./include` folder.
|
The "include directory" I am referring to is the `./include` folder.
|
||||||
|
|
||||||
Now we're going to use the files that we had created earlier in the *Build SDL* step.
|
Now we're going to use the files that we had created earlier in the *Build SDL* step.
|
||||||
|
|
||||||
Copy the following file into your Project directory:
|
Copy the following file into your Project directory:
|
||||||
|
|
||||||
- `SDL2.dll`
|
- `SDL2.dll`
|
||||||
|
|
||||||
Add the following files to your project (It is not necessary to copy them to your project directory):
|
Add the following files to your project (It is not necessary to copy them to your project directory):
|
||||||
|
|
||||||
- `SDL2.lib`
|
- `SDL2.lib`
|
||||||
- `SDL2main.lib`
|
- `SDL2main.lib`
|
||||||
|
|
||||||
To add them to your project, right click on your project, and select
|
To add them to your project, right click on your project, and select
|
||||||
`Add files to project`.
|
`Add files to project`.
|
||||||
|
|
||||||
**Instead of adding the files to your project, it is more desirable to add them to the linker options: Project|Properties|Linker|Command Line
|
**Instead of adding the files to your project, it is more desirable to add them to the linker options: Project|Properties|Linker|Command Line
|
||||||
and type the names of the libraries to link with in the "Additional Options:" box. Note: This must be done for each build configuration
|
and type the names of the libraries to link with in the "Additional Options:" box. Note: This must be done for each build configuration
|
||||||
(e.g. Release,Debug).**
|
(e.g. Release,Debug).**
|
||||||
|
|
||||||
### Hello SDL2
|
### Hello SDL2
|
||||||
|
|
||||||
Here's a sample SDL snippet to verify everything is setup in your IDE:
|
Here's a sample SDL snippet to verify everything is setup in your IDE:
|
||||||
|
|
||||||
```
|
```
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
int main( int argc, char* argv[] )
|
int main( int argc, char* argv[] )
|
||||||
{
|
{
|
||||||
const int WIDTH = 640;
|
const int WIDTH = 640;
|
||||||
const int HEIGHT = 480;
|
const int HEIGHT = 480;
|
||||||
SDL_Window* window = NULL;
|
SDL_Window* window = NULL;
|
||||||
SDL_Renderer* renderer = NULL;
|
SDL_Renderer* renderer = NULL;
|
||||||
|
|
||||||
SDL_Init(SDL_INIT_VIDEO);
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
window = SDL_CreateWindow("SDL2 Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_SHOWN);
|
window = SDL_CreateWindow("SDL2 Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_SHOWN);
|
||||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||||
|
|
||||||
SDL_DestroyRenderer(renderer);
|
SDL_DestroyRenderer(renderer);
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### That's it!
|
### That's it!
|
||||||
|
|
||||||
I hope that this document has helped you get through the most difficult part of using the SDL: installing it.
|
I hope that this document has helped you get through the most difficult part of using the SDL: installing it.
|
||||||
Suggestions for improvements should be posted to the [Github Issues](https://github.com/libsdl-org/SDL/issues).
|
Suggestions for improvements should be posted to the [Github Issues](https://github.com/libsdl-org/SDL/issues).
|
||||||
|
|
||||||
### Credits
|
### Credits
|
||||||
|
|
||||||
Thanks to [Paulus Esterhazy](mailto:pesterhazy@gmx.net), for the work on VC++ port.
|
Thanks to [Paulus Esterhazy](mailto:pesterhazy@gmx.net), for the work on VC++ port.
|
||||||
|
|
||||||
This document was originally called "VisualC.txt", and was written by [Sam Lantinga](mailto:slouken@libsdl.org).
|
This document was originally called "VisualC.txt", and was written by [Sam Lantinga](mailto:slouken@libsdl.org).
|
||||||
|
|
||||||
Later, it was converted to HTML and expanded into the document that you see today by [Lion Kimbro](mailto:snowlion@sprynet.com).
|
Later, it was converted to HTML and expanded into the document that you see today by [Lion Kimbro](mailto:snowlion@sprynet.com).
|
||||||
|
|
||||||
Minor Fixes and Visual C++ 7 Information (In Green) was added by [James Turk](mailto:james@conceptofzero.net)
|
Minor Fixes and Visual C++ 7 Information (In Green) was added by [James Turk](mailto:james@conceptofzero.net)
|
||||||
|
@@ -1,33 +1,33 @@
|
|||||||
PS Vita
|
PS Vita
|
||||||
=======
|
=======
|
||||||
SDL port for the Sony Playstation Vita and Sony Playstation TV
|
SDL port for the Sony Playstation Vita and Sony Playstation TV
|
||||||
|
|
||||||
Credit to
|
Credit to
|
||||||
* xerpi, cpasjuste and rsn8887 for initial (vita2d) port
|
* xerpi, cpasjuste and rsn8887 for initial (vita2d) port
|
||||||
* vitasdk/dolcesdk devs
|
* vitasdk/dolcesdk devs
|
||||||
* CBPS discord (Namely Graphene and SonicMastr)
|
* CBPS discord (Namely Graphene and SonicMastr)
|
||||||
|
|
||||||
Building
|
Building
|
||||||
--------
|
--------
|
||||||
To build for the PSVita, make sure you have vitasdk and cmake installed and run:
|
To build for the PSVita, make sure you have vitasdk and cmake installed and run:
|
||||||
```
|
```
|
||||||
cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake -DCMAKE_BUILD_TYPE=Release
|
cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake -DCMAKE_BUILD_TYPE=Release
|
||||||
cmake --build build
|
cmake --build build
|
||||||
cmake --install build
|
cmake --install build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
Notes
|
Notes
|
||||||
-----
|
-----
|
||||||
* gles1/gles2 support and renderers are disabled by default and can be enabled by configuring with `-DVIDEO_VITA_PVR=ON`
|
* gles1/gles2 support and renderers are disabled by default and can be enabled by configuring with `-DVIDEO_VITA_PVR=ON`
|
||||||
These renderers support 720p and 1080i resolutions. These can be specified with:
|
These renderers support 720p and 1080i resolutions. These can be specified with:
|
||||||
`SDL_setenv("VITA_RESOLUTION", "720", 1);` and `SDL_setenv("VITA_RESOLUTION", "1080", 1);`
|
`SDL_setenv("VITA_RESOLUTION", "720", 1);` and `SDL_setenv("VITA_RESOLUTION", "1080", 1);`
|
||||||
* Desktop GL 1.X and 2.X support and renderers are also disabled by default and also can be enabled with `-DVIDEO_VITA_PVR=ON` as long as gl4es4vita is present in your SDK.
|
* Desktop GL 1.X and 2.X support and renderers are also disabled by default and also can be enabled with `-DVIDEO_VITA_PVR=ON` as long as gl4es4vita is present in your SDK.
|
||||||
They support the same resolutions as the gles1/gles2 backends and require specifying `SDL_setenv("VITA_PVR_OGL", "1", 1);`
|
They support the same resolutions as the gles1/gles2 backends and require specifying `SDL_setenv("VITA_PVR_OGL", "1", 1);`
|
||||||
anytime before video subsystem initialization.
|
anytime before video subsystem initialization.
|
||||||
* gles2 support via PIB is disabled by default and can be enabled by configuring with `-DVIDEO_VITA_PIB=ON`
|
* gles2 support via PIB is disabled by default and can be enabled by configuring with `-DVIDEO_VITA_PIB=ON`
|
||||||
* By default SDL emits mouse events for touch events on every touchscreen.
|
* By default SDL emits mouse events for touch events on every touchscreen.
|
||||||
Vita has two touchscreens, so it's recommended to use `SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");` and handle touch events instead.
|
Vita has two touchscreens, so it's recommended to use `SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");` and handle touch events instead.
|
||||||
Individual touchscreens can be disabled with:
|
Individual touchscreens can be disabled with:
|
||||||
`SDL_setenv("VITA_DISABLE_TOUCH_FRONT", "1", 1);` and `SDL_setenv("VITA_DISABLE_TOUCH_BACK", "1", 1);`
|
`SDL_setenv("VITA_DISABLE_TOUCH_FRONT", "1", 1);` and `SDL_setenv("VITA_DISABLE_TOUCH_BACK", "1", 1);`
|
||||||
* Support for L2/R2/R3/R3 buttons, haptic feedback and gamepad led only available on PSTV, or when using external ds4 gamepad on vita.
|
* Support for L2/R2/R3/R3 buttons, haptic feedback and gamepad led only available on PSTV, or when using external ds4 gamepad on vita.
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
WinCE
|
WinCE
|
||||||
=====
|
=====
|
||||||
|
|
||||||
Windows CE is no longer supported by SDL.
|
Windows CE is no longer supported by SDL.
|
||||||
|
|
||||||
We have left the CE support in SDL 1.2 for those that must have it, and we
|
We have left the CE support in SDL 1.2 for those that must have it, and we
|
||||||
have support for Windows Phone 8 and WinRT in SDL2, as of SDL 2.0.3.
|
have support for Windows Phone 8 and WinRT in SDL2, as of SDL 2.0.3.
|
||||||
|
|
||||||
--ryan.
|
--ryan.
|
||||||
|
|
||||||
|
@@ -1,58 +1,58 @@
|
|||||||
# Windows
|
# Windows
|
||||||
|
|
||||||
## LLVM and Intel C++ compiler support
|
## LLVM and Intel C++ compiler support
|
||||||
|
|
||||||
SDL will build with the Visual Studio project files with LLVM-based compilers, such as the Intel oneAPI C++
|
SDL will build with the Visual Studio project files with LLVM-based compilers, such as the Intel oneAPI C++
|
||||||
compiler, but you'll have to manually add the "-msse3" command line option
|
compiler, but you'll have to manually add the "-msse3" command line option
|
||||||
to at least the SDL_audiocvt.c source file, and possibly others. This may
|
to at least the SDL_audiocvt.c source file, and possibly others. This may
|
||||||
not be necessary if you build SDL with CMake instead of the included Visual
|
not be necessary if you build SDL with CMake instead of the included Visual
|
||||||
Studio solution.
|
Studio solution.
|
||||||
|
|
||||||
Details are here: https://github.com/libsdl-org/SDL/issues/5186
|
Details are here: https://github.com/libsdl-org/SDL/issues/5186
|
||||||
|
|
||||||
|
|
||||||
## OpenGL ES 2.x support
|
## OpenGL ES 2.x support
|
||||||
|
|
||||||
SDL has support for OpenGL ES 2.x under Windows via two alternative
|
SDL has support for OpenGL ES 2.x under Windows via two alternative
|
||||||
implementations.
|
implementations.
|
||||||
|
|
||||||
The most straightforward method consists in running your app in a system with
|
The most straightforward method consists in running your app in a system with
|
||||||
a graphic card paired with a relatively recent (as of November of 2013) driver
|
a graphic card paired with a relatively recent (as of November of 2013) driver
|
||||||
which supports the WGL_EXT_create_context_es2_profile extension. Vendors known
|
which supports the WGL_EXT_create_context_es2_profile extension. Vendors known
|
||||||
to ship said extension on Windows currently include nVidia and Intel.
|
to ship said extension on Windows currently include nVidia and Intel.
|
||||||
|
|
||||||
The other method involves using the
|
The other method involves using the
|
||||||
[ANGLE library](https://code.google.com/p/angleproject/). If an OpenGL ES 2.x
|
[ANGLE library](https://code.google.com/p/angleproject/). If an OpenGL ES 2.x
|
||||||
context is requested and no WGL_EXT_create_context_es2_profile extension is
|
context is requested and no WGL_EXT_create_context_es2_profile extension is
|
||||||
found, SDL will try to load the libEGL.dll library provided by ANGLE.
|
found, SDL will try to load the libEGL.dll library provided by ANGLE.
|
||||||
|
|
||||||
To obtain the ANGLE binaries, you can either compile from source from
|
To obtain the ANGLE binaries, you can either compile from source from
|
||||||
https://chromium.googlesource.com/angle/angle or copy the relevant binaries
|
https://chromium.googlesource.com/angle/angle or copy the relevant binaries
|
||||||
from a recent Chrome/Chromium install for Windows. The files you need are:
|
from a recent Chrome/Chromium install for Windows. The files you need are:
|
||||||
|
|
||||||
- libEGL.dll
|
- libEGL.dll
|
||||||
- libGLESv2.dll
|
- libGLESv2.dll
|
||||||
- d3dcompiler_46.dll (supports Windows Vista or later, better shader
|
- d3dcompiler_46.dll (supports Windows Vista or later, better shader
|
||||||
compiler) *or* d3dcompiler_43.dll (supports Windows XP or later)
|
compiler) *or* d3dcompiler_43.dll (supports Windows XP or later)
|
||||||
|
|
||||||
If you compile ANGLE from source, you can configure it so it does not need the
|
If you compile ANGLE from source, you can configure it so it does not need the
|
||||||
d3dcompiler_* DLL at all (for details on this, see their documentation).
|
d3dcompiler_* DLL at all (for details on this, see their documentation).
|
||||||
However, by default SDL will try to preload the d3dcompiler_46.dll to
|
However, by default SDL will try to preload the d3dcompiler_46.dll to
|
||||||
comply with ANGLE's requirements. If you wish SDL to preload
|
comply with ANGLE's requirements. If you wish SDL to preload
|
||||||
d3dcompiler_43.dll (to support Windows XP) or to skip this step at all, you
|
d3dcompiler_43.dll (to support Windows XP) or to skip this step at all, you
|
||||||
can use the SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more
|
can use the SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more
|
||||||
details).
|
details).
|
||||||
|
|
||||||
Known Bugs:
|
Known Bugs:
|
||||||
|
|
||||||
- SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears
|
- SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears
|
||||||
that there's a bug in the library which prevents the window contents from
|
that there's a bug in the library which prevents the window contents from
|
||||||
refreshing if this is set to anything other than the default value.
|
refreshing if this is set to anything other than the default value.
|
||||||
|
|
||||||
## Vulkan Surface Support
|
## Vulkan Surface Support
|
||||||
|
|
||||||
Support for creating Vulkan surfaces is configured on by default. To disable
|
Support for creating Vulkan surfaces is configured on by default. To disable
|
||||||
it change the value of `SDL_VIDEO_VULKAN` to 0 in `SDL_config_windows.h`. You
|
it change the value of `SDL_VIDEO_VULKAN` to 0 in `SDL_config_windows.h`. You
|
||||||
must install the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) in order to
|
must install the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) in order to
|
||||||
use Vulkan graphics in your application.
|
use Vulkan graphics in your application.
|
||||||
|
|
||||||
|
1038
docs/README-winrt.md
1038
docs/README-winrt.md
File diff suppressed because it is too large
Load Diff
@@ -257,8 +257,9 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A type representing an atomic integer value. It is a struct
|
* A type representing an atomic integer value.
|
||||||
* so people don't accidentally use numeric operations on it.
|
*
|
||||||
|
* It is a struct so people don't accidentally use numeric operations on it.
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_atomic_t {
|
typedef struct SDL_atomic_t {
|
||||||
int value;
|
int value;
|
||||||
|
@@ -166,16 +166,19 @@ typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream,
|
|||||||
int len);
|
int len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The calculated values in this structure are calculated by SDL_OpenAudio().
|
* The calculated values in this structure are calculated by SDL_OpenAudio().
|
||||||
*
|
*
|
||||||
* For multi-channel audio, the default SDL channel mapping is:
|
* For multi-channel audio, the default SDL channel mapping is:
|
||||||
* 2: FL FR (stereo)
|
*
|
||||||
* 3: FL FR LFE (2.1 surround)
|
* ```
|
||||||
* 4: FL FR BL BR (quad)
|
* 2: FL FR (stereo)
|
||||||
* 5: FL FR LFE BL BR (4.1 surround)
|
* 3: FL FR LFE (2.1 surround)
|
||||||
* 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
|
* 4: FL FR BL BR (quad)
|
||||||
* 7: FL FR FC LFE BC SL SR (6.1 surround)
|
* 5: FL FR LFE BL BR (4.1 surround)
|
||||||
* 8: FL FR FC LFE BL BR SL SR (7.1 surround)
|
* 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
|
||||||
|
* 7: FL FR FC LFE BC SL SR (6.1 surround)
|
||||||
|
* 8: FL FR FC LFE BL BR SL SR (7.1 surround)
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_AudioSpec
|
typedef struct SDL_AudioSpec
|
||||||
{
|
{
|
||||||
@@ -196,11 +199,11 @@ typedef void (SDLCALL * SDL_AudioFilter) (struct SDL_AudioCVT * cvt,
|
|||||||
SDL_AudioFormat format);
|
SDL_AudioFormat format);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Upper limit of filters in SDL_AudioCVT
|
* Upper limit of filters in SDL_AudioCVT
|
||||||
*
|
*
|
||||||
* The maximum number of SDL_AudioFilter functions in SDL_AudioCVT is
|
* The maximum number of SDL_AudioFilter functions in SDL_AudioCVT is
|
||||||
* currently limited to 9. The SDL_AudioCVT.filters array has 10 pointers,
|
* currently limited to 9. The SDL_AudioCVT.filters array has 10 pointers, one
|
||||||
* one of which is the terminating NULL pointer.
|
* of which is the terminating NULL pointer.
|
||||||
*/
|
*/
|
||||||
#define SDL_AUDIOCVT_MAX_FILTERS 9
|
#define SDL_AUDIOCVT_MAX_FILTERS 9
|
||||||
|
|
||||||
@@ -408,13 +411,13 @@ extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired,
|
|||||||
SDL_AudioSpec * obtained);
|
SDL_AudioSpec * obtained);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SDL Audio Device IDs.
|
* SDL Audio Device IDs.
|
||||||
*
|
*
|
||||||
* A successful call to SDL_OpenAudio() is always device id 1, and legacy
|
* A successful call to SDL_OpenAudio() is always device id 1, and legacy SDL
|
||||||
* SDL audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls
|
* audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls
|
||||||
* always returns devices >= 2 on success. The legacy calls are good both
|
* always returns devices >= 2 on success. The legacy calls are good both for
|
||||||
* for backwards compatibility and when you don't care about multiple,
|
* backwards compatibility and when you don't care about multiple, specific,
|
||||||
* specific, or capture devices.
|
* or capture devices.
|
||||||
*/
|
*/
|
||||||
typedef Uint32 SDL_AudioDeviceID;
|
typedef Uint32 SDL_AudioDeviceID;
|
||||||
|
|
||||||
@@ -874,8 +877,9 @@ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
|
|||||||
Uint32 * audio_len);
|
Uint32 * audio_len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a WAV from a file.
|
* Loads a WAV from a file.
|
||||||
* Compatibility convenience function.
|
*
|
||||||
|
* Compatibility convenience function.
|
||||||
*/
|
*/
|
||||||
#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
|
#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
|
||||||
SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len)
|
SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len)
|
||||||
|
@@ -56,6 +56,12 @@ extern __inline int _SDL_bsr_watcom(Uint32);
|
|||||||
modify exact [eax] nomemory;
|
modify exact [eax] nomemory;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this function to get the index of the most significant (set) bit in a
|
||||||
|
*
|
||||||
|
* \param x the number to find the MSB of
|
||||||
|
* \returns the index of the most significant bit of x, or -1 if x is 0.
|
||||||
|
*/
|
||||||
SDL_FORCE_INLINE int
|
SDL_FORCE_INLINE int
|
||||||
SDL_MostSignificantBitIndex32(Uint32 x)
|
SDL_MostSignificantBitIndex32(Uint32 x)
|
||||||
{
|
{
|
||||||
|
@@ -35,7 +35,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The blend mode used in SDL_RenderCopy() and drawing operations.
|
* The blend mode used in SDL_RenderCopy() and drawing operations.
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_BlendMode
|
typedef enum SDL_BlendMode
|
||||||
{
|
{
|
||||||
@@ -60,7 +60,8 @@ typedef enum SDL_BlendMode
|
|||||||
} SDL_BlendMode;
|
} SDL_BlendMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The blend operation used when combining source and destination pixel components
|
* The blend operation used when combining source and destination pixel
|
||||||
|
* components
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_BlendOperation
|
typedef enum SDL_BlendOperation
|
||||||
{
|
{
|
||||||
@@ -72,7 +73,7 @@ typedef enum SDL_BlendOperation
|
|||||||
} SDL_BlendOperation;
|
} SDL_BlendOperation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The normalized factor used to multiply pixel components
|
* The normalized factor used to multiply pixel components
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_BlendFactor
|
typedef enum SDL_BlendFactor
|
||||||
{
|
{
|
||||||
|
@@ -180,6 +180,16 @@ extern __inline Uint16 SDL_Swap16(Uint16);
|
|||||||
parm [ax] \
|
parm [ax] \
|
||||||
modify [ax];
|
modify [ax];
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this function to swap the byte order of a 16-bit value.
|
||||||
|
*
|
||||||
|
* \param x the value to be swapped
|
||||||
|
* \returns the swapped value.
|
||||||
|
*
|
||||||
|
* \sa SDL_SwapBE16
|
||||||
|
* \sa SDL_SwapLE16
|
||||||
|
*/
|
||||||
SDL_FORCE_INLINE Uint16
|
SDL_FORCE_INLINE Uint16
|
||||||
SDL_Swap16(Uint16 x)
|
SDL_Swap16(Uint16 x)
|
||||||
{
|
{
|
||||||
@@ -231,6 +241,16 @@ extern __inline Uint32 SDL_Swap32(Uint32);
|
|||||||
parm [eax] \
|
parm [eax] \
|
||||||
modify [eax];
|
modify [eax];
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this function to swap the byte order of a 32-bit value.
|
||||||
|
*
|
||||||
|
* \param x the value to be swapped
|
||||||
|
* \returns the swapped value.
|
||||||
|
*
|
||||||
|
* \sa SDL_SwapBE32
|
||||||
|
* \sa SDL_SwapLE32
|
||||||
|
*/
|
||||||
SDL_FORCE_INLINE Uint32
|
SDL_FORCE_INLINE Uint32
|
||||||
SDL_Swap32(Uint32 x)
|
SDL_Swap32(Uint32 x)
|
||||||
{
|
{
|
||||||
@@ -276,6 +296,16 @@ extern __inline Uint64 SDL_Swap64(Uint64);
|
|||||||
parm [eax edx] \
|
parm [eax edx] \
|
||||||
modify [eax edx];
|
modify [eax edx];
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this function to swap the byte order of a 64-bit value.
|
||||||
|
*
|
||||||
|
* \param x the value to be swapped
|
||||||
|
* \returns the swapped value.
|
||||||
|
*
|
||||||
|
* \sa SDL_SwapBE64
|
||||||
|
* \sa SDL_SwapLE64
|
||||||
|
*/
|
||||||
SDL_FORCE_INLINE Uint64
|
SDL_FORCE_INLINE Uint64
|
||||||
SDL_Swap64(Uint64 x)
|
SDL_Swap64(Uint64 x)
|
||||||
{
|
{
|
||||||
@@ -293,6 +323,15 @@ SDL_Swap64(Uint64 x)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this function to swap the byte order of a floating point value.
|
||||||
|
*
|
||||||
|
* \param x the value to be swapped
|
||||||
|
* \returns the swapped value.
|
||||||
|
*
|
||||||
|
* \sa SDL_SwapFloatBE
|
||||||
|
* \sa SDL_SwapFloatLE
|
||||||
|
*/
|
||||||
SDL_FORCE_INLINE float
|
SDL_FORCE_INLINE float
|
||||||
SDL_SwapFloat(float x)
|
SDL_SwapFloat(float x)
|
||||||
{
|
{
|
||||||
|
@@ -167,7 +167,7 @@ typedef enum SDL_EventType
|
|||||||
/* Internal events */
|
/* Internal events */
|
||||||
SDL_POLLSENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */
|
SDL_POLLSENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */
|
||||||
|
|
||||||
/** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
|
/** Events SDL_USEREVENT through SDL_LASTEVENT are for your use,
|
||||||
* and should be allocated with SDL_RegisterEvents()
|
* and should be allocated with SDL_RegisterEvents()
|
||||||
*/
|
*/
|
||||||
SDL_USEREVENT = 0x8000,
|
SDL_USEREVENT = 0x8000,
|
||||||
@@ -179,7 +179,7 @@ typedef enum SDL_EventType
|
|||||||
} SDL_EventType;
|
} SDL_EventType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Fields shared by every event
|
* Fields shared by every event
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_CommonEvent
|
typedef struct SDL_CommonEvent
|
||||||
{
|
{
|
||||||
@@ -188,14 +188,14 @@ typedef struct SDL_CommonEvent
|
|||||||
} SDL_CommonEvent;
|
} SDL_CommonEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Display state change event data (event.display.*)
|
* Display state change event data (event.display.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_DisplayEvent
|
typedef struct SDL_DisplayEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_DISPLAYEVENT */
|
Uint32 type; /**< SDL_DISPLAYEVENT */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
Uint32 display; /**< The associated display index */
|
Uint32 display; /**< The associated display index */
|
||||||
Uint8 event; /**< ::SDL_DisplayEventID */
|
Uint8 event; /**< SDL_DisplayEventID */
|
||||||
Uint8 padding1;
|
Uint8 padding1;
|
||||||
Uint8 padding2;
|
Uint8 padding2;
|
||||||
Uint8 padding3;
|
Uint8 padding3;
|
||||||
@@ -203,14 +203,14 @@ typedef struct SDL_DisplayEvent
|
|||||||
} SDL_DisplayEvent;
|
} SDL_DisplayEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Window state change event data (event.window.*)
|
* Window state change event data (event.window.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_WindowEvent
|
typedef struct SDL_WindowEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_WINDOWEVENT */
|
Uint32 type; /**< SDL_WINDOWEVENT */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
Uint32 windowID; /**< The associated window */
|
Uint32 windowID; /**< The associated window */
|
||||||
Uint8 event; /**< ::SDL_WindowEventID */
|
Uint8 event; /**< SDL_WindowEventID */
|
||||||
Uint8 padding1;
|
Uint8 padding1;
|
||||||
Uint8 padding2;
|
Uint8 padding2;
|
||||||
Uint8 padding3;
|
Uint8 padding3;
|
||||||
@@ -219,14 +219,14 @@ typedef struct SDL_WindowEvent
|
|||||||
} SDL_WindowEvent;
|
} SDL_WindowEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Keyboard button event structure (event.key.*)
|
* Keyboard button event structure (event.key.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_KeyboardEvent
|
typedef struct SDL_KeyboardEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
|
Uint32 type; /**< SDL_KEYDOWN or SDL_KEYUP */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
Uint32 windowID; /**< The window with keyboard focus, if any */
|
Uint32 windowID; /**< The window with keyboard focus, if any */
|
||||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
|
||||||
Uint8 repeat; /**< Non-zero if this is a key repeat */
|
Uint8 repeat; /**< Non-zero if this is a key repeat */
|
||||||
Uint8 padding2;
|
Uint8 padding2;
|
||||||
Uint8 padding3;
|
Uint8 padding3;
|
||||||
@@ -234,12 +234,13 @@ typedef struct SDL_KeyboardEvent
|
|||||||
} SDL_KeyboardEvent;
|
} SDL_KeyboardEvent;
|
||||||
|
|
||||||
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
|
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Keyboard text editing event structure (event.edit.*)
|
* Keyboard text editing event structure (event.edit.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_TextEditingEvent
|
typedef struct SDL_TextEditingEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_TEXTEDITING */
|
Uint32 type; /**< SDL_TEXTEDITING */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
Uint32 windowID; /**< The window with keyboard focus, if any */
|
Uint32 windowID; /**< The window with keyboard focus, if any */
|
||||||
char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
|
char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
|
||||||
@@ -248,12 +249,12 @@ typedef struct SDL_TextEditingEvent
|
|||||||
} SDL_TextEditingEvent;
|
} SDL_TextEditingEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Extended keyboard text editing event structure (event.editExt.*) when text would be
|
* Extended keyboard text editing event structure (event.editExt.*) when text
|
||||||
* truncated if stored in the text buffer SDL_TextEditingEvent
|
* would be truncated if stored in the text buffer SDL_TextEditingEvent
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_TextEditingExtEvent
|
typedef struct SDL_TextEditingExtEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_TEXTEDITING_EXT */
|
Uint32 type; /**< SDL_TEXTEDITING_EXT */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
Uint32 windowID; /**< The window with keyboard focus, if any */
|
Uint32 windowID; /**< The window with keyboard focus, if any */
|
||||||
char* text; /**< The editing text, which should be freed with SDL_free(), and will not be NULL */
|
char* text; /**< The editing text, which should be freed with SDL_free(), and will not be NULL */
|
||||||
@@ -262,23 +263,24 @@ typedef struct SDL_TextEditingExtEvent
|
|||||||
} SDL_TextEditingExtEvent;
|
} SDL_TextEditingExtEvent;
|
||||||
|
|
||||||
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
|
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Keyboard text input event structure (event.text.*)
|
* Keyboard text input event structure (event.text.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_TextInputEvent
|
typedef struct SDL_TextInputEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_TEXTINPUT */
|
Uint32 type; /**< SDL_TEXTINPUT */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
Uint32 windowID; /**< The window with keyboard focus, if any */
|
Uint32 windowID; /**< The window with keyboard focus, if any */
|
||||||
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */
|
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */
|
||||||
} SDL_TextInputEvent;
|
} SDL_TextInputEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Mouse motion event structure (event.motion.*)
|
* Mouse motion event structure (event.motion.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_MouseMotionEvent
|
typedef struct SDL_MouseMotionEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_MOUSEMOTION */
|
Uint32 type; /**< SDL_MOUSEMOTION */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||||
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
||||||
@@ -290,16 +292,16 @@ typedef struct SDL_MouseMotionEvent
|
|||||||
} SDL_MouseMotionEvent;
|
} SDL_MouseMotionEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Mouse button event structure (event.button.*)
|
* Mouse button event structure (event.button.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_MouseButtonEvent
|
typedef struct SDL_MouseButtonEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
|
Uint32 type; /**< SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||||
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
||||||
Uint8 button; /**< The mouse button index */
|
Uint8 button; /**< The mouse button index */
|
||||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
|
||||||
Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */
|
Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */
|
||||||
Uint8 padding1;
|
Uint8 padding1;
|
||||||
Sint32 x; /**< X coordinate, relative to window */
|
Sint32 x; /**< X coordinate, relative to window */
|
||||||
@@ -307,11 +309,11 @@ typedef struct SDL_MouseButtonEvent
|
|||||||
} SDL_MouseButtonEvent;
|
} SDL_MouseButtonEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Mouse wheel event structure (event.wheel.*)
|
* Mouse wheel event structure (event.wheel.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_MouseWheelEvent
|
typedef struct SDL_MouseWheelEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_MOUSEWHEEL */
|
Uint32 type; /**< SDL_MOUSEWHEEL */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||||
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
||||||
@@ -325,11 +327,11 @@ typedef struct SDL_MouseWheelEvent
|
|||||||
} SDL_MouseWheelEvent;
|
} SDL_MouseWheelEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Joystick axis motion event structure (event.jaxis.*)
|
* Joystick axis motion event structure (event.jaxis.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_JoyAxisEvent
|
typedef struct SDL_JoyAxisEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_JOYAXISMOTION */
|
Uint32 type; /**< SDL_JOYAXISMOTION */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
SDL_JoystickID which; /**< The joystick instance id */
|
SDL_JoystickID which; /**< The joystick instance id */
|
||||||
Uint8 axis; /**< The joystick axis index */
|
Uint8 axis; /**< The joystick axis index */
|
||||||
@@ -341,11 +343,11 @@ typedef struct SDL_JoyAxisEvent
|
|||||||
} SDL_JoyAxisEvent;
|
} SDL_JoyAxisEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Joystick trackball motion event structure (event.jball.*)
|
* Joystick trackball motion event structure (event.jball.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_JoyBallEvent
|
typedef struct SDL_JoyBallEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_JOYBALLMOTION */
|
Uint32 type; /**< SDL_JOYBALLMOTION */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
SDL_JoystickID which; /**< The joystick instance id */
|
SDL_JoystickID which; /**< The joystick instance id */
|
||||||
Uint8 ball; /**< The joystick trackball index */
|
Uint8 ball; /**< The joystick trackball index */
|
||||||
@@ -357,18 +359,18 @@ typedef struct SDL_JoyBallEvent
|
|||||||
} SDL_JoyBallEvent;
|
} SDL_JoyBallEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Joystick hat position change event structure (event.jhat.*)
|
* Joystick hat position change event structure (event.jhat.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_JoyHatEvent
|
typedef struct SDL_JoyHatEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_JOYHATMOTION */
|
Uint32 type; /**< SDL_JOYHATMOTION */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
SDL_JoystickID which; /**< The joystick instance id */
|
SDL_JoystickID which; /**< The joystick instance id */
|
||||||
Uint8 hat; /**< The joystick hat index */
|
Uint8 hat; /**< The joystick hat index */
|
||||||
Uint8 value; /**< The hat position value.
|
Uint8 value; /**< The hat position value.
|
||||||
* \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
|
* \sa SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP
|
||||||
* \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
|
* \sa SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT
|
||||||
* \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
|
* \sa SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN
|
||||||
*
|
*
|
||||||
* Note that zero means the POV is centered.
|
* Note that zero means the POV is centered.
|
||||||
*/
|
*/
|
||||||
@@ -377,46 +379,46 @@ typedef struct SDL_JoyHatEvent
|
|||||||
} SDL_JoyHatEvent;
|
} SDL_JoyHatEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Joystick button event structure (event.jbutton.*)
|
* Joystick button event structure (event.jbutton.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_JoyButtonEvent
|
typedef struct SDL_JoyButtonEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
|
Uint32 type; /**< SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
SDL_JoystickID which; /**< The joystick instance id */
|
SDL_JoystickID which; /**< The joystick instance id */
|
||||||
Uint8 button; /**< The joystick button index */
|
Uint8 button; /**< The joystick button index */
|
||||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
|
||||||
Uint8 padding1;
|
Uint8 padding1;
|
||||||
Uint8 padding2;
|
Uint8 padding2;
|
||||||
} SDL_JoyButtonEvent;
|
} SDL_JoyButtonEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Joystick device event structure (event.jdevice.*)
|
* Joystick device event structure (event.jdevice.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_JoyDeviceEvent
|
typedef struct SDL_JoyDeviceEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */
|
Uint32 type; /**< SDL_JOYDEVICEADDED or SDL_JOYDEVICEREMOVED */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
|
Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
|
||||||
} SDL_JoyDeviceEvent;
|
} SDL_JoyDeviceEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Joysick battery level change event structure (event.jbattery.*)
|
* Joysick battery level change event structure (event.jbattery.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_JoyBatteryEvent
|
typedef struct SDL_JoyBatteryEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_JOYBATTERYUPDATED */
|
Uint32 type; /**< SDL_JOYBATTERYUPDATED */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
SDL_JoystickID which; /**< The joystick instance id */
|
SDL_JoystickID which; /**< The joystick instance id */
|
||||||
SDL_JoystickPowerLevel level; /**< The joystick battery level */
|
SDL_JoystickPowerLevel level; /**< The joystick battery level */
|
||||||
} SDL_JoyBatteryEvent;
|
} SDL_JoyBatteryEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Game controller axis motion event structure (event.caxis.*)
|
* Game controller axis motion event structure (event.caxis.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_ControllerAxisEvent
|
typedef struct SDL_ControllerAxisEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */
|
Uint32 type; /**< SDL_CONTROLLERAXISMOTION */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
SDL_JoystickID which; /**< The joystick instance id */
|
SDL_JoystickID which; /**< The joystick instance id */
|
||||||
Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */
|
Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */
|
||||||
@@ -429,36 +431,36 @@ typedef struct SDL_ControllerAxisEvent
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Game controller button event structure (event.cbutton.*)
|
* Game controller button event structure (event.cbutton.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_ControllerButtonEvent
|
typedef struct SDL_ControllerButtonEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */
|
Uint32 type; /**< SDL_CONTROLLERBUTTONDOWN or SDL_CONTROLLERBUTTONUP */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
SDL_JoystickID which; /**< The joystick instance id */
|
SDL_JoystickID which; /**< The joystick instance id */
|
||||||
Uint8 button; /**< The controller button (SDL_GameControllerButton) */
|
Uint8 button; /**< The controller button (SDL_GameControllerButton) */
|
||||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
|
||||||
Uint8 padding1;
|
Uint8 padding1;
|
||||||
Uint8 padding2;
|
Uint8 padding2;
|
||||||
} SDL_ControllerButtonEvent;
|
} SDL_ControllerButtonEvent;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Controller device event structure (event.cdevice.*)
|
* Controller device event structure (event.cdevice.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_ControllerDeviceEvent
|
typedef struct SDL_ControllerDeviceEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, ::SDL_CONTROLLERDEVICEREMAPPED, or ::SDL_CONTROLLERSTEAMHANDLEUPDATED */
|
Uint32 type; /**< SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED, SDL_CONTROLLERDEVICEREMAPPED, or SDL_CONTROLLERSTEAMHANDLEUPDATED */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
|
Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
|
||||||
} SDL_ControllerDeviceEvent;
|
} SDL_ControllerDeviceEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Game controller touchpad event structure (event.ctouchpad.*)
|
* Game controller touchpad event structure (event.ctouchpad.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_ControllerTouchpadEvent
|
typedef struct SDL_ControllerTouchpadEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_CONTROLLERTOUCHPADDOWN or ::SDL_CONTROLLERTOUCHPADMOTION or ::SDL_CONTROLLERTOUCHPADUP */
|
Uint32 type; /**< SDL_CONTROLLERTOUCHPADDOWN or SDL_CONTROLLERTOUCHPADMOTION or SDL_CONTROLLERTOUCHPADUP */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
SDL_JoystickID which; /**< The joystick instance id */
|
SDL_JoystickID which; /**< The joystick instance id */
|
||||||
Sint32 touchpad; /**< The index of the touchpad */
|
Sint32 touchpad; /**< The index of the touchpad */
|
||||||
@@ -469,24 +471,24 @@ typedef struct SDL_ControllerTouchpadEvent
|
|||||||
} SDL_ControllerTouchpadEvent;
|
} SDL_ControllerTouchpadEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Game controller sensor event structure (event.csensor.*)
|
* Game controller sensor event structure (event.csensor.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_ControllerSensorEvent
|
typedef struct SDL_ControllerSensorEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_CONTROLLERSENSORUPDATE */
|
Uint32 type; /**< SDL_CONTROLLERSENSORUPDATE */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
SDL_JoystickID which; /**< The joystick instance id */
|
SDL_JoystickID which; /**< The joystick instance id */
|
||||||
Sint32 sensor; /**< The type of the sensor, one of the values of ::SDL_SensorType */
|
Sint32 sensor; /**< The type of the sensor, one of the values of SDL_SensorType */
|
||||||
float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
|
float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
|
||||||
Uint64 timestamp_us; /**< The timestamp of the sensor reading in microseconds, if the hardware provides this information. */
|
Uint64 timestamp_us; /**< The timestamp of the sensor reading in microseconds, if the hardware provides this information. */
|
||||||
} SDL_ControllerSensorEvent;
|
} SDL_ControllerSensorEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Audio device event structure (event.adevice.*)
|
* Audio device event structure (event.adevice.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_AudioDeviceEvent
|
typedef struct SDL_AudioDeviceEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED */
|
Uint32 type; /**< SDL_AUDIODEVICEADDED, or SDL_AUDIODEVICEREMOVED */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
Uint32 which; /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */
|
Uint32 which; /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */
|
||||||
Uint8 iscapture; /**< zero if an output device, non-zero if a capture device. */
|
Uint8 iscapture; /**< zero if an output device, non-zero if a capture device. */
|
||||||
@@ -497,11 +499,11 @@ typedef struct SDL_AudioDeviceEvent
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Touch finger event structure (event.tfinger.*)
|
* Touch finger event structure (event.tfinger.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_TouchFingerEvent
|
typedef struct SDL_TouchFingerEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */
|
Uint32 type; /**< SDL_FINGERMOTION or SDL_FINGERDOWN or SDL_FINGERUP */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
SDL_TouchID touchId; /**< The touch device id */
|
SDL_TouchID touchId; /**< The touch device id */
|
||||||
SDL_FingerID fingerId;
|
SDL_FingerID fingerId;
|
||||||
@@ -515,11 +517,11 @@ typedef struct SDL_TouchFingerEvent
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Multiple Finger Gesture Event (event.mgesture.*)
|
* Multiple Finger Gesture Event (event.mgesture.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_MultiGestureEvent
|
typedef struct SDL_MultiGestureEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_MULTIGESTURE */
|
Uint32 type; /**< SDL_MULTIGESTURE */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
SDL_TouchID touchId; /**< The touch device id */
|
SDL_TouchID touchId; /**< The touch device id */
|
||||||
float dTheta;
|
float dTheta;
|
||||||
@@ -532,11 +534,11 @@ typedef struct SDL_MultiGestureEvent
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Dollar Gesture Event (event.dgesture.*)
|
* Dollar Gesture Event (event.dgesture.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_DollarGestureEvent
|
typedef struct SDL_DollarGestureEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_DOLLARGESTURE or ::SDL_DOLLARRECORD */
|
Uint32 type; /**< SDL_DOLLARGESTURE or SDL_DOLLARRECORD */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
SDL_TouchID touchId; /**< The touch device id */
|
SDL_TouchID touchId; /**< The touch device id */
|
||||||
SDL_GestureID gestureId;
|
SDL_GestureID gestureId;
|
||||||
@@ -548,13 +550,15 @@ typedef struct SDL_DollarGestureEvent
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief An event used to request a file open by the system (event.drop.*)
|
* An event used to request a file open by the system (event.drop.*)
|
||||||
* This event is enabled by default, you can disable it with SDL_EventState().
|
*
|
||||||
* \note If this event is enabled, you must free the filename in the event.
|
* This event is enabled by default, you can disable it with SDL_EventState().
|
||||||
|
*
|
||||||
|
* If this event is enabled, you must free the filename in the event.
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_DropEvent
|
typedef struct SDL_DropEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_DROPBEGIN or ::SDL_DROPFILE or ::SDL_DROPTEXT or ::SDL_DROPCOMPLETE */
|
Uint32 type; /**< SDL_DROPBEGIN or SDL_DROPFILE or SDL_DROPTEXT or SDL_DROPCOMPLETE */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
char *file; /**< The file name, which should be freed with SDL_free(), is NULL on begin/complete */
|
char *file; /**< The file name, which should be freed with SDL_free(), is NULL on begin/complete */
|
||||||
Uint32 windowID; /**< The window that was dropped on, if any */
|
Uint32 windowID; /**< The window that was dropped on, if any */
|
||||||
@@ -562,11 +566,11 @@ typedef struct SDL_DropEvent
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sensor event structure (event.sensor.*)
|
* Sensor event structure (event.sensor.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_SensorEvent
|
typedef struct SDL_SensorEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_SENSORUPDATE */
|
Uint32 type; /**< SDL_SENSORUPDATE */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
Sint32 which; /**< The instance ID of the sensor */
|
Sint32 which; /**< The instance ID of the sensor */
|
||||||
float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData() */
|
float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData() */
|
||||||
@@ -574,20 +578,20 @@ typedef struct SDL_SensorEvent
|
|||||||
} SDL_SensorEvent;
|
} SDL_SensorEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The "quit requested" event
|
* The "quit requested" event
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_QuitEvent
|
typedef struct SDL_QuitEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_QUIT */
|
Uint32 type; /**< SDL_QUIT */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
} SDL_QuitEvent;
|
} SDL_QuitEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A user-defined event type (event.user.*)
|
* A user-defined event type (event.user.*)
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_UserEvent
|
typedef struct SDL_UserEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */
|
Uint32 type; /**< SDL_USEREVENT through SDL_LASTEVENT-1 */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
Uint32 windowID; /**< The associated window if any */
|
Uint32 windowID; /**< The associated window if any */
|
||||||
Sint32 code; /**< User defined event code */
|
Sint32 code; /**< User defined event code */
|
||||||
@@ -600,20 +604,21 @@ struct SDL_SysWMmsg;
|
|||||||
typedef struct SDL_SysWMmsg SDL_SysWMmsg;
|
typedef struct SDL_SysWMmsg SDL_SysWMmsg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A video driver dependent system event (event.syswm.*)
|
* A video driver dependent system event (event.syswm.*)
|
||||||
* This event is disabled by default, you can enable it with SDL_EventState()
|
|
||||||
*
|
*
|
||||||
* \note If you want to use this event, you should include SDL_syswm.h.
|
* This event is disabled by default, you can enable it with SDL_EventState()
|
||||||
|
*
|
||||||
|
* If you want to use this event, you should include SDL_syswm.h.
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_SysWMEvent
|
typedef struct SDL_SysWMEvent
|
||||||
{
|
{
|
||||||
Uint32 type; /**< ::SDL_SYSWMEVENT */
|
Uint32 type; /**< SDL_SYSWMEVENT */
|
||||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||||
SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */
|
SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */
|
||||||
} SDL_SysWMEvent;
|
} SDL_SysWMEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief General event structure
|
* General event structure
|
||||||
*/
|
*/
|
||||||
typedef union SDL_Event
|
typedef union SDL_Event
|
||||||
{
|
{
|
||||||
@@ -961,11 +966,11 @@ extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
|
|||||||
/**
|
/**
|
||||||
* A function pointer used for callbacks that watch the event queue.
|
* A function pointer used for callbacks that watch the event queue.
|
||||||
*
|
*
|
||||||
* \param userdata what was passed as `userdata` to SDL_SetEventFilter()
|
* \param userdata what was passed as `userdata` to SDL_SetEventFilter() or
|
||||||
* or SDL_AddEventWatch, etc
|
* SDL_AddEventWatch, etc
|
||||||
* \param event the event that triggered the callback
|
* \param event the event that triggered the callback
|
||||||
* \returns 1 to permit event to be added to the queue, and 0 to disallow
|
* \returns 1 to permit event to be added to the queue, and 0 to disallow it.
|
||||||
* it. When used with SDL_AddEventWatch, the return value is ignored.
|
* When used with SDL_AddEventWatch, the return value is ignored.
|
||||||
*
|
*
|
||||||
* \sa SDL_SetEventFilter
|
* \sa SDL_SetEventFilter
|
||||||
* \sa SDL_AddEventWatch
|
* \sa SDL_AddEventWatch
|
||||||
@@ -988,7 +993,7 @@ typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
|
|||||||
* interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the
|
* interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the
|
||||||
* application at the next event poll.
|
* application at the next event poll.
|
||||||
*
|
*
|
||||||
* There is one caveat when dealing with the ::SDL_QuitEvent event type. The
|
* There is one caveat when dealing with the SDL_QuitEvent event type. The
|
||||||
* event filter is only called when the window manager desires to close the
|
* event filter is only called when the window manager desires to close the
|
||||||
* application window. If the event filter returns 1, then the window will be
|
* application window. If the event filter returns 1, then the window will be
|
||||||
* closed, otherwise the window will remain open if possible.
|
* closed, otherwise the window will remain open if possible.
|
||||||
|
@@ -44,7 +44,7 @@ extern "C" {
|
|||||||
* \file SDL_gamecontroller.h
|
* \file SDL_gamecontroller.h
|
||||||
*
|
*
|
||||||
* In order to use these functions, SDL_Init() must have been called
|
* In order to use these functions, SDL_Init() must have been called
|
||||||
* with the ::SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system
|
* with the SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system
|
||||||
* for game controllers, and load appropriate drivers.
|
* for game controllers, and load appropriate drivers.
|
||||||
*
|
*
|
||||||
* If you would like to receive controller updates while the application
|
* If you would like to receive controller updates while the application
|
||||||
@@ -86,7 +86,7 @@ typedef enum SDL_GameControllerBindType
|
|||||||
} SDL_GameControllerBindType;
|
} SDL_GameControllerBindType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the SDL joystick layer binding for this controller button/axis mapping
|
* Get the SDL joystick layer binding for this controller button/axis mapping
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_GameControllerButtonBind
|
typedef struct SDL_GameControllerButtonBind
|
||||||
{
|
{
|
||||||
@@ -166,9 +166,10 @@ typedef struct SDL_GameControllerButtonBind
|
|||||||
extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw);
|
extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a set of mappings from a file, filtered by the current SDL_GetPlatform()
|
* Load a set of mappings from a file, filtered by the current
|
||||||
|
* SDL_GetPlatform()
|
||||||
*
|
*
|
||||||
* Convenience macro.
|
* Convenience macro.
|
||||||
*/
|
*/
|
||||||
#define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1)
|
#define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1)
|
||||||
|
|
||||||
@@ -607,15 +608,17 @@ extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void);
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of axes available from a controller
|
* The list of axes available from a controller
|
||||||
*
|
*
|
||||||
* Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to SDL_JOYSTICK_AXIS_MAX,
|
* Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to
|
||||||
* and are centered within ~8000 of zero, though advanced UI will allow users to set
|
* SDL_JOYSTICK_AXIS_MAX, and are centered within ~8000 of zero, though
|
||||||
* or autodetect the dead zone, which varies between controllers.
|
* advanced UI will allow users to set or autodetect the dead zone, which
|
||||||
|
* varies between controllers.
|
||||||
*
|
*
|
||||||
* Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX
|
* Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX (fully
|
||||||
* (fully pressed) when reported by SDL_GameControllerGetAxis(). Note that this is not the
|
* pressed) when reported by SDL_GameControllerGetAxis(). Note that this is
|
||||||
* same range that will be reported by the lower-level SDL_GetJoystickAxis().
|
* not the same range that will be reported by the lower-level
|
||||||
|
* SDL_GetJoystickAxis().
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_GameControllerAxis
|
typedef enum SDL_GameControllerAxis
|
||||||
{
|
{
|
||||||
@@ -724,7 +727,7 @@ extern DECLSPEC Sint16 SDLCALL
|
|||||||
SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
|
SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of buttons available from a controller
|
* The list of buttons available from a controller
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_GameControllerButton
|
typedef enum SDL_GameControllerButton
|
||||||
{
|
{
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
/**
|
/**
|
||||||
* \file SDL_guid.h
|
* \file SDL_guid.h
|
||||||
*
|
*
|
||||||
* Include file for handling ::SDL_GUID values.
|
* Include file for handling SDL_GUID values.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SDL_guid_h_
|
#ifndef SDL_guid_h_
|
||||||
@@ -38,19 +38,19 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An SDL_GUID is a 128-bit identifier for an input device that
|
* An SDL_GUID is a 128-bit identifier for an input device that identifies
|
||||||
* identifies that device across runs of SDL programs on the same
|
* that device across runs of SDL programs on the same platform.
|
||||||
* platform. If the device is detached and then re-attached to a
|
|
||||||
* different port, or if the base system is rebooted, the device
|
|
||||||
* should still report the same GUID.
|
|
||||||
*
|
*
|
||||||
* GUIDs are as precise as possible but are not guaranteed to
|
* If the device is detached and then re-attached to a different port, or if
|
||||||
* distinguish physically distinct but equivalent devices. For
|
* the base system is rebooted, the device should still report the same GUID.
|
||||||
* example, two game controllers from the same vendor with the same
|
|
||||||
* product ID and revision may have the same GUID.
|
|
||||||
*
|
*
|
||||||
* GUIDs may be platform-dependent (i.e., the same device may report
|
* GUIDs are as precise as possible but are not guaranteed to distinguish
|
||||||
* different GUIDs on different operating systems).
|
* physically distinct but equivalent devices. For example, two game
|
||||||
|
* controllers from the same vendor with the same product ID and revision may
|
||||||
|
* have the same GUID.
|
||||||
|
*
|
||||||
|
* GUIDs may be platform-dependent (i.e., the same device may report different
|
||||||
|
* GUIDs on different operating systems).
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_GUID {
|
typedef struct SDL_GUID {
|
||||||
Uint8 data[16];
|
Uint8 data[16];
|
||||||
@@ -59,11 +59,11 @@ typedef struct SDL_GUID {
|
|||||||
/* Function prototypes */
|
/* Function prototypes */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an ASCII string representation for a given ::SDL_GUID.
|
* Get an ASCII string representation for a given SDL_GUID.
|
||||||
*
|
*
|
||||||
* You should supply at least 33 bytes for pszGUID.
|
* You should supply at least 33 bytes for pszGUID.
|
||||||
*
|
*
|
||||||
* \param guid the ::SDL_GUID you wish to convert to string
|
* \param guid the SDL_GUID you wish to convert to string
|
||||||
* \param pszGUID buffer in which to write the ASCII string
|
* \param pszGUID buffer in which to write the ASCII string
|
||||||
* \param cbGUID the size of pszGUID
|
* \param cbGUID the size of pszGUID
|
||||||
*
|
*
|
||||||
@@ -74,14 +74,14 @@ typedef struct SDL_GUID {
|
|||||||
extern DECLSPEC void SDLCALL SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID);
|
extern DECLSPEC void SDLCALL SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a GUID string into a ::SDL_GUID structure.
|
* Convert a GUID string into a SDL_GUID structure.
|
||||||
*
|
*
|
||||||
* Performs no error checking. If this function is given a string containing
|
* Performs no error checking. If this function is given a string containing
|
||||||
* an invalid GUID, the function will silently succeed, but the GUID generated
|
* an invalid GUID, the function will silently succeed, but the GUID generated
|
||||||
* will not be useful.
|
* will not be useful.
|
||||||
*
|
*
|
||||||
* \param pchGUID string containing an ASCII representation of a GUID
|
* \param pchGUID string containing an ASCII representation of a GUID
|
||||||
* \returns a ::SDL_GUID structure.
|
* \returns a SDL_GUID structure.
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 2.24.0.
|
* \since This function is available since SDL 2.24.0.
|
||||||
*
|
*
|
||||||
|
@@ -26,18 +26,19 @@
|
|||||||
* devices.
|
* devices.
|
||||||
*
|
*
|
||||||
* The basic usage is as follows:
|
* The basic usage is as follows:
|
||||||
* - Initialize the subsystem (::SDL_INIT_HAPTIC).
|
* - Initialize the subsystem (SDL_INIT_HAPTIC).
|
||||||
* - Open a haptic device.
|
* - Open a haptic device.
|
||||||
* - SDL_HapticOpen() to open from index.
|
* - SDL_HapticOpen() to open from index.
|
||||||
* - SDL_HapticOpenFromJoystick() to open from an existing joystick.
|
* - SDL_HapticOpenFromJoystick() to open from an existing joystick.
|
||||||
* - Create an effect (::SDL_HapticEffect).
|
* - Create an effect (SDL_HapticEffect).
|
||||||
* - Upload the effect with SDL_HapticNewEffect().
|
* - Upload the effect with SDL_HapticNewEffect().
|
||||||
* - Run the effect with SDL_HapticRunEffect().
|
* - Run the effect with SDL_HapticRunEffect().
|
||||||
* - (optional) Free the effect with SDL_HapticDestroyEffect().
|
* - (optional) Free the effect with SDL_HapticDestroyEffect().
|
||||||
* - Close the haptic device with SDL_HapticClose().
|
* - Close the haptic device with SDL_HapticClose().
|
||||||
*
|
*
|
||||||
* \par Simple rumble example:
|
* \par Simple rumble example:
|
||||||
* \code
|
*
|
||||||
|
* ```c
|
||||||
* SDL_Haptic *haptic;
|
* SDL_Haptic *haptic;
|
||||||
*
|
*
|
||||||
* // Open the device
|
* // Open the device
|
||||||
@@ -56,10 +57,11 @@
|
|||||||
*
|
*
|
||||||
* // Clean up
|
* // Clean up
|
||||||
* SDL_HapticClose( haptic );
|
* SDL_HapticClose( haptic );
|
||||||
* \endcode
|
* ```
|
||||||
*
|
*
|
||||||
* \par Complete example:
|
* Complete example:
|
||||||
* \code
|
*
|
||||||
|
* ```c
|
||||||
* int test_haptic( SDL_Joystick * joystick ) {
|
* int test_haptic( SDL_Joystick * joystick ) {
|
||||||
* SDL_Haptic *haptic;
|
* SDL_Haptic *haptic;
|
||||||
* SDL_HapticEffect effect;
|
* SDL_HapticEffect effect;
|
||||||
@@ -101,7 +103,7 @@
|
|||||||
*
|
*
|
||||||
* return 0; // Success
|
* return 0; // Success
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* ```
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SDL_haptic_h_
|
#ifndef SDL_haptic_h_
|
||||||
@@ -154,31 +156,29 @@ typedef struct _SDL_Haptic SDL_Haptic;
|
|||||||
/* @{ */
|
/* @{ */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Constant effect supported.
|
* Constant effect supported.
|
||||||
*
|
*
|
||||||
* Constant haptic effect.
|
* Constant haptic effect.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticCondition
|
* \sa SDL_HapticCondition
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_CONSTANT (1u<<0)
|
#define SDL_HAPTIC_CONSTANT (1u<<0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sine wave effect supported.
|
* Sine wave effect supported.
|
||||||
*
|
*
|
||||||
* Periodic haptic effect that simulates sine waves.
|
* Periodic haptic effect that simulates sine waves.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticPeriodic
|
* \sa SDL_HapticPeriodic
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_SINE (1u<<1)
|
#define SDL_HAPTIC_SINE (1u<<1)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Left/Right effect supported.
|
* Left/Right effect supported.
|
||||||
*
|
*
|
||||||
* Haptic effect for direct control over high/low frequency motors.
|
* Haptic effect for direct control over high/low frequency motors.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticLeftRight
|
* \sa SDL_HapticLeftRight
|
||||||
* \warning this value was SDL_HAPTIC_SQUARE right before 2.0.0 shipped. Sorry,
|
|
||||||
* we ran out of bits, and this is important for XInput devices.
|
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_LEFTRIGHT (1u<<2)
|
#define SDL_HAPTIC_LEFTRIGHT (1u<<2)
|
||||||
|
|
||||||
@@ -186,85 +186,85 @@ typedef struct _SDL_Haptic SDL_Haptic;
|
|||||||
/* #define SDL_HAPTIC_SQUARE (1<<2) */
|
/* #define SDL_HAPTIC_SQUARE (1<<2) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Triangle wave effect supported.
|
* Triangle wave effect supported.
|
||||||
*
|
*
|
||||||
* Periodic haptic effect that simulates triangular waves.
|
* Periodic haptic effect that simulates triangular waves.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticPeriodic
|
* \sa SDL_HapticPeriodic
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_TRIANGLE (1u<<3)
|
#define SDL_HAPTIC_TRIANGLE (1u<<3)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sawtoothup wave effect supported.
|
* Sawtoothup wave effect supported.
|
||||||
*
|
*
|
||||||
* Periodic haptic effect that simulates saw tooth up waves.
|
* Periodic haptic effect that simulates saw tooth up waves.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticPeriodic
|
* \sa SDL_HapticPeriodic
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_SAWTOOTHUP (1u<<4)
|
#define SDL_HAPTIC_SAWTOOTHUP (1u<<4)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Sawtoothdown wave effect supported.
|
* Sawtoothdown wave effect supported.
|
||||||
*
|
*
|
||||||
* Periodic haptic effect that simulates saw tooth down waves.
|
* Periodic haptic effect that simulates saw tooth down waves.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticPeriodic
|
* \sa SDL_HapticPeriodic
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_SAWTOOTHDOWN (1u<<5)
|
#define SDL_HAPTIC_SAWTOOTHDOWN (1u<<5)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Ramp effect supported.
|
* Ramp effect supported.
|
||||||
*
|
*
|
||||||
* Ramp haptic effect.
|
* Ramp haptic effect.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticRamp
|
* \sa SDL_HapticRamp
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_RAMP (1u<<6)
|
#define SDL_HAPTIC_RAMP (1u<<6)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Spring effect supported - uses axes position.
|
* Spring effect supported - uses axes position.
|
||||||
*
|
*
|
||||||
* Condition haptic effect that simulates a spring. Effect is based on the
|
* Condition haptic effect that simulates a spring. Effect is based on the
|
||||||
* axes position.
|
* axes position.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticCondition
|
* \sa SDL_HapticCondition
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_SPRING (1u<<7)
|
#define SDL_HAPTIC_SPRING (1u<<7)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Damper effect supported - uses axes velocity.
|
* Damper effect supported - uses axes velocity.
|
||||||
*
|
*
|
||||||
* Condition haptic effect that simulates dampening. Effect is based on the
|
* Condition haptic effect that simulates dampening. Effect is based on the
|
||||||
* axes velocity.
|
* axes velocity.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticCondition
|
* \sa SDL_HapticCondition
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_DAMPER (1u<<8)
|
#define SDL_HAPTIC_DAMPER (1u<<8)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Inertia effect supported - uses axes acceleration.
|
* Inertia effect supported - uses axes acceleration.
|
||||||
*
|
*
|
||||||
* Condition haptic effect that simulates inertia. Effect is based on the axes
|
* Condition haptic effect that simulates inertia. Effect is based on the axes
|
||||||
* acceleration.
|
* acceleration.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticCondition
|
* \sa SDL_HapticCondition
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_INERTIA (1u<<9)
|
#define SDL_HAPTIC_INERTIA (1u<<9)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Friction effect supported - uses axes movement.
|
* Friction effect supported - uses axes movement.
|
||||||
*
|
*
|
||||||
* Condition haptic effect that simulates friction. Effect is based on the
|
* Condition haptic effect that simulates friction. Effect is based on the
|
||||||
* axes movement.
|
* axes movement.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticCondition
|
* \sa SDL_HapticCondition
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_FRICTION (1u<<10)
|
#define SDL_HAPTIC_FRICTION (1u<<10)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Custom effect is supported.
|
* Custom effect is supported.
|
||||||
*
|
*
|
||||||
* User defined custom haptic effect.
|
* User defined custom haptic effect.
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_CUSTOM (1u<<11)
|
#define SDL_HAPTIC_CUSTOM (1u<<11)
|
||||||
|
|
||||||
@@ -273,39 +273,39 @@ typedef struct _SDL_Haptic SDL_Haptic;
|
|||||||
/* These last few are features the device has, not effects */
|
/* These last few are features the device has, not effects */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Device can set global gain.
|
* Device can set global gain.
|
||||||
*
|
*
|
||||||
* Device supports setting the global gain.
|
* Device supports setting the global gain.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticSetGain
|
* \sa SDL_HapticSetGain
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_GAIN (1u<<12)
|
#define SDL_HAPTIC_GAIN (1u<<12)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Device can set autocenter.
|
* Device can set autocenter.
|
||||||
*
|
*
|
||||||
* Device supports setting autocenter.
|
* Device supports setting autocenter.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticSetAutocenter
|
* \sa SDL_HapticSetAutocenter
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_AUTOCENTER (1u<<13)
|
#define SDL_HAPTIC_AUTOCENTER (1u<<13)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Device can be queried for effect status.
|
* Device can be queried for effect status.
|
||||||
*
|
*
|
||||||
* Device supports querying effect status.
|
* Device supports querying effect status.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticGetEffectStatus
|
* \sa SDL_HapticGetEffectStatus
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_STATUS (1u<<14)
|
#define SDL_HAPTIC_STATUS (1u<<14)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Device can be paused.
|
* Device can be paused.
|
||||||
*
|
*
|
||||||
* Devices supports being paused.
|
* Devices supports being paused.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticPause
|
* \sa SDL_HapticPause
|
||||||
* \sa SDL_HapticUnpause
|
* \sa SDL_HapticUnpause
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_PAUSE (1u<<15)
|
#define SDL_HAPTIC_PAUSE (1u<<15)
|
||||||
|
|
||||||
@@ -316,31 +316,33 @@ typedef struct _SDL_Haptic SDL_Haptic;
|
|||||||
/* @{ */
|
/* @{ */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Uses polar coordinates for the direction.
|
* Uses polar coordinates for the direction.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticDirection
|
* \sa SDL_HapticDirection
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_POLAR 0
|
#define SDL_HAPTIC_POLAR 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Uses cartesian coordinates for the direction.
|
* Uses cartesian coordinates for the direction.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticDirection
|
* \sa SDL_HapticDirection
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_CARTESIAN 1
|
#define SDL_HAPTIC_CARTESIAN 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Uses spherical coordinates for the direction.
|
* Uses spherical coordinates for the direction.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticDirection
|
* \sa SDL_HapticDirection
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_SPHERICAL 2
|
#define SDL_HAPTIC_SPHERICAL 2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Use this value to play an effect on the steering wheel axis. This
|
* Use this value to play an effect on the steering wheel axis.
|
||||||
* provides better compatibility across platforms and devices as SDL will guess
|
*
|
||||||
* the correct axis.
|
* This provides better compatibility across platforms and devices as SDL will
|
||||||
* \sa SDL_HapticDirection
|
* guess the correct axis.
|
||||||
|
*
|
||||||
|
* \sa SDL_HapticDirection
|
||||||
*/
|
*/
|
||||||
#define SDL_HAPTIC_STEERING_AXIS 3
|
#define SDL_HAPTIC_STEERING_AXIS 3
|
||||||
|
|
||||||
@@ -353,7 +355,7 @@ typedef struct _SDL_Haptic SDL_Haptic;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Used to play a device an infinite number of times.
|
* Used to play a device an infinite number of times.
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticRunEffect
|
* \sa SDL_HapticRunEffect
|
||||||
*/
|
*/
|
||||||
@@ -361,77 +363,82 @@ typedef struct _SDL_Haptic SDL_Haptic;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Structure that represents a haptic direction.
|
* Structure that represents a haptic direction.
|
||||||
*
|
*
|
||||||
* This is the direction where the force comes from,
|
* This is the direction where the force comes from, instead of the direction
|
||||||
* instead of the direction in which the force is exerted.
|
* in which the force is exerted.
|
||||||
*
|
*
|
||||||
* Directions can be specified by:
|
* Directions can be specified by:
|
||||||
* - ::SDL_HAPTIC_POLAR : Specified by polar coordinates.
|
|
||||||
* - ::SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates.
|
|
||||||
* - ::SDL_HAPTIC_SPHERICAL : Specified by spherical coordinates.
|
|
||||||
*
|
*
|
||||||
* Cardinal directions of the haptic device are relative to the positioning
|
* - SDL_HAPTIC_POLAR : Specified by polar coordinates.
|
||||||
* of the device. North is considered to be away from the user.
|
* - SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates.
|
||||||
|
* - SDL_HAPTIC_SPHERICAL : Specified by spherical coordinates.
|
||||||
*
|
*
|
||||||
* The following diagram represents the cardinal directions:
|
* Cardinal directions of the haptic device are relative to the positioning of
|
||||||
* \verbatim
|
* the device. North is considered to be away from the user.
|
||||||
.--.
|
|
||||||
|__| .-------.
|
|
||||||
|=.| |.-----.|
|
|
||||||
|--| || ||
|
|
||||||
| | |'-----'|
|
|
||||||
|__|~')_____('
|
|
||||||
[ COMPUTER ]
|
|
||||||
|
|
||||||
|
|
||||||
North (0,-1)
|
|
||||||
^
|
|
||||||
|
|
|
||||||
|
|
|
||||||
(-1,0) West <----[ HAPTIC ]----> East (1,0)
|
|
||||||
|
|
|
||||||
|
|
|
||||||
v
|
|
||||||
South (0,1)
|
|
||||||
|
|
||||||
|
|
||||||
[ USER ]
|
|
||||||
\|||/
|
|
||||||
(o o)
|
|
||||||
---ooO-(_)-Ooo---
|
|
||||||
\endverbatim
|
|
||||||
*
|
*
|
||||||
* If type is ::SDL_HAPTIC_POLAR, direction is encoded by hundredths of a
|
* The following diagram represents the cardinal directions:
|
||||||
* degree starting north and turning clockwise. ::SDL_HAPTIC_POLAR only uses
|
|
||||||
* the first \c dir parameter. The cardinal directions would be:
|
|
||||||
* - North: 0 (0 degrees)
|
|
||||||
* - East: 9000 (90 degrees)
|
|
||||||
* - South: 18000 (180 degrees)
|
|
||||||
* - West: 27000 (270 degrees)
|
|
||||||
*
|
*
|
||||||
* If type is ::SDL_HAPTIC_CARTESIAN, direction is encoded by three positions
|
* ```
|
||||||
* (X axis, Y axis and Z axis (with 3 axes)). ::SDL_HAPTIC_CARTESIAN uses
|
* .--.
|
||||||
* the first three \c dir parameters. The cardinal directions would be:
|
* |__| .-------.
|
||||||
* - North: 0,-1, 0
|
* |=.| |.-----.|
|
||||||
* - East: 1, 0, 0
|
* |--| || ||
|
||||||
* - South: 0, 1, 0
|
* | | |'-----'|
|
||||||
* - West: -1, 0, 0
|
* |__|~')_____('
|
||||||
*
|
* [ COMPUTER ]
|
||||||
* The Z axis represents the height of the effect if supported, otherwise
|
|
||||||
* it's unused. In cartesian encoding (1, 2) would be the same as (2, 4), you
|
|
||||||
* can use any multiple you want, only the direction matters.
|
|
||||||
*
|
|
||||||
* If type is ::SDL_HAPTIC_SPHERICAL, direction is encoded by two rotations.
|
|
||||||
* The first two \c dir parameters are used. The \c dir parameters are as
|
|
||||||
* follows (all values are in hundredths of degrees):
|
|
||||||
* - Degrees from (1, 0) rotated towards (0, 1).
|
|
||||||
* - Degrees towards (0, 0, 1) (device needs at least 3 axes).
|
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Example of force coming from the south with all encodings (force coming
|
* North (0,-1)
|
||||||
* from the south means the user will have to pull the stick to counteract):
|
* ^
|
||||||
* \code
|
* |
|
||||||
|
* |
|
||||||
|
* (-1,0) West <----[ HAPTIC ]----> East (1,0)
|
||||||
|
* |
|
||||||
|
* |
|
||||||
|
* v
|
||||||
|
* South (0,1)
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* [ USER ]
|
||||||
|
* \|||/
|
||||||
|
* (o o)
|
||||||
|
* ---ooO-(_)-Ooo---
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* If type is SDL_HAPTIC_POLAR, direction is encoded by hundredths of a degree
|
||||||
|
* starting north and turning clockwise. SDL_HAPTIC_POLAR only uses the first
|
||||||
|
* `dir` parameter. The cardinal directions would be:
|
||||||
|
*
|
||||||
|
* - North: 0 (0 degrees)
|
||||||
|
* - East: 9000 (90 degrees)
|
||||||
|
* - South: 18000 (180 degrees)
|
||||||
|
* - West: 27000 (270 degrees)
|
||||||
|
*
|
||||||
|
* If type is SDL_HAPTIC_CARTESIAN, direction is encoded by three positions (X
|
||||||
|
* axis, Y axis and Z axis (with 3 axes)). SDL_HAPTIC_CARTESIAN uses the first
|
||||||
|
* three `dir` parameters. The cardinal directions would be:
|
||||||
|
*
|
||||||
|
* - North: 0,-1, 0
|
||||||
|
* - East: 1, 0, 0
|
||||||
|
* - South: 0, 1, 0
|
||||||
|
* - West: -1, 0, 0
|
||||||
|
*
|
||||||
|
* The Z axis represents the height of the effect if supported, otherwise it's
|
||||||
|
* unused. In cartesian encoding (1, 2) would be the same as (2, 4), you can
|
||||||
|
* use any multiple you want, only the direction matters.
|
||||||
|
*
|
||||||
|
* If type is SDL_HAPTIC_SPHERICAL, direction is encoded by two rotations. The
|
||||||
|
* first two `dir` parameters are used. The `dir` parameters are as follows
|
||||||
|
* (all values are in hundredths of degrees):
|
||||||
|
*
|
||||||
|
* - Degrees from (1, 0) rotated towards (0, 1).
|
||||||
|
* - Degrees towards (0, 0, 1) (device needs at least 3 axes).
|
||||||
|
*
|
||||||
|
* Example of force coming from the south with all encodings (force coming
|
||||||
|
* from the south means the user will have to pull the stick to counteract):
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
* SDL_HapticDirection direction;
|
* SDL_HapticDirection direction;
|
||||||
*
|
*
|
||||||
* // Cartesian directions
|
* // Cartesian directions
|
||||||
@@ -447,14 +454,14 @@ typedef struct _SDL_Haptic SDL_Haptic;
|
|||||||
* // Spherical coordinates
|
* // Spherical coordinates
|
||||||
* direction.type = SDL_HAPTIC_SPHERICAL; // Spherical encoding
|
* direction.type = SDL_HAPTIC_SPHERICAL; // Spherical encoding
|
||||||
* direction.dir[0] = 9000; // Since we only have two axes we don't need more parameters.
|
* direction.dir[0] = 9000; // Since we only have two axes we don't need more parameters.
|
||||||
* \endcode
|
* ```
|
||||||
*
|
*
|
||||||
* \sa SDL_HAPTIC_POLAR
|
* \sa SDL_HAPTIC_POLAR
|
||||||
* \sa SDL_HAPTIC_CARTESIAN
|
* \sa SDL_HAPTIC_CARTESIAN
|
||||||
* \sa SDL_HAPTIC_SPHERICAL
|
* \sa SDL_HAPTIC_SPHERICAL
|
||||||
* \sa SDL_HAPTIC_STEERING_AXIS
|
* \sa SDL_HAPTIC_STEERING_AXIS
|
||||||
* \sa SDL_HapticEffect
|
* \sa SDL_HapticEffect
|
||||||
* \sa SDL_HapticNumAxes
|
* \sa SDL_HapticNumAxes
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_HapticDirection
|
typedef struct SDL_HapticDirection
|
||||||
{
|
{
|
||||||
@@ -464,20 +471,20 @@ typedef struct SDL_HapticDirection
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A structure containing a template for a Constant effect.
|
* A structure containing a template for a Constant effect.
|
||||||
*
|
*
|
||||||
* This struct is exclusively for the ::SDL_HAPTIC_CONSTANT effect.
|
* This struct is exclusively for the SDL_HAPTIC_CONSTANT effect.
|
||||||
*
|
*
|
||||||
* A constant effect applies a constant force in the specified direction
|
* A constant effect applies a constant force in the specified direction to
|
||||||
* to the joystick.
|
* the joystick.
|
||||||
*
|
*
|
||||||
* \sa SDL_HAPTIC_CONSTANT
|
* \sa SDL_HAPTIC_CONSTANT
|
||||||
* \sa SDL_HapticEffect
|
* \sa SDL_HapticEffect
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_HapticConstant
|
typedef struct SDL_HapticConstant
|
||||||
{
|
{
|
||||||
/* Header */
|
/* Header */
|
||||||
Uint16 type; /**< ::SDL_HAPTIC_CONSTANT */
|
Uint16 type; /**< SDL_HAPTIC_CONSTANT */
|
||||||
SDL_HapticDirection direction; /**< Direction of the effect. */
|
SDL_HapticDirection direction; /**< Direction of the effect. */
|
||||||
|
|
||||||
/* Replay */
|
/* Replay */
|
||||||
@@ -499,68 +506,71 @@ typedef struct SDL_HapticConstant
|
|||||||
} SDL_HapticConstant;
|
} SDL_HapticConstant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A structure containing a template for a Periodic effect.
|
* A structure containing a template for a Periodic effect.
|
||||||
*
|
*
|
||||||
* The struct handles the following effects:
|
* The struct handles the following effects:
|
||||||
* - ::SDL_HAPTIC_SINE
|
|
||||||
* - ::SDL_HAPTIC_LEFTRIGHT
|
|
||||||
* - ::SDL_HAPTIC_TRIANGLE
|
|
||||||
* - ::SDL_HAPTIC_SAWTOOTHUP
|
|
||||||
* - ::SDL_HAPTIC_SAWTOOTHDOWN
|
|
||||||
*
|
*
|
||||||
* A periodic effect consists in a wave-shaped effect that repeats itself
|
* - SDL_HAPTIC_SINE
|
||||||
* over time. The type determines the shape of the wave and the parameters
|
* - SDL_HAPTIC_SQUARE
|
||||||
* determine the dimensions of the wave.
|
* - SDL_HAPTIC_TRIANGLE
|
||||||
|
* - SDL_HAPTIC_SAWTOOTHUP
|
||||||
|
* - SDL_HAPTIC_SAWTOOTHDOWN
|
||||||
*
|
*
|
||||||
* Phase is given by hundredth of a degree meaning that giving the phase a value
|
* A periodic effect consists in a wave-shaped effect that repeats itself over
|
||||||
* of 9000 will displace it 25% of its period. Here are sample values:
|
* time. The type determines the shape of the wave and the parameters
|
||||||
* - 0: No phase displacement.
|
* determine the dimensions of the wave.
|
||||||
* - 9000: Displaced 25% of its period.
|
|
||||||
* - 18000: Displaced 50% of its period.
|
|
||||||
* - 27000: Displaced 75% of its period.
|
|
||||||
* - 36000: Displaced 100% of its period, same as 0, but 0 is preferred.
|
|
||||||
*
|
*
|
||||||
* Examples:
|
* Phase is given by hundredth of a degree meaning that giving the phase a
|
||||||
* \verbatim
|
* value of 9000 will displace it 25% of its period. Here are sample values:
|
||||||
SDL_HAPTIC_SINE
|
|
||||||
__ __ __ __
|
|
||||||
/ \ / \ / \ /
|
|
||||||
/ \__/ \__/ \__/
|
|
||||||
|
|
||||||
SDL_HAPTIC_SQUARE
|
|
||||||
__ __ __ __ __
|
|
||||||
| | | | | | | | | |
|
|
||||||
| |__| |__| |__| |__| |
|
|
||||||
|
|
||||||
SDL_HAPTIC_TRIANGLE
|
|
||||||
/\ /\ /\ /\ /\
|
|
||||||
/ \ / \ / \ / \ /
|
|
||||||
/ \/ \/ \/ \/
|
|
||||||
|
|
||||||
SDL_HAPTIC_SAWTOOTHUP
|
|
||||||
/| /| /| /| /| /| /|
|
|
||||||
/ | / | / | / | / | / | / |
|
|
||||||
/ |/ |/ |/ |/ |/ |/ |
|
|
||||||
|
|
||||||
SDL_HAPTIC_SAWTOOTHDOWN
|
|
||||||
\ |\ |\ |\ |\ |\ |\ |
|
|
||||||
\ | \ | \ | \ | \ | \ | \ |
|
|
||||||
\| \| \| \| \| \| \|
|
|
||||||
\endverbatim
|
|
||||||
*
|
*
|
||||||
* \sa SDL_HAPTIC_SINE
|
* - 0: No phase displacement.
|
||||||
* \sa SDL_HAPTIC_LEFTRIGHT
|
* - 9000: Displaced 25% of its period.
|
||||||
* \sa SDL_HAPTIC_TRIANGLE
|
* - 18000: Displaced 50% of its period.
|
||||||
* \sa SDL_HAPTIC_SAWTOOTHUP
|
* - 27000: Displaced 75% of its period.
|
||||||
* \sa SDL_HAPTIC_SAWTOOTHDOWN
|
* - 36000: Displaced 100% of its period, same as 0, but 0 is preferred.
|
||||||
* \sa SDL_HapticEffect
|
*
|
||||||
|
* Examples:
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* SDL_HAPTIC_SINE
|
||||||
|
* __ __ __ __
|
||||||
|
* / \ / \ / \ /
|
||||||
|
* / \__/ \__/ \__/
|
||||||
|
*
|
||||||
|
* SDL_HAPTIC_SQUARE
|
||||||
|
* __ __ __ __ __
|
||||||
|
* | | | | | | | | | |
|
||||||
|
* | |__| |__| |__| |__| |
|
||||||
|
*
|
||||||
|
* SDL_HAPTIC_TRIANGLE
|
||||||
|
* /\ /\ /\ /\ /\
|
||||||
|
* / \ / \ / \ / \ /
|
||||||
|
* / \/ \/ \/ \/
|
||||||
|
*
|
||||||
|
* SDL_HAPTIC_SAWTOOTHUP
|
||||||
|
* /| /| /| /| /| /| /|
|
||||||
|
* / | / | / | / | / | / | / |
|
||||||
|
* / |/ |/ |/ |/ |/ |/ |
|
||||||
|
*
|
||||||
|
* SDL_HAPTIC_SAWTOOTHDOWN
|
||||||
|
* \ |\ |\ |\ |\ |\ |\ |
|
||||||
|
* \ | \ | \ | \ | \ | \ | \ |
|
||||||
|
* \| \| \| \| \| \| \|
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* \sa SDL_HAPTIC_SINE
|
||||||
|
* \sa SDL_HAPTIC_LEFTRIGHT
|
||||||
|
* \sa SDL_HAPTIC_TRIANGLE
|
||||||
|
* \sa SDL_HAPTIC_SAWTOOTHUP
|
||||||
|
* \sa SDL_HAPTIC_SAWTOOTHDOWN
|
||||||
|
* \sa SDL_HapticEffect
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_HapticPeriodic
|
typedef struct SDL_HapticPeriodic
|
||||||
{
|
{
|
||||||
/* Header */
|
/* Header */
|
||||||
Uint16 type; /**< ::SDL_HAPTIC_SINE, ::SDL_HAPTIC_LEFTRIGHT,
|
Uint16 type; /**< SDL_HAPTIC_SINE, SDL_HAPTIC_LEFTRIGHT,
|
||||||
::SDL_HAPTIC_TRIANGLE, ::SDL_HAPTIC_SAWTOOTHUP or
|
SDL_HAPTIC_TRIANGLE, SDL_HAPTIC_SAWTOOTHUP or
|
||||||
::SDL_HAPTIC_SAWTOOTHDOWN */
|
SDL_HAPTIC_SAWTOOTHDOWN */
|
||||||
SDL_HapticDirection direction; /**< Direction of the effect. */
|
SDL_HapticDirection direction; /**< Direction of the effect. */
|
||||||
|
|
||||||
/* Replay */
|
/* Replay */
|
||||||
@@ -585,34 +595,35 @@ typedef struct SDL_HapticPeriodic
|
|||||||
} SDL_HapticPeriodic;
|
} SDL_HapticPeriodic;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A structure containing a template for a Condition effect.
|
* A structure containing a template for a Condition effect.
|
||||||
*
|
*
|
||||||
* The struct handles the following effects:
|
* The struct handles the following effects:
|
||||||
* - ::SDL_HAPTIC_SPRING: Effect based on axes position.
|
|
||||||
* - ::SDL_HAPTIC_DAMPER: Effect based on axes velocity.
|
|
||||||
* - ::SDL_HAPTIC_INERTIA: Effect based on axes acceleration.
|
|
||||||
* - ::SDL_HAPTIC_FRICTION: Effect based on axes movement.
|
|
||||||
*
|
*
|
||||||
* Direction is handled by condition internals instead of a direction member.
|
* - SDL_HAPTIC_SPRING: Effect based on axes position.
|
||||||
* The condition effect specific members have three parameters. The first
|
* - SDL_HAPTIC_DAMPER: Effect based on axes velocity.
|
||||||
* refers to the X axis, the second refers to the Y axis and the third
|
* - SDL_HAPTIC_INERTIA: Effect based on axes acceleration.
|
||||||
* refers to the Z axis. The right terms refer to the positive side of the
|
* - SDL_HAPTIC_FRICTION: Effect based on axes movement.
|
||||||
* axis and the left terms refer to the negative side of the axis. Please
|
|
||||||
* refer to the ::SDL_HapticDirection diagram for which side is positive and
|
|
||||||
* which is negative.
|
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticDirection
|
* Direction is handled by condition internals instead of a direction member.
|
||||||
* \sa SDL_HAPTIC_SPRING
|
* The condition effect specific members have three parameters. The first
|
||||||
* \sa SDL_HAPTIC_DAMPER
|
* refers to the X axis, the second refers to the Y axis and the third refers
|
||||||
* \sa SDL_HAPTIC_INERTIA
|
* to the Z axis. The right terms refer to the positive side of the axis and
|
||||||
* \sa SDL_HAPTIC_FRICTION
|
* the left terms refer to the negative side of the axis. Please refer to the
|
||||||
* \sa SDL_HapticEffect
|
* SDL_HapticDirection diagram for which side is positive and which is
|
||||||
|
* negative.
|
||||||
|
*
|
||||||
|
* \sa SDL_HapticDirection
|
||||||
|
* \sa SDL_HAPTIC_SPRING
|
||||||
|
* \sa SDL_HAPTIC_DAMPER
|
||||||
|
* \sa SDL_HAPTIC_INERTIA
|
||||||
|
* \sa SDL_HAPTIC_FRICTION
|
||||||
|
* \sa SDL_HapticEffect
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_HapticCondition
|
typedef struct SDL_HapticCondition
|
||||||
{
|
{
|
||||||
/* Header */
|
/* Header */
|
||||||
Uint16 type; /**< ::SDL_HAPTIC_SPRING, ::SDL_HAPTIC_DAMPER,
|
Uint16 type; /**< SDL_HAPTIC_SPRING, SDL_HAPTIC_DAMPER,
|
||||||
::SDL_HAPTIC_INERTIA or ::SDL_HAPTIC_FRICTION */
|
SDL_HAPTIC_INERTIA or SDL_HAPTIC_FRICTION */
|
||||||
SDL_HapticDirection direction; /**< Direction of the effect - Not used ATM. */
|
SDL_HapticDirection direction; /**< Direction of the effect - Not used ATM. */
|
||||||
|
|
||||||
/* Replay */
|
/* Replay */
|
||||||
@@ -633,22 +644,22 @@ typedef struct SDL_HapticCondition
|
|||||||
} SDL_HapticCondition;
|
} SDL_HapticCondition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A structure containing a template for a Ramp effect.
|
* A structure containing a template for a Ramp effect.
|
||||||
*
|
*
|
||||||
* This struct is exclusively for the ::SDL_HAPTIC_RAMP effect.
|
* This struct is exclusively for the SDL_HAPTIC_RAMP effect.
|
||||||
*
|
*
|
||||||
* The ramp effect starts at start strength and ends at end strength.
|
* The ramp effect starts at start strength and ends at end strength. It
|
||||||
* It augments in linear fashion. If you use attack and fade with a ramp
|
* augments in linear fashion. If you use attack and fade with a ramp the
|
||||||
* the effects get added to the ramp effect making the effect become
|
* effects get added to the ramp effect making the effect become quadratic
|
||||||
* quadratic instead of linear.
|
* instead of linear.
|
||||||
*
|
*
|
||||||
* \sa SDL_HAPTIC_RAMP
|
* \sa SDL_HAPTIC_RAMP
|
||||||
* \sa SDL_HapticEffect
|
* \sa SDL_HapticEffect
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_HapticRamp
|
typedef struct SDL_HapticRamp
|
||||||
{
|
{
|
||||||
/* Header */
|
/* Header */
|
||||||
Uint16 type; /**< ::SDL_HAPTIC_RAMP */
|
Uint16 type; /**< SDL_HAPTIC_RAMP */
|
||||||
SDL_HapticDirection direction; /**< Direction of the effect. */
|
SDL_HapticDirection direction; /**< Direction of the effect. */
|
||||||
|
|
||||||
/* Replay */
|
/* Replay */
|
||||||
@@ -671,9 +682,9 @@ typedef struct SDL_HapticRamp
|
|||||||
} SDL_HapticRamp;
|
} SDL_HapticRamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A structure containing a template for a Left/Right effect.
|
* A structure containing a template for a Left/Right effect.
|
||||||
*
|
*
|
||||||
* This struct is exclusively for the ::SDL_HAPTIC_LEFTRIGHT effect.
|
* This struct is exclusively for the SDL_HAPTIC_LEFTRIGHT effect.
|
||||||
*
|
*
|
||||||
* The Left/Right effect is used to explicitly control the large and small
|
* The Left/Right effect is used to explicitly control the large and small
|
||||||
* motors, commonly found in modern game controllers. The small (right) motor
|
* motors, commonly found in modern game controllers. The small (right) motor
|
||||||
@@ -685,7 +696,7 @@ typedef struct SDL_HapticRamp
|
|||||||
typedef struct SDL_HapticLeftRight
|
typedef struct SDL_HapticLeftRight
|
||||||
{
|
{
|
||||||
/* Header */
|
/* Header */
|
||||||
Uint16 type; /**< ::SDL_HAPTIC_LEFTRIGHT */
|
Uint16 type; /**< SDL_HAPTIC_LEFTRIGHT */
|
||||||
|
|
||||||
/* Replay */
|
/* Replay */
|
||||||
Uint32 length; /**< Duration of the effect in milliseconds. */
|
Uint32 length; /**< Duration of the effect in milliseconds. */
|
||||||
@@ -696,24 +707,24 @@ typedef struct SDL_HapticLeftRight
|
|||||||
} SDL_HapticLeftRight;
|
} SDL_HapticLeftRight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A structure containing a template for the ::SDL_HAPTIC_CUSTOM effect.
|
* A structure containing a template for the SDL_HAPTIC_CUSTOM effect.
|
||||||
*
|
*
|
||||||
* This struct is exclusively for the ::SDL_HAPTIC_CUSTOM effect.
|
* This struct is exclusively for the SDL_HAPTIC_CUSTOM effect.
|
||||||
*
|
*
|
||||||
* A custom force feedback effect is much like a periodic effect, where the
|
* A custom force feedback effect is much like a periodic effect, where the
|
||||||
* application can define its exact shape. You will have to allocate the
|
* application can define its exact shape. You will have to allocate the data
|
||||||
* data yourself. Data should consist of channels * samples Uint16 samples.
|
* yourself. Data should consist of channels * samples Uint16 samples.
|
||||||
*
|
*
|
||||||
* If channels is one, the effect is rotated using the defined direction.
|
* If channels is one, the effect is rotated using the defined direction.
|
||||||
* Otherwise it uses the samples in data for the different axes.
|
* Otherwise it uses the samples in data for the different axes.
|
||||||
*
|
*
|
||||||
* \sa SDL_HAPTIC_CUSTOM
|
* \sa SDL_HAPTIC_CUSTOM
|
||||||
* \sa SDL_HapticEffect
|
* \sa SDL_HapticEffect
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_HapticCustom
|
typedef struct SDL_HapticCustom
|
||||||
{
|
{
|
||||||
/* Header */
|
/* Header */
|
||||||
Uint16 type; /**< ::SDL_HAPTIC_CUSTOM */
|
Uint16 type; /**< SDL_HAPTIC_CUSTOM */
|
||||||
SDL_HapticDirection direction; /**< Direction of the effect. */
|
SDL_HapticDirection direction; /**< Direction of the effect. */
|
||||||
|
|
||||||
/* Replay */
|
/* Replay */
|
||||||
@@ -738,27 +749,28 @@ typedef struct SDL_HapticCustom
|
|||||||
} SDL_HapticCustom;
|
} SDL_HapticCustom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The generic template for any haptic effect.
|
* The generic template for any haptic effect.
|
||||||
*
|
*
|
||||||
* All values max at 32767 (0x7FFF). Signed values also can be negative.
|
* All values max at 32767 (0x7FFF). Signed values also can be negative. Time
|
||||||
* Time values unless specified otherwise are in milliseconds.
|
* values unless specified otherwise are in milliseconds.
|
||||||
*
|
*
|
||||||
* You can also pass ::SDL_HAPTIC_INFINITY to length instead of a 0-32767
|
* You can also pass SDL_HAPTIC_INFINITY to length instead of a 0-32767 value.
|
||||||
* value. Neither delay, interval, attack_length nor fade_length support
|
* Neither delay, interval, attack_length nor fade_length support
|
||||||
* ::SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends.
|
* SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends.
|
||||||
*
|
*
|
||||||
* Additionally, the ::SDL_HAPTIC_RAMP effect does not support a duration of
|
* Additionally, the SDL_HAPTIC_RAMP effect does not support a duration of
|
||||||
* ::SDL_HAPTIC_INFINITY.
|
* SDL_HAPTIC_INFINITY.
|
||||||
*
|
*
|
||||||
* Button triggers may not be supported on all devices, it is advised to not
|
* Button triggers may not be supported on all devices, it is advised to not
|
||||||
* use them if possible. Buttons start at index 1 instead of index 0 like
|
* use them if possible. Buttons start at index 1 instead of index 0 like the
|
||||||
* the joystick.
|
* joystick.
|
||||||
*
|
*
|
||||||
* If both attack_length and fade_level are 0, the envelope is not used,
|
* If both attack_length and fade_level are 0, the envelope is not used,
|
||||||
* otherwise both values are used.
|
* otherwise both values are used.
|
||||||
*
|
*
|
||||||
* Common parts:
|
* Common parts:
|
||||||
* \code
|
*
|
||||||
|
* ```c
|
||||||
* // Replay - All effects have this
|
* // Replay - All effects have this
|
||||||
* Uint32 length; // Duration of effect (ms).
|
* Uint32 length; // Duration of effect (ms).
|
||||||
* Uint16 delay; // Delay before starting effect.
|
* Uint16 delay; // Delay before starting effect.
|
||||||
@@ -772,39 +784,39 @@ typedef struct SDL_HapticCustom
|
|||||||
* Uint16 attack_level; // Level at the start of the attack.
|
* Uint16 attack_level; // Level at the start of the attack.
|
||||||
* Uint16 fade_length; // Duration of the fade out (ms).
|
* Uint16 fade_length; // Duration of the fade out (ms).
|
||||||
* Uint16 fade_level; // Level at the end of the fade.
|
* Uint16 fade_level; // Level at the end of the fade.
|
||||||
* \endcode
|
* ```
|
||||||
*
|
*
|
||||||
|
* Here we have an example of a constant effect evolution in time:
|
||||||
*
|
*
|
||||||
* Here we have an example of a constant effect evolution in time:
|
* ```
|
||||||
* \verbatim
|
* Strength
|
||||||
Strength
|
* ^
|
||||||
^
|
* |
|
||||||
|
|
* | effect level --> _________________
|
||||||
| effect level --> _________________
|
* | / \
|
||||||
| / \
|
* | / \
|
||||||
| / \
|
* | / \
|
||||||
| / \
|
* | / \
|
||||||
| / \
|
* | attack_level --> | \
|
||||||
| attack_level --> | \
|
* | | | <--- fade_level
|
||||||
| | | <--- fade_level
|
* |
|
||||||
|
|
* +--------------------------------------------------> Time
|
||||||
+--------------------------------------------------> Time
|
* [--] [---]
|
||||||
[--] [---]
|
* attack_length fade_length
|
||||||
attack_length fade_length
|
|
||||||
|
|
||||||
[------------------][-----------------------]
|
|
||||||
delay length
|
|
||||||
\endverbatim
|
|
||||||
*
|
*
|
||||||
* Note either the attack_level or the fade_level may be above the actual
|
* [------------------][-----------------------]
|
||||||
* effect level.
|
* delay length
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* \sa SDL_HapticConstant
|
* Note either the attack_level or the fade_level may be above the actual
|
||||||
* \sa SDL_HapticPeriodic
|
* effect level.
|
||||||
* \sa SDL_HapticCondition
|
*
|
||||||
* \sa SDL_HapticRamp
|
* \sa SDL_HapticConstant
|
||||||
* \sa SDL_HapticLeftRight
|
* \sa SDL_HapticPeriodic
|
||||||
* \sa SDL_HapticCustom
|
* \sa SDL_HapticCondition
|
||||||
|
* \sa SDL_HapticRamp
|
||||||
|
* \sa SDL_HapticLeftRight
|
||||||
|
* \sa SDL_HapticCustom
|
||||||
*/
|
*/
|
||||||
typedef union SDL_HapticEffect
|
typedef union SDL_HapticEffect
|
||||||
{
|
{
|
||||||
|
@@ -71,14 +71,15 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A handle representing an open HID device
|
* A handle representing an open HID device
|
||||||
*/
|
*/
|
||||||
struct SDL_hid_device_;
|
struct SDL_hid_device_;
|
||||||
typedef struct SDL_hid_device_ SDL_hid_device; /**< opaque hidapi structure */
|
typedef struct SDL_hid_device_ SDL_hid_device; /**< opaque hidapi structure */
|
||||||
|
|
||||||
/** hidapi info structure */
|
/** hidapi info structure */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Information about a connected HID device
|
* Information about a connected HID device
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_hid_device_info
|
typedef struct SDL_hid_device_info
|
||||||
{
|
{
|
||||||
|
3000
include/SDL_hints.h
3000
include/SDL_hints.h
File diff suppressed because it is too large
Load Diff
@@ -56,7 +56,7 @@ extern "C" {
|
|||||||
* \file SDL_joystick.h
|
* \file SDL_joystick.h
|
||||||
*
|
*
|
||||||
* In order to use these functions, SDL_Init() must have been called
|
* In order to use these functions, SDL_Init() must have been called
|
||||||
* with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
|
* with the SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
|
||||||
* for joysticks, and load appropriate drivers.
|
* for joysticks, and load appropriate drivers.
|
||||||
*
|
*
|
||||||
* If you would like to receive joystick updates while the application
|
* If you would like to receive joystick updates while the application
|
||||||
@@ -77,11 +77,13 @@ typedef struct _SDL_Joystick SDL_Joystick;
|
|||||||
typedef SDL_GUID SDL_JoystickGUID;
|
typedef SDL_GUID SDL_JoystickGUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a unique ID for a joystick for the time it is connected to the system,
|
* This is a unique ID for a joystick for the time it is connected to the
|
||||||
* and is never reused for the lifetime of the application. If the joystick is
|
* system, and is never reused for the lifetime of the application.
|
||||||
* disconnected and reconnected, it will get a new ID.
|
|
||||||
*
|
*
|
||||||
* The ID value starts at 0 and increments from there. The value -1 is an invalid ID.
|
* If the joystick is disconnected and reconnected, it will get a new ID.
|
||||||
|
*
|
||||||
|
* The ID value starts at 0 and increments from there. The value -1 is an
|
||||||
|
* invalid ID.
|
||||||
*/
|
*/
|
||||||
typedef Sint32 SDL_JoystickID;
|
typedef Sint32 SDL_JoystickID;
|
||||||
|
|
||||||
@@ -358,8 +360,10 @@ extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type,
|
|||||||
/**
|
/**
|
||||||
* The structure that defines an extended virtual joystick description
|
* The structure that defines an extended virtual joystick description
|
||||||
*
|
*
|
||||||
* The caller must zero the structure and then initialize the version with `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` before passing it to SDL_JoystickAttachVirtualEx()
|
* The caller must zero the structure and then initialize the version with
|
||||||
* All other elements of this structure are optional and can be left 0.
|
* `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` before passing it to
|
||||||
|
* SDL_JoystickAttachVirtualEx() All other elements of this structure are
|
||||||
|
* optional and can be left 0.
|
||||||
*
|
*
|
||||||
* \sa SDL_JoystickAttachVirtualEx
|
* \sa SDL_JoystickAttachVirtualEx
|
||||||
*/
|
*/
|
||||||
@@ -390,7 +394,7 @@ typedef struct SDL_VirtualJoystickDesc
|
|||||||
} SDL_VirtualJoystickDesc;
|
} SDL_VirtualJoystickDesc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The current version of the SDL_VirtualJoystickDesc structure
|
* The current version of the SDL_VirtualJoystickDesc structure
|
||||||
*/
|
*/
|
||||||
#define SDL_VIRTUAL_JOYSTICK_DESC_VERSION 1
|
#define SDL_VIRTUAL_JOYSTICK_DESC_VERSION 1
|
||||||
|
|
||||||
|
@@ -40,14 +40,15 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The SDL keysym structure, used in key events.
|
* The SDL keysym structure, used in key events.
|
||||||
*
|
*
|
||||||
* \note If you are looking for translated character input, see the ::SDL_TEXTINPUT event.
|
* If you are looking for translated character input, see the SDL_TEXTINPUT
|
||||||
|
* event.
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_Keysym
|
typedef struct SDL_Keysym
|
||||||
{
|
{
|
||||||
SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */
|
SDL_Scancode scancode; /**< SDL physical key code - see SDL_Scancode for details */
|
||||||
SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */
|
SDL_Keycode sym; /**< SDL virtual key code - see SDL_Keycode for details */
|
||||||
Uint16 mod; /**< current key modifiers */
|
Uint16 mod; /**< current key modifiers */
|
||||||
Uint32 unused;
|
Uint32 unused;
|
||||||
} SDL_Keysym;
|
} SDL_Keysym;
|
||||||
|
@@ -32,15 +32,15 @@
|
|||||||
#include "SDL_scancode.h"
|
#include "SDL_scancode.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The SDL virtual key representation.
|
* The SDL virtual key representation.
|
||||||
*
|
*
|
||||||
* Values of this type are used to represent keyboard keys using the current
|
* Values of this type are used to represent keyboard keys using the current
|
||||||
* layout of the keyboard. These values include Unicode values representing
|
* layout of the keyboard. These values include Unicode values representing
|
||||||
* the unmodified character that would be generated by pressing the key, or
|
* the unmodified character that would be generated by pressing the key, or an
|
||||||
* an SDLK_* constant for those keys that do not generate characters.
|
* SDLK_* constant for those keys that do not generate characters.
|
||||||
*
|
*
|
||||||
* A special exception is the number keys at the top of the keyboard which
|
* A special exception is the number keys at the top of the keyboard which map
|
||||||
* map to SDLK_0...SDLK_9 on AZERTY layouts.
|
* to SDLK_0...SDLK_9 on AZERTY layouts.
|
||||||
*/
|
*/
|
||||||
typedef Sint32 SDL_Keycode;
|
typedef Sint32 SDL_Keycode;
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ typedef enum SDL_KeyCode
|
|||||||
} SDL_KeyCode;
|
} SDL_KeyCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Enumeration of valid key mods (possibly OR'd together).
|
* Enumeration of valid key mods (possibly OR'd together).
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_Keymod
|
typedef enum SDL_Keymod
|
||||||
{
|
{
|
||||||
|
@@ -47,19 +47,18 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The maximum size of a log message prior to SDL 2.0.24
|
* The maximum size of a log message prior to SDL 2.0.24
|
||||||
*
|
*
|
||||||
* As of 2.0.24 there is no limit to the length of SDL log messages.
|
* As of 2.0.24 there is no limit to the length of SDL log messages.
|
||||||
*/
|
*/
|
||||||
#define SDL_MAX_LOG_MESSAGE 4096
|
#define SDL_MAX_LOG_MESSAGE 4096
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The predefined log categories
|
* The predefined log categories
|
||||||
*
|
*
|
||||||
* By default the application category is enabled at the INFO level,
|
* By default the application category is enabled at the INFO level, the
|
||||||
* the assert category is enabled at the WARN level, test is enabled
|
* assert category is enabled at the WARN level, test is enabled at the
|
||||||
* at the VERBOSE level and all other categories are enabled at the
|
* VERBOSE level and all other categories are enabled at the ERROR level.
|
||||||
* ERROR level.
|
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_LogCategory
|
typedef enum SDL_LogCategory
|
||||||
{
|
{
|
||||||
@@ -97,7 +96,7 @@ typedef enum SDL_LogCategory
|
|||||||
} SDL_LogCategory;
|
} SDL_LogCategory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The predefined log priorities
|
* The predefined log priorities
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_LogPriority
|
typedef enum SDL_LogPriority
|
||||||
{
|
{
|
||||||
|
@@ -129,14 +129,14 @@
|
|||||||
*
|
*
|
||||||
* The application's main() function must be called with C linkage,
|
* The application's main() function must be called with C linkage,
|
||||||
* and should be declared like this:
|
* and should be declared like this:
|
||||||
* \code
|
* ```c
|
||||||
* #ifdef __cplusplus
|
* #ifdef __cplusplus
|
||||||
* extern "C"
|
* extern "C"
|
||||||
* #endif
|
* #endif
|
||||||
* int main(int argc, char *argv[])
|
* int main(int argc, char *argv[])
|
||||||
* {
|
* {
|
||||||
* }
|
* }
|
||||||
* \endcode
|
* ```
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE)
|
#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE)
|
||||||
@@ -149,7 +149,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The prototype for the application's main() function
|
* The prototype for the application's main() function
|
||||||
*/
|
*/
|
||||||
typedef int (*SDL_main_func)(int argc, char *argv[]);
|
typedef int (*SDL_main_func)(int argc, char *argv[]);
|
||||||
extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]);
|
extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]);
|
||||||
|
@@ -32,7 +32,9 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SDL_MessageBox flags. If supported will display warning icon, etc.
|
* SDL_MessageBox flags.
|
||||||
|
*
|
||||||
|
* If supported will display warning icon, etc.
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_MessageBoxFlags
|
typedef enum SDL_MessageBoxFlags
|
||||||
{
|
{
|
||||||
@@ -57,7 +59,7 @@ typedef enum SDL_MessageBoxButtonFlags
|
|||||||
*/
|
*/
|
||||||
typedef struct SDL_MessageBoxButtonData
|
typedef struct SDL_MessageBoxButtonData
|
||||||
{
|
{
|
||||||
Uint32 flags; /**< ::SDL_MessageBoxButtonFlags */
|
Uint32 flags; /**< SDL_MessageBoxButtonFlags */
|
||||||
int buttonid; /**< User defined button id (value returned via SDL_ShowMessageBox) */
|
int buttonid; /**< User defined button id (value returned via SDL_ShowMessageBox) */
|
||||||
const char * text; /**< The UTF-8 button text */
|
const char * text; /**< The UTF-8 button text */
|
||||||
} SDL_MessageBoxButtonData;
|
} SDL_MessageBoxButtonData;
|
||||||
@@ -93,7 +95,7 @@ typedef struct SDL_MessageBoxColorScheme
|
|||||||
*/
|
*/
|
||||||
typedef struct SDL_MessageBoxData
|
typedef struct SDL_MessageBoxData
|
||||||
{
|
{
|
||||||
Uint32 flags; /**< ::SDL_MessageBoxFlags */
|
Uint32 flags; /**< SDL_MessageBoxFlags */
|
||||||
SDL_Window *window; /**< Parent window, can be NULL */
|
SDL_Window *window; /**< Parent window, can be NULL */
|
||||||
const char *title; /**< UTF-8 title */
|
const char *title; /**< UTF-8 title */
|
||||||
const char *message; /**< UTF-8 message text */
|
const char *message; /**< UTF-8 message text */
|
||||||
@@ -101,7 +103,7 @@ typedef struct SDL_MessageBoxData
|
|||||||
int numbuttons;
|
int numbuttons;
|
||||||
const SDL_MessageBoxButtonData *buttons;
|
const SDL_MessageBoxButtonData *buttons;
|
||||||
|
|
||||||
const SDL_MessageBoxColorScheme *colorScheme; /**< ::SDL_MessageBoxColorScheme, can be NULL to use system settings */
|
const SDL_MessageBoxColorScheme *colorScheme; /**< SDL_MessageBoxColorScheme, can be NULL to use system settings */
|
||||||
} SDL_MessageBoxData;
|
} SDL_MessageBoxData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -37,9 +37,9 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS).
|
* A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS).
|
||||||
*
|
*
|
||||||
* \note This can be cast directly to an NSView or UIView.
|
* This can be cast directly to an NSView or UIView.
|
||||||
*/
|
*/
|
||||||
typedef void *SDL_MetalView;
|
typedef void *SDL_MetalView;
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ extern "C" {
|
|||||||
typedef struct SDL_Cursor SDL_Cursor; /**< Implementation dependent */
|
typedef struct SDL_Cursor SDL_Cursor; /**< Implementation dependent */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Cursor types for SDL_CreateSystemCursor().
|
* Cursor types for SDL_CreateSystemCursor().
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_SystemCursor
|
typedef enum SDL_SystemCursor
|
||||||
{
|
{
|
||||||
@@ -61,7 +61,7 @@ typedef enum SDL_SystemCursor
|
|||||||
} SDL_SystemCursor;
|
} SDL_SystemCursor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Scroll direction types for the Scroll event
|
* Scroll direction types for the Scroll event
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_MouseWheelDirection
|
typedef enum SDL_MouseWheelDirection
|
||||||
{
|
{
|
||||||
@@ -437,9 +437,9 @@ extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
|
|||||||
/**
|
/**
|
||||||
* Used as a mask when testing buttons in buttonstate.
|
* Used as a mask when testing buttons in buttonstate.
|
||||||
*
|
*
|
||||||
* - Button 1: Left mouse button
|
* - Button 1: Left mouse button
|
||||||
* - Button 2: Middle mouse button
|
* - Button 2: Middle mouse button
|
||||||
* - Button 3: Right mouse button
|
* - Button 3: Right mouse button
|
||||||
*/
|
*/
|
||||||
#define SDL_BUTTON(X) (1 << ((X)-1))
|
#define SDL_BUTTON(X) (1 << ((X)-1))
|
||||||
#define SDL_BUTTON_LEFT 1
|
#define SDL_BUTTON_LEFT 1
|
||||||
|
@@ -112,13 +112,13 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Synchronization functions which can time out return this value
|
* Synchronization functions which can time out return this value if they time
|
||||||
* if they time out.
|
* out.
|
||||||
*/
|
*/
|
||||||
#define SDL_MUTEX_TIMEDOUT 1
|
#define SDL_MUTEX_TIMEDOUT 1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the timeout value which corresponds to never time out.
|
* This is the timeout value which corresponds to never time out.
|
||||||
*/
|
*/
|
||||||
#define SDL_MUTEX_MAXWAIT (~(Uint32)0)
|
#define SDL_MUTEX_MAXWAIT (~(Uint32)0)
|
||||||
|
|
||||||
|
@@ -320,9 +320,10 @@ typedef enum
|
|||||||
} SDL_PixelFormatEnum;
|
} SDL_PixelFormatEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The bits of this structure can be directly reinterpreted as an integer-packed
|
* The bits of this structure can be directly reinterpreted as an
|
||||||
* color which uses the SDL_PIXELFORMAT_RGBA32 format (SDL_PIXELFORMAT_ABGR8888
|
* integer-packed color which uses the SDL_PIXELFORMAT_RGBA32 format
|
||||||
* on little-endian systems and SDL_PIXELFORMAT_RGBA8888 on big-endian systems).
|
* (SDL_PIXELFORMAT_ABGR8888 on little-endian systems and
|
||||||
|
* SDL_PIXELFORMAT_RGBA8888 on big-endian systems).
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_Color
|
typedef struct SDL_Color
|
||||||
{
|
{
|
||||||
@@ -342,7 +343,30 @@ typedef struct SDL_Palette
|
|||||||
} SDL_Palette;
|
} SDL_Palette;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \note Everything in the pixel format structure is read-only.
|
* A structure that contains pixel format information.
|
||||||
|
*
|
||||||
|
* Everything in the pixel format structure is read-only.
|
||||||
|
*
|
||||||
|
* A pixel format has either a palette or masks. If a palette is used `Rmask`,
|
||||||
|
* `Gmask`, `Bmask`, and `Amask` will be 0.
|
||||||
|
*
|
||||||
|
* An SDL_PixelFormat describes the format of the pixel data stored at the
|
||||||
|
* `pixels` field of an SDL_Surface. Every surface stores an SDL_PixelFormat
|
||||||
|
* in the `format` field.
|
||||||
|
*
|
||||||
|
* If you wish to do pixel level modifications on a surface, then
|
||||||
|
* understanding how SDL stores its color information is essential.
|
||||||
|
*
|
||||||
|
* For information on modern pixel color spaces, see the following Wikipedia
|
||||||
|
* article: http://en.wikipedia.org/wiki/RGBA_color_space
|
||||||
|
*
|
||||||
|
* \sa SDL_ConvertSurface
|
||||||
|
* \sa SDL_GetRGB
|
||||||
|
* \sa SDL_GetRGBA
|
||||||
|
* \sa SDL_MapRGB
|
||||||
|
* \sa SDL_MapRGBA
|
||||||
|
* \sa SDL_AllocFormat
|
||||||
|
* \sa SDL_FreeFormat
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_PixelFormat
|
typedef struct SDL_PixelFormat
|
||||||
{
|
{
|
||||||
|
@@ -37,7 +37,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The basic state for the system's power supply.
|
* The basic state for the system's power supply.
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_PowerState
|
typedef enum SDL_PowerState
|
||||||
{
|
{
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
/**
|
/**
|
||||||
* \file SDL_quit.h
|
* \file SDL_quit.h
|
||||||
*
|
*
|
||||||
* An ::SDL_QUIT event is generated when the user tries to close the application
|
* An SDL_QUIT event is generated when the user tries to close the application
|
||||||
* window. If it is ignored or filtered out, the window will remain open.
|
* window. If it is ignored or filtered out, the window will remain open.
|
||||||
* If it is not ignored or filtered, it is queued normally and the window
|
* If it is not ignored or filtered, it is queued normally and the window
|
||||||
* is allowed to close. When the window is closed, screen updates will
|
* is allowed to close. When the window is closed, screen updates will
|
||||||
@@ -42,8 +42,8 @@
|
|||||||
*
|
*
|
||||||
* SDL_Init() installs signal handlers for SIGINT (keyboard interrupt)
|
* SDL_Init() installs signal handlers for SIGINT (keyboard interrupt)
|
||||||
* and SIGTERM (system termination request), if handlers do not already
|
* and SIGTERM (system termination request), if handlers do not already
|
||||||
* exist, that generate ::SDL_QUIT events as well. There is no way
|
* exist, that generate SDL_QUIT events as well. There is no way
|
||||||
* to determine the cause of an ::SDL_QUIT event, but setting a signal
|
* to determine the cause of an SDL_QUIT event, but setting a signal
|
||||||
* handler in your application will override the default generation of
|
* handler in your application will override the default generation of
|
||||||
* quit events for that signal.
|
* quit events for that signal.
|
||||||
*
|
*
|
||||||
|
@@ -78,7 +78,7 @@ typedef enum SDL_RendererFlags
|
|||||||
typedef struct SDL_RendererInfo
|
typedef struct SDL_RendererInfo
|
||||||
{
|
{
|
||||||
const char *name; /**< The name of the renderer */
|
const char *name; /**< The name of the renderer */
|
||||||
Uint32 flags; /**< Supported ::SDL_RendererFlags */
|
Uint32 flags; /**< Supported SDL_RendererFlags */
|
||||||
Uint32 num_texture_formats; /**< The number of available texture formats */
|
Uint32 num_texture_formats; /**< The number of available texture formats */
|
||||||
Uint32 texture_formats[16]; /**< The available texture formats */
|
Uint32 texture_formats[16]; /**< The available texture formats */
|
||||||
int max_texture_width; /**< The maximum texture width */
|
int max_texture_width; /**< The maximum texture width */
|
||||||
@@ -86,7 +86,7 @@ typedef struct SDL_RendererInfo
|
|||||||
} SDL_RendererInfo;
|
} SDL_RendererInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vertex structure
|
* Vertex structure
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_Vertex
|
typedef struct SDL_Vertex
|
||||||
{
|
{
|
||||||
|
@@ -57,7 +57,7 @@ typedef struct SDL_RWops
|
|||||||
Sint64 (SDLCALL * size) (struct SDL_RWops * context);
|
Sint64 (SDLCALL * size) (struct SDL_RWops * context);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Seek to \c offset relative to \c whence, one of stdio's whence values:
|
* Seek to `offset` relative to `whence`, one of stdio's whence values:
|
||||||
* RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END
|
* RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END
|
||||||
*
|
*
|
||||||
* \return the final offset in the data stream, or -1 on error.
|
* \return the final offset in the data stream, or -1 on error.
|
||||||
@@ -66,8 +66,8 @@ typedef struct SDL_RWops
|
|||||||
int whence);
|
int whence);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read up to \c maxnum objects each of size \c size from the data
|
* Read up to `maxnum` objects each of size `size` from the data
|
||||||
* stream to the area pointed at by \c ptr.
|
* stream to the area pointed at by `ptr`.
|
||||||
*
|
*
|
||||||
* \return the number of objects read, or 0 at error or end of file.
|
* \return the number of objects read, or 0 at error or end of file.
|
||||||
*/
|
*/
|
||||||
@@ -75,8 +75,8 @@ typedef struct SDL_RWops
|
|||||||
size_t size, size_t maxnum);
|
size_t size, size_t maxnum);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write exactly \c num objects each of size \c size from the area
|
* Write exactly `num` objects each of size `size` from the area
|
||||||
* pointed at by \c ptr to data stream.
|
* pointed at by `ptr` to data stream.
|
||||||
*
|
*
|
||||||
* \return the number of objects written, or 0 at error or end of file.
|
* \return the number of objects written, or 0 at error or end of file.
|
||||||
*/
|
*/
|
||||||
|
@@ -31,14 +31,14 @@
|
|||||||
#include "SDL_stdinc.h"
|
#include "SDL_stdinc.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The SDL keyboard scancode representation.
|
* The SDL keyboard scancode representation.
|
||||||
*
|
*
|
||||||
* Values of this type are used to represent keyboard keys, among other places
|
* Values of this type are used to represent keyboard keys, among other places
|
||||||
* in the \link SDL_Keysym::scancode key.keysym.scancode \endlink field of the
|
* in the SDL_Keysym::scancode key.keysym.scancode field of the SDL_Event
|
||||||
* SDL_Event structure.
|
* structure.
|
||||||
*
|
*
|
||||||
* The values in this enumeration are based on the USB usage page standard:
|
* The values in this enumeration are based on the USB usage page standard:
|
||||||
* https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf
|
* https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_Scancode
|
typedef enum SDL_Scancode
|
||||||
{
|
{
|
||||||
|
@@ -44,7 +44,7 @@ extern "C" {
|
|||||||
* \brief SDL_sensor.h
|
* \brief SDL_sensor.h
|
||||||
*
|
*
|
||||||
* In order to use these functions, SDL_Init() must have been called
|
* In order to use these functions, SDL_Init() must have been called
|
||||||
* with the ::SDL_INIT_SENSOR flag. This causes SDL to scan the system
|
* with the SDL_INIT_SENSOR flag. This causes SDL to scan the system
|
||||||
* for sensors, and load appropriate drivers.
|
* for sensors, and load appropriate drivers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -52,21 +52,67 @@ struct _SDL_Sensor;
|
|||||||
typedef struct _SDL_Sensor SDL_Sensor;
|
typedef struct _SDL_Sensor SDL_Sensor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a unique ID for a sensor for the time it is connected to the system,
|
* This is a unique ID for a sensor for the time it is connected to the
|
||||||
* and is never reused for the lifetime of the application.
|
* system, and is never reused for the lifetime of the application.
|
||||||
*
|
*
|
||||||
* The ID value starts at 0 and increments from there. The value -1 is an invalid ID.
|
* The ID value starts at 0 and increments from there. The value -1 is an
|
||||||
|
* invalid ID.
|
||||||
*/
|
*/
|
||||||
typedef Sint32 SDL_SensorID;
|
typedef Sint32 SDL_SensorID;
|
||||||
|
|
||||||
/* The different sensors defined by SDL
|
/**
|
||||||
|
* The different sensors defined by SDL.
|
||||||
*
|
*
|
||||||
* Additional sensors may be available, using platform dependent semantics.
|
* Additional sensors may be available, using platform dependent semantics.
|
||||||
*
|
*
|
||||||
* Hare are the additional Android sensors:
|
* Here are the additional Android sensors:
|
||||||
|
*
|
||||||
* https://developer.android.com/reference/android/hardware/SensorEvent.html#values
|
* https://developer.android.com/reference/android/hardware/SensorEvent.html#values
|
||||||
|
*
|
||||||
|
* Accelerometer sensor notes:
|
||||||
|
*
|
||||||
|
* The accelerometer returns the current acceleration in SI meters per second
|
||||||
|
* squared. This measurement includes the force of gravity, so a device at
|
||||||
|
* rest will have an value of SDL_STANDARD_GRAVITY away from the center of the
|
||||||
|
* earth, which is a positive Y value.
|
||||||
|
*
|
||||||
|
* - `values[0]`: Acceleration on the x axis
|
||||||
|
* - `values[1]`: Acceleration on the y axis
|
||||||
|
* - `values[2]`: Acceleration on the z axis
|
||||||
|
*
|
||||||
|
* For phones and tablets held in natural orientation and game controllers
|
||||||
|
* held in front of you, the axes are defined as follows:
|
||||||
|
*
|
||||||
|
* - -X ... +X : left ... right
|
||||||
|
* - -Y ... +Y : bottom ... top
|
||||||
|
* - -Z ... +Z : farther ... closer
|
||||||
|
*
|
||||||
|
* The accelerometer axis data is not changed when the device is rotated.
|
||||||
|
*
|
||||||
|
* Gyroscope sensor notes:
|
||||||
|
*
|
||||||
|
* The gyroscope returns the current rate of rotation in radians per second.
|
||||||
|
* The rotation is positive in the counter-clockwise direction. That is, an
|
||||||
|
* observer looking from a positive location on one of the axes would see
|
||||||
|
* positive rotation on that axis when it appeared to be rotating
|
||||||
|
* counter-clockwise.
|
||||||
|
*
|
||||||
|
* - `values[0]`: Angular speed around the x axis (pitch)
|
||||||
|
* - `values[1]`: Angular speed around the y axis (yaw)
|
||||||
|
* - `values[2]`: Angular speed around the z axis (roll)
|
||||||
|
*
|
||||||
|
* For phones and tablets held in natural orientation and game controllers
|
||||||
|
* held in front of you, the axes are defined as follows:
|
||||||
|
*
|
||||||
|
* - -X ... +X : left ... right
|
||||||
|
* - -Y ... +Y : bottom ... top
|
||||||
|
* - -Z ... +Z : farther ... closer
|
||||||
|
*
|
||||||
|
* The gyroscope axis data is not changed when the device is rotated.
|
||||||
|
*
|
||||||
|
* \sa SDL_GetDisplayOrientation
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum SDL_SensorType
|
||||||
{
|
{
|
||||||
SDL_SENSOR_INVALID = -1, /**< Returned for an invalid sensor */
|
SDL_SENSOR_INVALID = -1, /**< Returned for an invalid sensor */
|
||||||
SDL_SENSOR_UNKNOWN, /**< Unknown sensor type */
|
SDL_SENSOR_UNKNOWN, /**< Unknown sensor type */
|
||||||
@@ -79,53 +125,15 @@ typedef enum
|
|||||||
} SDL_SensorType;
|
} SDL_SensorType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accelerometer sensor
|
* A constant to represent standard gravity for accelerometer sensors.
|
||||||
*
|
*
|
||||||
* The accelerometer returns the current acceleration in SI meters per
|
* The accelerometer returns the current acceleration in SI meters per second
|
||||||
* second squared. This measurement includes the force of gravity, so
|
* squared. This measurement includes the force of gravity, so a device at
|
||||||
* a device at rest will have an value of SDL_STANDARD_GRAVITY away
|
* rest will have an value of SDL_STANDARD_GRAVITY away from the center of the
|
||||||
* from the center of the earth, which is a positive Y value.
|
* earth, which is a positive Y value.
|
||||||
*
|
|
||||||
* values[0]: Acceleration on the x axis
|
|
||||||
* values[1]: Acceleration on the y axis
|
|
||||||
* values[2]: Acceleration on the z axis
|
|
||||||
*
|
|
||||||
* For phones held in portrait mode and game controllers held in front of you,
|
|
||||||
* the axes are defined as follows:
|
|
||||||
* -X ... +X : left ... right
|
|
||||||
* -Y ... +Y : bottom ... top
|
|
||||||
* -Z ... +Z : farther ... closer
|
|
||||||
*
|
|
||||||
* The axis data is not changed when the phone is rotated.
|
|
||||||
*
|
|
||||||
* \sa SDL_GetDisplayOrientation()
|
|
||||||
*/
|
*/
|
||||||
#define SDL_STANDARD_GRAVITY 9.80665f
|
#define SDL_STANDARD_GRAVITY 9.80665f
|
||||||
|
|
||||||
/**
|
|
||||||
* Gyroscope sensor
|
|
||||||
*
|
|
||||||
* The gyroscope returns the current rate of rotation in radians per second.
|
|
||||||
* The rotation is positive in the counter-clockwise direction. That is,
|
|
||||||
* an observer looking from a positive location on one of the axes would
|
|
||||||
* see positive rotation on that axis when it appeared to be rotating
|
|
||||||
* counter-clockwise.
|
|
||||||
*
|
|
||||||
* values[0]: Angular speed around the x axis (pitch)
|
|
||||||
* values[1]: Angular speed around the y axis (yaw)
|
|
||||||
* values[2]: Angular speed around the z axis (roll)
|
|
||||||
*
|
|
||||||
* For phones held in portrait mode and game controllers held in front of you,
|
|
||||||
* the axes are defined as follows:
|
|
||||||
* -X ... +X : left ... right
|
|
||||||
* -Y ... +Y : bottom ... top
|
|
||||||
* -Z ... +Z : farther ... closer
|
|
||||||
*
|
|
||||||
* The axis data is not changed when the phone or controller is rotated.
|
|
||||||
*
|
|
||||||
* \sa SDL_GetDisplayOrientation()
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Function prototypes */
|
/* Function prototypes */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -48,18 +48,18 @@ extern "C" {
|
|||||||
* and flags.
|
* and flags.
|
||||||
*
|
*
|
||||||
* \param title The title of the window, in UTF-8 encoding.
|
* \param title The title of the window, in UTF-8 encoding.
|
||||||
* \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or
|
* \param x The x position of the window, SDL_WINDOWPOS_CENTERED, or
|
||||||
* ::SDL_WINDOWPOS_UNDEFINED.
|
* SDL_WINDOWPOS_UNDEFINED.
|
||||||
* \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or
|
* \param y The y position of the window, SDL_WINDOWPOS_CENTERED, or
|
||||||
* ::SDL_WINDOWPOS_UNDEFINED.
|
* SDL_WINDOWPOS_UNDEFINED.
|
||||||
* \param w The width of the window.
|
* \param w The width of the window.
|
||||||
* \param h The height of the window.
|
* \param h The height of the window.
|
||||||
* \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with
|
* \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with
|
||||||
* any of the following: ::SDL_WINDOW_OPENGL,
|
* any of the following: SDL_WINDOW_OPENGL,
|
||||||
* ::SDL_WINDOW_INPUT_GRABBED, ::SDL_WINDOW_HIDDEN,
|
* SDL_WINDOW_INPUT_GRABBED, SDL_WINDOW_HIDDEN,
|
||||||
* ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED,
|
* SDL_WINDOW_RESIZABLE, SDL_WINDOW_MAXIMIZED,
|
||||||
* ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_BORDERLESS is always set,
|
* SDL_WINDOW_MINIMIZED, SDL_WINDOW_BORDERLESS is always set, and
|
||||||
* and ::SDL_WINDOW_FULLSCREEN is always unset.
|
* SDL_WINDOW_FULLSCREEN is always unset.
|
||||||
* \return the window created, or NULL if window creation failed.
|
* \return the window created, or NULL if window creation failed.
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 2.0.0.
|
* \since This function is available since SDL 2.0.0.
|
||||||
|
@@ -129,15 +129,19 @@ void *alloca(size_t);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of elements in an array.
|
* The number of elements in an array.
|
||||||
*/
|
*/
|
||||||
#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0]))
|
#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0]))
|
||||||
#define SDL_TABLESIZE(table) SDL_arraysize(table)
|
#define SDL_TABLESIZE(table) SDL_arraysize(table)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro useful for building other macros with strings in them
|
* Macro useful for building other macros with strings in them
|
||||||
*
|
*
|
||||||
* e.g. #define LOG_ERROR(X) OutputDebugString(SDL_STRINGIFY_ARG(__FUNCTION__) ": " X "\n")
|
* e.g:
|
||||||
|
*
|
||||||
|
* ```c
|
||||||
|
* #define LOG_ERROR(X) OutputDebugString(SDL_STRINGIFY_ARG(__FUNCTION__) ": " X "\n")
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
#define SDL_STRINGIFY_ARG(arg) #arg
|
#define SDL_STRINGIFY_ARG(arg) #arg
|
||||||
|
|
||||||
@@ -185,50 +189,56 @@ typedef enum
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A signed 8-bit integer type.
|
* A signed 8-bit integer type.
|
||||||
*/
|
*/
|
||||||
#define SDL_MAX_SINT8 ((Sint8)0x7F) /* 127 */
|
#define SDL_MAX_SINT8 ((Sint8)0x7F) /* 127 */
|
||||||
#define SDL_MIN_SINT8 ((Sint8)(~0x7F)) /* -128 */
|
#define SDL_MIN_SINT8 ((Sint8)(~0x7F)) /* -128 */
|
||||||
typedef int8_t Sint8;
|
typedef int8_t Sint8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief An unsigned 8-bit integer type.
|
* An unsigned 8-bit integer type.
|
||||||
*/
|
*/
|
||||||
#define SDL_MAX_UINT8 ((Uint8)0xFF) /* 255 */
|
#define SDL_MAX_UINT8 ((Uint8)0xFF) /* 255 */
|
||||||
#define SDL_MIN_UINT8 ((Uint8)0x00) /* 0 */
|
#define SDL_MIN_UINT8 ((Uint8)0x00) /* 0 */
|
||||||
typedef uint8_t Uint8;
|
typedef uint8_t Uint8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A signed 16-bit integer type.
|
* A signed 16-bit integer type.
|
||||||
*/
|
*/
|
||||||
#define SDL_MAX_SINT16 ((Sint16)0x7FFF) /* 32767 */
|
#define SDL_MAX_SINT16 ((Sint16)0x7FFF) /* 32767 */
|
||||||
#define SDL_MIN_SINT16 ((Sint16)(~0x7FFF)) /* -32768 */
|
#define SDL_MIN_SINT16 ((Sint16)(~0x7FFF)) /* -32768 */
|
||||||
typedef int16_t Sint16;
|
typedef int16_t Sint16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief An unsigned 16-bit integer type.
|
* An unsigned 16-bit integer type.
|
||||||
*/
|
*/
|
||||||
#define SDL_MAX_UINT16 ((Uint16)0xFFFF) /* 65535 */
|
#define SDL_MAX_UINT16 ((Uint16)0xFFFF) /* 65535 */
|
||||||
#define SDL_MIN_UINT16 ((Uint16)0x0000) /* 0 */
|
#define SDL_MIN_UINT16 ((Uint16)0x0000) /* 0 */
|
||||||
typedef uint16_t Uint16;
|
typedef uint16_t Uint16;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A signed 32-bit integer type.
|
* A signed 32-bit integer type.
|
||||||
*/
|
*/
|
||||||
#define SDL_MAX_SINT32 ((Sint32)0x7FFFFFFF) /* 2147483647 */
|
#define SDL_MAX_SINT32 ((Sint32)0x7FFFFFFF) /* 2147483647 */
|
||||||
#define SDL_MIN_SINT32 ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */
|
#define SDL_MIN_SINT32 ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */
|
||||||
typedef int32_t Sint32;
|
typedef int32_t Sint32;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief An unsigned 32-bit integer type.
|
* An unsigned 32-bit integer type.
|
||||||
*/
|
*/
|
||||||
#define SDL_MAX_UINT32 ((Uint32)0xFFFFFFFFu) /* 4294967295 */
|
#define SDL_MAX_UINT32 ((Uint32)0xFFFFFFFFu) /* 4294967295 */
|
||||||
#define SDL_MIN_UINT32 ((Uint32)0x00000000) /* 0 */
|
#define SDL_MIN_UINT32 ((Uint32)0x00000000) /* 0 */
|
||||||
typedef uint32_t Uint32;
|
typedef uint32_t Uint32;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A signed 64-bit integer type.
|
* A signed 64-bit integer type.
|
||||||
*/
|
*/
|
||||||
#define SDL_MAX_SINT64 ((Sint64)0x7FFFFFFFFFFFFFFFll) /* 9223372036854775807 */
|
#define SDL_MAX_SINT64 ((Sint64)0x7FFFFFFFFFFFFFFFll) /* 9223372036854775807 */
|
||||||
#define SDL_MIN_SINT64 ((Sint64)(~0x7FFFFFFFFFFFFFFFll)) /* -9223372036854775808 */
|
#define SDL_MIN_SINT64 ((Sint64)(~0x7FFFFFFFFFFFFFFFll)) /* -9223372036854775808 */
|
||||||
typedef int64_t Sint64;
|
typedef int64_t Sint64;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief An unsigned 64-bit integer type.
|
* An unsigned 64-bit integer type.
|
||||||
*/
|
*/
|
||||||
#define SDL_MAX_UINT64 ((Uint64)0xFFFFFFFFFFFFFFFFull) /* 18446744073709551615 */
|
#define SDL_MAX_UINT64 ((Uint64)0xFFFFFFFFFFFFFFFFull) /* 18446744073709551615 */
|
||||||
#define SDL_MIN_UINT64 ((Uint64)(0x0000000000000000ull)) /* 0 */
|
#define SDL_MIN_UINT64 ((Uint64)(0x0000000000000000ull)) /* 0 */
|
||||||
@@ -775,8 +785,9 @@ SDL_FORCE_INLINE void *SDL_memcpy4(SDL_OUT_BYTECAP(dwords*4) void *dst, SDL_IN_B
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a * b would overflow, return -1. Otherwise store a * b via ret
|
* If a * b would overflow, return -1.
|
||||||
* and return 0.
|
*
|
||||||
|
* Otherwise store a * b via ret and return 0.
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 2.24.0.
|
* \since This function is available since SDL 2.24.0.
|
||||||
*/
|
*/
|
||||||
@@ -805,8 +816,9 @@ SDL_FORCE_INLINE int _SDL_size_mul_overflow_builtin (size_t a,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a + b would overflow, return -1. Otherwise store a + b via ret
|
* If a + b would overflow, return -1.
|
||||||
* and return 0.
|
*
|
||||||
|
* Otherwise store a + b via ret and return 0.
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 2.24.0.
|
* \since This function is available since SDL 2.24.0.
|
||||||
*/
|
*/
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
/**
|
/**
|
||||||
* \file SDL_surface.h
|
* \file SDL_surface.h
|
||||||
*
|
*
|
||||||
* Header file for ::SDL_Surface definition and management functions.
|
* Header file for SDL_Surface definition and management functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SDL_surface_h_
|
#ifndef SDL_surface_h_
|
||||||
@@ -43,7 +43,7 @@ extern "C" {
|
|||||||
/**
|
/**
|
||||||
* \name Surface flags
|
* \name Surface flags
|
||||||
*
|
*
|
||||||
* These are the currently supported flags for the ::SDL_Surface.
|
* These are the currently supported flags for the SDL_Surface.
|
||||||
*
|
*
|
||||||
* \internal
|
* \internal
|
||||||
* Used internally (read-only).
|
* Used internally (read-only).
|
||||||
@@ -57,17 +57,17 @@ extern "C" {
|
|||||||
/* @} *//* Surface flags */
|
/* @} *//* Surface flags */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Evaluates to true if the surface needs to be locked before access.
|
* Evaluates to true if the surface needs to be locked before access.
|
||||||
*/
|
*/
|
||||||
#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0)
|
#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0)
|
||||||
|
|
||||||
typedef struct SDL_BlitMap SDL_BlitMap; /* this is an opaque type. */
|
typedef struct SDL_BlitMap SDL_BlitMap; /* this is an opaque type. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A collection of pixels used in software blitting.
|
* A collection of pixels used in software blitting.
|
||||||
*
|
*
|
||||||
* \note This structure should be treated as read-only, except for \c pixels,
|
* This structure should be treated as read-only, except for `pixels`, which,
|
||||||
* which, if not NULL, contains the raw pixel data for the surface.
|
* if not NULL, contains the raw pixel data for the surface.
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_Surface
|
typedef struct SDL_Surface
|
||||||
{
|
{
|
||||||
@@ -103,7 +103,7 @@ typedef int (SDLCALL *SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
|
|||||||
struct SDL_Surface * dst, SDL_Rect * dstrect);
|
struct SDL_Surface * dst, SDL_Rect * dstrect);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The formula used for converting between YUV and RGB
|
* The formula used for converting between YUV and RGB
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_YUV_CONVERSION_MODE
|
typedef enum SDL_YUV_CONVERSION_MODE
|
||||||
{
|
{
|
||||||
@@ -378,9 +378,9 @@ extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
|
|||||||
(SDL_Surface * surface, SDL_RWops * dst, int freedst);
|
(SDL_Surface * surface, SDL_RWops * dst, int freedst);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save a surface to a file.
|
* Save a surface to a file.
|
||||||
*
|
*
|
||||||
* Convenience macro.
|
* Convenience macro.
|
||||||
*/
|
*/
|
||||||
#define SDL_SaveBMP(surface, file) \
|
#define SDL_SaveBMP(surface, file) \
|
||||||
SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
|
SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
|
||||||
@@ -801,62 +801,64 @@ extern DECLSPEC int SDLCALL SDL_FillRects
|
|||||||
(SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
|
(SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
|
||||||
|
|
||||||
/* !!! FIXME: merge this documentation with the wiki */
|
/* !!! FIXME: merge this documentation with the wiki */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a fast blit from the source surface to the destination surface.
|
* Performs a fast blit from the source surface to the destination surface.
|
||||||
*
|
*
|
||||||
* This assumes that the source and destination rectangles are
|
* This assumes that the source and destination rectangles are the same size.
|
||||||
* the same size. If either \c srcrect or \c dstrect are NULL, the entire
|
* If either `srcrect` or `dstrect` are NULL, the entire surface (`src` or
|
||||||
* surface (\c src or \c dst) is copied. The final blit rectangles are saved
|
* `dst`) is copied. The final blit rectangles are saved in `srcrect` and
|
||||||
* in \c srcrect and \c dstrect after all clipping is performed.
|
* `dstrect` after all clipping is performed.
|
||||||
*
|
*
|
||||||
* \returns 0 if the blit is successful, otherwise it returns -1.
|
* The blit function should not be called on a locked surface.
|
||||||
*
|
*
|
||||||
* The blit function should not be called on a locked surface.
|
* The blit semantics for surfaces with and without blending and colorkey are
|
||||||
|
* defined as follows:
|
||||||
*
|
*
|
||||||
* The blit semantics for surfaces with and without blending and colorkey
|
* ```
|
||||||
* are defined as follows:
|
* RGBA->RGB:
|
||||||
* \verbatim
|
* Source surface blend mode set to SDL_BLENDMODE_BLEND:
|
||||||
RGBA->RGB:
|
* alpha-blend (using the source alpha-channel and per-surface alpha)
|
||||||
Source surface blend mode set to SDL_BLENDMODE_BLEND:
|
* SDL_SRCCOLORKEY ignored.
|
||||||
alpha-blend (using the source alpha-channel and per-surface alpha)
|
* Source surface blend mode set to SDL_BLENDMODE_NONE:
|
||||||
SDL_SRCCOLORKEY ignored.
|
* copy RGB.
|
||||||
Source surface blend mode set to SDL_BLENDMODE_NONE:
|
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||||
copy RGB.
|
* RGB values of the source color key, ignoring alpha in the
|
||||||
if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
* comparison.
|
||||||
RGB values of the source color key, ignoring alpha in the
|
|
||||||
comparison.
|
|
||||||
|
|
||||||
RGB->RGBA:
|
|
||||||
Source surface blend mode set to SDL_BLENDMODE_BLEND:
|
|
||||||
alpha-blend (using the source per-surface alpha)
|
|
||||||
Source surface blend mode set to SDL_BLENDMODE_NONE:
|
|
||||||
copy RGB, set destination alpha to source per-surface alpha value.
|
|
||||||
both:
|
|
||||||
if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
|
||||||
source color key.
|
|
||||||
|
|
||||||
RGBA->RGBA:
|
|
||||||
Source surface blend mode set to SDL_BLENDMODE_BLEND:
|
|
||||||
alpha-blend (using the source alpha-channel and per-surface alpha)
|
|
||||||
SDL_SRCCOLORKEY ignored.
|
|
||||||
Source surface blend mode set to SDL_BLENDMODE_NONE:
|
|
||||||
copy all of RGBA to the destination.
|
|
||||||
if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
|
||||||
RGB values of the source color key, ignoring alpha in the
|
|
||||||
comparison.
|
|
||||||
|
|
||||||
RGB->RGB:
|
|
||||||
Source surface blend mode set to SDL_BLENDMODE_BLEND:
|
|
||||||
alpha-blend (using the source per-surface alpha)
|
|
||||||
Source surface blend mode set to SDL_BLENDMODE_NONE:
|
|
||||||
copy RGB.
|
|
||||||
both:
|
|
||||||
if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
|
||||||
source color key.
|
|
||||||
\endverbatim
|
|
||||||
*
|
*
|
||||||
* You should call SDL_BlitSurface() unless you know exactly how SDL
|
* RGB->RGBA:
|
||||||
* blitting works internally and how to use the other blit functions.
|
* Source surface blend mode set to SDL_BLENDMODE_BLEND:
|
||||||
|
* alpha-blend (using the source per-surface alpha)
|
||||||
|
* Source surface blend mode set to SDL_BLENDMODE_NONE:
|
||||||
|
* copy RGB, set destination alpha to source per-surface alpha value.
|
||||||
|
* both:
|
||||||
|
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||||
|
* source color key.
|
||||||
|
*
|
||||||
|
* RGBA->RGBA:
|
||||||
|
* Source surface blend mode set to SDL_BLENDMODE_BLEND:
|
||||||
|
* alpha-blend (using the source alpha-channel and per-surface alpha)
|
||||||
|
* SDL_SRCCOLORKEY ignored.
|
||||||
|
* Source surface blend mode set to SDL_BLENDMODE_NONE:
|
||||||
|
* copy all of RGBA to the destination.
|
||||||
|
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||||
|
* RGB values of the source color key, ignoring alpha in the
|
||||||
|
* comparison.
|
||||||
|
*
|
||||||
|
* RGB->RGB:
|
||||||
|
* Source surface blend mode set to SDL_BLENDMODE_BLEND:
|
||||||
|
* alpha-blend (using the source per-surface alpha)
|
||||||
|
* Source surface blend mode set to SDL_BLENDMODE_NONE:
|
||||||
|
* copy RGB.
|
||||||
|
* both:
|
||||||
|
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||||
|
* source color key.
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* You should call SDL_BlitSurface() unless you know exactly how SDL blitting
|
||||||
|
* works internally and how to use the other blit functions.
|
||||||
|
*
|
||||||
|
* \returns 0 if the blit is successful, otherwise it returns -1.
|
||||||
*/
|
*/
|
||||||
#define SDL_BlitSurface SDL_UpperBlit
|
#define SDL_BlitSurface SDL_UpperBlit
|
||||||
|
|
||||||
|
@@ -356,9 +356,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void);
|
|||||||
extern DECLSPEC void SDLCALL SDL_AndroidBackButton(void);
|
extern DECLSPEC void SDLCALL SDL_AndroidBackButton(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
See the official Android developer guide for more information:
|
* See the official Android developer guide for more information:
|
||||||
http://developer.android.com/guide/topics/data/data-storage.html
|
* http://developer.android.com/guide/topics/data/data-storage.html
|
||||||
*/
|
*/
|
||||||
#define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01
|
#define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01
|
||||||
#define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02
|
#define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02
|
||||||
|
|
||||||
@@ -470,7 +470,7 @@ extern DECLSPEC int SDLCALL SDL_AndroidSendMessage(Uint32 command, int param);
|
|||||||
#ifdef __WINRT__
|
#ifdef __WINRT__
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief WinRT / Windows Phone path types
|
* WinRT / Windows Phone path types
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_WinRT_Path
|
typedef enum SDL_WinRT_Path
|
||||||
{
|
{
|
||||||
@@ -494,7 +494,7 @@ typedef enum SDL_WinRT_Path
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief WinRT Device Family
|
* WinRT Device Family
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_WinRT_DeviceFamily
|
typedef enum SDL_WinRT_DeviceFamily
|
||||||
{
|
{
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
/*
|
/*
|
||||||
* \file SDL_syswm.h
|
* \file SDL_syswm.h
|
||||||
*
|
*
|
||||||
* Your application has access to a special type of event ::SDL_SYSWMEVENT,
|
* Your application has access to a special type of event SDL_SYSWMEVENT,
|
||||||
* which contains window-manager specific information and arrives whenever
|
* which contains window-manager specific information and arrives whenever
|
||||||
* an unhandled window event occurs. This event is ignored by default, but
|
* an unhandled window event occurs. This event is ignored by default, but
|
||||||
* you can enable it with SDL_EventState().
|
* you can enable it with SDL_EventState().
|
||||||
@@ -130,8 +130,9 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(SDL_PROTOTYPES_ONLY)
|
#if !defined(SDL_PROTOTYPES_ONLY)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These are the various supported windowing subsystems
|
* These are the various supported windowing subsystems
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_SYSWM_TYPE
|
typedef enum SDL_SYSWM_TYPE
|
||||||
{
|
{
|
||||||
@@ -153,7 +154,7 @@ typedef enum SDL_SYSWM_TYPE
|
|||||||
} SDL_SYSWM_TYPE;
|
} SDL_SYSWM_TYPE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The custom event structure.
|
* The custom event structure.
|
||||||
*/
|
*/
|
||||||
struct SDL_SysWMmsg
|
struct SDL_SysWMmsg
|
||||||
{
|
{
|
||||||
@@ -219,10 +220,10 @@ struct SDL_SysWMmsg
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The custom window manager information structure.
|
* The custom window manager information structure.
|
||||||
*
|
*
|
||||||
* When this structure is returned, it holds information about which
|
* When this structure is returned, it holds information about which low level
|
||||||
* low level system it is using, and will be one of SDL_SYSWM_TYPE.
|
* system it is using, and will be one of SDL_SYSWM_TYPE.
|
||||||
*/
|
*/
|
||||||
struct SDL_SysWMinfo
|
struct SDL_SysWMinfo
|
||||||
{
|
{
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \file SDL_test.h
|
* \file SDL_test.h
|
||||||
*
|
*
|
||||||
* Include file for SDL test framework.
|
* Include file for SDL test framework.
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \file SDL_test_assert.h
|
* \file SDL_test_assert.h
|
||||||
*
|
*
|
||||||
* Include file for SDL test framework.
|
* Include file for SDL test framework.
|
||||||
@@ -42,17 +42,17 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Fails the assert.
|
* \brief Fails the assert.
|
||||||
*/
|
*/
|
||||||
#define ASSERT_FAIL 0
|
#define ASSERT_FAIL 0
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Passes the assert.
|
* \brief Passes the assert.
|
||||||
*/
|
*/
|
||||||
#define ASSERT_PASS 1
|
#define ASSERT_PASS 1
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Assert that logs and break execution flow on failures.
|
* \brief Assert that logs and break execution flow on failures.
|
||||||
*
|
*
|
||||||
* \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
|
* \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
|
||||||
@@ -60,7 +60,7 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2);
|
void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters.
|
* \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters.
|
||||||
*
|
*
|
||||||
* \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
|
* \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0).
|
||||||
@@ -70,25 +70,25 @@ void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *as
|
|||||||
*/
|
*/
|
||||||
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2);
|
int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Explicitly pass without checking an assertion condition. Updates assertion counter.
|
* \brief Explicitly pass without checking an assertion condition. Updates assertion counter.
|
||||||
*
|
*
|
||||||
* \param assertDescription Message to log with the assert describing it.
|
* \param assertDescription Message to log with the assert describing it.
|
||||||
*/
|
*/
|
||||||
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(1);
|
void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(1);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Resets the assert summary counters to zero.
|
* \brief Resets the assert summary counters to zero.
|
||||||
*/
|
*/
|
||||||
void SDLTest_ResetAssertSummary(void);
|
void SDLTest_ResetAssertSummary(void);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR.
|
* \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR.
|
||||||
*/
|
*/
|
||||||
void SDLTest_LogAssertSummary(void);
|
void SDLTest_LogAssertSummary(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Converts the current assert summary state to a test result.
|
* \brief Converts the current assert summary state to a test result.
|
||||||
*
|
*
|
||||||
* \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT
|
* \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \file SDL_test_common.h
|
* \file SDL_test_common.h
|
||||||
*
|
*
|
||||||
* Include file for SDL test framework.
|
* Include file for SDL test framework.
|
||||||
@@ -129,7 +129,7 @@ extern "C" {
|
|||||||
|
|
||||||
/* Function prototypes */
|
/* Function prototypes */
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Parse command line parameters and create common state.
|
* \brief Parse command line parameters and create common state.
|
||||||
*
|
*
|
||||||
* \param argv Array of command line parameters
|
* \param argv Array of command line parameters
|
||||||
@@ -139,7 +139,7 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags);
|
SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Process one common argument.
|
* \brief Process one common argument.
|
||||||
*
|
*
|
||||||
* \param state The common state describing the test window to create.
|
* \param state The common state describing the test window to create.
|
||||||
@@ -150,7 +150,7 @@ SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags);
|
|||||||
int SDLTest_CommonArg(SDLTest_CommonState * state, int index);
|
int SDLTest_CommonArg(SDLTest_CommonState * state, int index);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Logs command line usage info.
|
* \brief Logs command line usage info.
|
||||||
*
|
*
|
||||||
* This logs the appropriate command line options for the subsystems in use
|
* This logs the appropriate command line options for the subsystems in use
|
||||||
@@ -164,7 +164,7 @@ int SDLTest_CommonArg(SDLTest_CommonState * state, int index);
|
|||||||
*/
|
*/
|
||||||
void SDLTest_CommonLogUsage(SDLTest_CommonState * state, const char *argv0, const char **options);
|
void SDLTest_CommonLogUsage(SDLTest_CommonState * state, const char *argv0, const char **options);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Returns common usage information
|
* \brief Returns common usage information
|
||||||
*
|
*
|
||||||
* You should (probably) be using SDLTest_CommonLogUsage() instead, but this
|
* You should (probably) be using SDLTest_CommonLogUsage() instead, but this
|
||||||
@@ -177,7 +177,7 @@ void SDLTest_CommonLogUsage(SDLTest_CommonState * state, const char *argv0, cons
|
|||||||
*/
|
*/
|
||||||
const char *SDLTest_CommonUsage(SDLTest_CommonState * state);
|
const char *SDLTest_CommonUsage(SDLTest_CommonState * state);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Open test window.
|
* \brief Open test window.
|
||||||
*
|
*
|
||||||
* \param state The common state describing the test window to create.
|
* \param state The common state describing the test window to create.
|
||||||
@@ -186,7 +186,7 @@ const char *SDLTest_CommonUsage(SDLTest_CommonState * state);
|
|||||||
*/
|
*/
|
||||||
SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state);
|
SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Easy argument handling when test app doesn't need any custom args.
|
* \brief Easy argument handling when test app doesn't need any custom args.
|
||||||
*
|
*
|
||||||
* \param state The common state describing the test window to create.
|
* \param state The common state describing the test window to create.
|
||||||
@@ -197,7 +197,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state);
|
|||||||
*/
|
*/
|
||||||
SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState * state, const int argc, char **argv);
|
SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState * state, const int argc, char **argv);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Common event handler for test windows.
|
* \brief Common event handler for test windows.
|
||||||
*
|
*
|
||||||
* \param state The common state used to create test window.
|
* \param state The common state used to create test window.
|
||||||
@@ -207,7 +207,7 @@ SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState * state, const int argc,
|
|||||||
*/
|
*/
|
||||||
void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done);
|
void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Close test window.
|
* \brief Close test window.
|
||||||
*
|
*
|
||||||
* \param state The common state used to create test window.
|
* \param state The common state used to create test window.
|
||||||
@@ -215,7 +215,7 @@ void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *do
|
|||||||
*/
|
*/
|
||||||
void SDLTest_CommonQuit(SDLTest_CommonState * state);
|
void SDLTest_CommonQuit(SDLTest_CommonState * state);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Draws various window information (position, size, etc.) to the renderer.
|
* \brief Draws various window information (position, size, etc.) to the renderer.
|
||||||
*
|
*
|
||||||
* \param renderer The renderer to draw to.
|
* \param renderer The renderer to draw to.
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \file SDL_test_compare.h
|
* \file SDL_test_compare.h
|
||||||
*
|
*
|
||||||
* Include file for SDL test framework.
|
* Include file for SDL test framework.
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Compares a surface and with reference image data for equality
|
* \brief Compares a surface and with reference image data for equality
|
||||||
*
|
*
|
||||||
* \param surface Surface used in comparison
|
* \param surface Surface used in comparison
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \file SDL_test_font.h
|
* \file SDL_test_font.h
|
||||||
*
|
*
|
||||||
* Include file for SDL test framework.
|
* Include file for SDL test framework.
|
||||||
@@ -41,7 +41,7 @@ extern "C" {
|
|||||||
#define FONT_CHARACTER_SIZE 8
|
#define FONT_CHARACTER_SIZE 8
|
||||||
#define FONT_LINE_HEIGHT (FONT_CHARACTER_SIZE + 2)
|
#define FONT_LINE_HEIGHT (FONT_CHARACTER_SIZE + 2)
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Draw a string in the currently set font.
|
* \brief Draw a string in the currently set font.
|
||||||
*
|
*
|
||||||
* \param renderer The renderer to draw on.
|
* \param renderer The renderer to draw on.
|
||||||
@@ -53,7 +53,7 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c);
|
int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Draw a UTF-8 string in the currently set font.
|
* \brief Draw a UTF-8 string in the currently set font.
|
||||||
*
|
*
|
||||||
* The font currently only supports characters in the Basic Latin and Latin-1 Supplement sets.
|
* The font currently only supports characters in the Basic Latin and Latin-1 Supplement sets.
|
||||||
@@ -67,7 +67,7 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c);
|
|||||||
*/
|
*/
|
||||||
int SDLTest_DrawString(SDL_Renderer *renderer, int x, int y, const char *s);
|
int SDLTest_DrawString(SDL_Renderer *renderer, int x, int y, const char *s);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Data used for multi-line text output
|
* \brief Data used for multi-line text output
|
||||||
*/
|
*/
|
||||||
typedef struct SDLTest_TextWindow
|
typedef struct SDLTest_TextWindow
|
||||||
@@ -78,7 +78,7 @@ typedef struct SDLTest_TextWindow
|
|||||||
char **lines;
|
char **lines;
|
||||||
} SDLTest_TextWindow;
|
} SDLTest_TextWindow;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Create a multi-line text output window
|
* \brief Create a multi-line text output window
|
||||||
*
|
*
|
||||||
* \param x The X coordinate of the upper left corner of the window.
|
* \param x The X coordinate of the upper left corner of the window.
|
||||||
@@ -92,7 +92,7 @@ typedef struct SDLTest_TextWindow
|
|||||||
*/
|
*/
|
||||||
SDLTest_TextWindow *SDLTest_TextWindowCreate(int x, int y, int w, int h);
|
SDLTest_TextWindow *SDLTest_TextWindowCreate(int x, int y, int w, int h);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Display a multi-line text output window
|
* \brief Display a multi-line text output window
|
||||||
*
|
*
|
||||||
* This function should be called every frame to display the text
|
* This function should be called every frame to display the text
|
||||||
@@ -104,7 +104,7 @@ SDLTest_TextWindow *SDLTest_TextWindowCreate(int x, int y, int w, int h);
|
|||||||
*/
|
*/
|
||||||
void SDLTest_TextWindowDisplay(SDLTest_TextWindow *textwin, SDL_Renderer *renderer);
|
void SDLTest_TextWindowDisplay(SDLTest_TextWindow *textwin, SDL_Renderer *renderer);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Add text to a multi-line text output window
|
* \brief Add text to a multi-line text output window
|
||||||
*
|
*
|
||||||
* Adds UTF-8 text to the end of the current text. The newline character starts a
|
* Adds UTF-8 text to the end of the current text. The newline character starts a
|
||||||
@@ -119,7 +119,7 @@ void SDLTest_TextWindowDisplay(SDLTest_TextWindow *textwin, SDL_Renderer *render
|
|||||||
*/
|
*/
|
||||||
void SDLTest_TextWindowAddText(SDLTest_TextWindow *textwin, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
|
void SDLTest_TextWindowAddText(SDLTest_TextWindow *textwin, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Add text to a multi-line text output window
|
* \brief Add text to a multi-line text output window
|
||||||
*
|
*
|
||||||
* Adds UTF-8 text to the end of the current text. The newline character starts a
|
* Adds UTF-8 text to the end of the current text. The newline character starts a
|
||||||
@@ -134,7 +134,7 @@ void SDLTest_TextWindowAddText(SDLTest_TextWindow *textwin, SDL_PRINTF_FORMAT_ST
|
|||||||
*/
|
*/
|
||||||
void SDLTest_TextWindowAddTextWithLength(SDLTest_TextWindow *textwin, const char *text, size_t len);
|
void SDLTest_TextWindowAddTextWithLength(SDLTest_TextWindow *textwin, const char *text, size_t len);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Clear the text in a multi-line text output window
|
* \brief Clear the text in a multi-line text output window
|
||||||
*
|
*
|
||||||
* \param textwin The text output window
|
* \param textwin The text output window
|
||||||
@@ -143,7 +143,7 @@ void SDLTest_TextWindowAddTextWithLength(SDLTest_TextWindow *textwin, const char
|
|||||||
*/
|
*/
|
||||||
void SDLTest_TextWindowClear(SDLTest_TextWindow *textwin);
|
void SDLTest_TextWindowClear(SDLTest_TextWindow *textwin);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Free the storage associated with a multi-line text output window
|
* \brief Free the storage associated with a multi-line text output window
|
||||||
*
|
*
|
||||||
* \param textwin The text output window
|
* \param textwin The text output window
|
||||||
@@ -152,7 +152,7 @@ void SDLTest_TextWindowClear(SDLTest_TextWindow *textwin);
|
|||||||
*/
|
*/
|
||||||
void SDLTest_TextWindowDestroy(SDLTest_TextWindow *textwin);
|
void SDLTest_TextWindowDestroy(SDLTest_TextWindow *textwin);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Cleanup textures used by font drawing functions.
|
* \brief Cleanup textures used by font drawing functions.
|
||||||
*/
|
*/
|
||||||
void SDLTest_CleanupTextDrawing(void);
|
void SDLTest_CleanupTextDrawing(void);
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \file SDL_test_fuzzer.h
|
* \file SDL_test_fuzzer.h
|
||||||
*
|
*
|
||||||
* Include file for SDL test framework.
|
* Include file for SDL test framework.
|
||||||
@@ -48,13 +48,13 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \file
|
* \file
|
||||||
* Note: The fuzzer implementation uses a static instance of random context
|
* Note: The fuzzer implementation uses a static instance of random context
|
||||||
* internally which makes it thread-UNsafe.
|
* internally which makes it thread-UNsafe.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Initializes the fuzzer for a test
|
* Initializes the fuzzer for a test
|
||||||
*
|
*
|
||||||
* \param execKey Execution "Key" that initializes the random number generator uniquely for the test.
|
* \param execKey Execution "Key" that initializes the random number generator uniquely for the test.
|
||||||
@@ -63,14 +63,14 @@ extern "C" {
|
|||||||
void SDLTest_FuzzerInit(Uint64 execKey);
|
void SDLTest_FuzzerInit(Uint64 execKey);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns a random Uint8
|
* Returns a random Uint8
|
||||||
*
|
*
|
||||||
* \returns a generated integer
|
* \returns a generated integer
|
||||||
*/
|
*/
|
||||||
Uint8 SDLTest_RandomUint8(void);
|
Uint8 SDLTest_RandomUint8(void);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns a random Sint8
|
* Returns a random Sint8
|
||||||
*
|
*
|
||||||
* \returns a generated signed integer
|
* \returns a generated signed integer
|
||||||
@@ -78,14 +78,14 @@ Uint8 SDLTest_RandomUint8(void);
|
|||||||
Sint8 SDLTest_RandomSint8(void);
|
Sint8 SDLTest_RandomSint8(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns a random Uint16
|
* Returns a random Uint16
|
||||||
*
|
*
|
||||||
* \returns a generated integer
|
* \returns a generated integer
|
||||||
*/
|
*/
|
||||||
Uint16 SDLTest_RandomUint16(void);
|
Uint16 SDLTest_RandomUint16(void);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns a random Sint16
|
* Returns a random Sint16
|
||||||
*
|
*
|
||||||
* \returns a generated signed integer
|
* \returns a generated signed integer
|
||||||
@@ -93,7 +93,7 @@ Uint16 SDLTest_RandomUint16(void);
|
|||||||
Sint16 SDLTest_RandomSint16(void);
|
Sint16 SDLTest_RandomSint16(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns a random integer
|
* Returns a random integer
|
||||||
*
|
*
|
||||||
* \returns a generated integer
|
* \returns a generated integer
|
||||||
@@ -101,14 +101,14 @@ Sint16 SDLTest_RandomSint16(void);
|
|||||||
Sint32 SDLTest_RandomSint32(void);
|
Sint32 SDLTest_RandomSint32(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns a random positive integer
|
* Returns a random positive integer
|
||||||
*
|
*
|
||||||
* \returns a generated integer
|
* \returns a generated integer
|
||||||
*/
|
*/
|
||||||
Uint32 SDLTest_RandomUint32(void);
|
Uint32 SDLTest_RandomUint32(void);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns random Uint64.
|
* Returns random Uint64.
|
||||||
*
|
*
|
||||||
* \returns a generated integer
|
* \returns a generated integer
|
||||||
@@ -116,36 +116,36 @@ Uint32 SDLTest_RandomUint32(void);
|
|||||||
Uint64 SDLTest_RandomUint64(void);
|
Uint64 SDLTest_RandomUint64(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns random Sint64.
|
* Returns random Sint64.
|
||||||
*
|
*
|
||||||
* \returns a generated signed integer
|
* \returns a generated signed integer
|
||||||
*/
|
*/
|
||||||
Sint64 SDLTest_RandomSint64(void);
|
Sint64 SDLTest_RandomSint64(void);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \returns a random float in range [0.0 - 1.0]
|
* \returns a random float in range [0.0 - 1.0]
|
||||||
*/
|
*/
|
||||||
float SDLTest_RandomUnitFloat(void);
|
float SDLTest_RandomUnitFloat(void);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \returns a random double in range [0.0 - 1.0]
|
* \returns a random double in range [0.0 - 1.0]
|
||||||
*/
|
*/
|
||||||
double SDLTest_RandomUnitDouble(void);
|
double SDLTest_RandomUnitDouble(void);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \returns a random float.
|
* \returns a random float.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
float SDLTest_RandomFloat(void);
|
float SDLTest_RandomFloat(void);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \returns a random double.
|
* \returns a random double.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
double SDLTest_RandomDouble(void);
|
double SDLTest_RandomDouble(void);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns a random boundary value for Uint8 within the given boundaries.
|
* Returns a random boundary value for Uint8 within the given boundaries.
|
||||||
* Boundaries are inclusive, see the usage examples below. If validDomain
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
* is true, the function will only return valid boundaries, otherwise non-valid
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
@@ -166,7 +166,7 @@ double SDLTest_RandomDouble(void);
|
|||||||
*/
|
*/
|
||||||
Uint8 SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain);
|
Uint8 SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns a random boundary value for Uint16 within the given boundaries.
|
* Returns a random boundary value for Uint16 within the given boundaries.
|
||||||
* Boundaries are inclusive, see the usage examples below. If validDomain
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
* is true, the function will only return valid boundaries, otherwise non-valid
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
@@ -187,7 +187,7 @@ Uint8 SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_boo
|
|||||||
*/
|
*/
|
||||||
Uint16 SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain);
|
Uint16 SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns a random boundary value for Uint32 within the given boundaries.
|
* Returns a random boundary value for Uint32 within the given boundaries.
|
||||||
* Boundaries are inclusive, see the usage examples below. If validDomain
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
* is true, the function will only return valid boundaries, otherwise non-valid
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
@@ -208,7 +208,7 @@ Uint16 SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL
|
|||||||
*/
|
*/
|
||||||
Uint32 SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain);
|
Uint32 SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns a random boundary value for Uint64 within the given boundaries.
|
* Returns a random boundary value for Uint64 within the given boundaries.
|
||||||
* Boundaries are inclusive, see the usage examples below. If validDomain
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
* is true, the function will only return valid boundaries, otherwise non-valid
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
@@ -229,7 +229,7 @@ Uint32 SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL
|
|||||||
*/
|
*/
|
||||||
Uint64 SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain);
|
Uint64 SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns a random boundary value for Sint8 within the given boundaries.
|
* Returns a random boundary value for Sint8 within the given boundaries.
|
||||||
* Boundaries are inclusive, see the usage examples below. If validDomain
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
* is true, the function will only return valid boundaries, otherwise non-valid
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
@@ -251,7 +251,7 @@ Uint64 SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL
|
|||||||
Sint8 SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain);
|
Sint8 SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns a random boundary value for Sint16 within the given boundaries.
|
* Returns a random boundary value for Sint16 within the given boundaries.
|
||||||
* Boundaries are inclusive, see the usage examples below. If validDomain
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
* is true, the function will only return valid boundaries, otherwise non-valid
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
@@ -272,7 +272,7 @@ Sint8 SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_boo
|
|||||||
*/
|
*/
|
||||||
Sint16 SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain);
|
Sint16 SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns a random boundary value for Sint32 within the given boundaries.
|
* Returns a random boundary value for Sint32 within the given boundaries.
|
||||||
* Boundaries are inclusive, see the usage examples below. If validDomain
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
* is true, the function will only return valid boundaries, otherwise non-valid
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
@@ -293,7 +293,7 @@ Sint16 SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL
|
|||||||
*/
|
*/
|
||||||
Sint32 SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain);
|
Sint32 SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns a random boundary value for Sint64 within the given boundaries.
|
* Returns a random boundary value for Sint64 within the given boundaries.
|
||||||
* Boundaries are inclusive, see the usage examples below. If validDomain
|
* Boundaries are inclusive, see the usage examples below. If validDomain
|
||||||
* is true, the function will only return valid boundaries, otherwise non-valid
|
* is true, the function will only return valid boundaries, otherwise non-valid
|
||||||
@@ -315,7 +315,7 @@ Sint32 SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL
|
|||||||
Sint64 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain);
|
Sint64 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Returns integer in range [min, max] (inclusive).
|
* Returns integer in range [min, max] (inclusive).
|
||||||
* Min and max values can be negative values.
|
* Min and max values can be negative values.
|
||||||
* If Max in smaller than min, then the values are swapped.
|
* If Max in smaller than min, then the values are swapped.
|
||||||
@@ -329,7 +329,7 @@ Sint64 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL
|
|||||||
Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max);
|
Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Generates random null-terminated string. The minimum length for
|
* Generates random null-terminated string. The minimum length for
|
||||||
* the string is 1 character, maximum length for the string is 255
|
* the string is 1 character, maximum length for the string is 255
|
||||||
* characters and it can contain ASCII characters from 32 to 126.
|
* characters and it can contain ASCII characters from 32 to 126.
|
||||||
@@ -341,7 +341,7 @@ Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max);
|
|||||||
char * SDLTest_RandomAsciiString(void);
|
char * SDLTest_RandomAsciiString(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Generates random null-terminated string. The maximum length for
|
* Generates random null-terminated string. The maximum length for
|
||||||
* the string is defined by the maxLength parameter.
|
* the string is defined by the maxLength parameter.
|
||||||
* String can contain ASCII characters from 32 to 126.
|
* String can contain ASCII characters from 32 to 126.
|
||||||
@@ -355,7 +355,7 @@ char * SDLTest_RandomAsciiString(void);
|
|||||||
char * SDLTest_RandomAsciiStringWithMaximumLength(int maxLength);
|
char * SDLTest_RandomAsciiStringWithMaximumLength(int maxLength);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Generates random null-terminated string. The length for
|
* Generates random null-terminated string. The length for
|
||||||
* the string is defined by the size parameter.
|
* the string is defined by the size parameter.
|
||||||
* String can contain ASCII characters from 32 to 126.
|
* String can contain ASCII characters from 32 to 126.
|
||||||
@@ -368,7 +368,8 @@ char * SDLTest_RandomAsciiStringWithMaximumLength(int maxLength);
|
|||||||
*/
|
*/
|
||||||
char * SDLTest_RandomAsciiStringOfSize(int size);
|
char * SDLTest_RandomAsciiStringOfSize(int size);
|
||||||
|
|
||||||
/**
|
|
||||||
|
/*
|
||||||
* Get the invocation count for the fuzzer since last ...FuzzerInit.
|
* Get the invocation count for the fuzzer since last ...FuzzerInit.
|
||||||
*
|
*
|
||||||
* \returns the invocation count.
|
* \returns the invocation count.
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \file SDL_test_harness.h
|
* \file SDL_test_harness.h
|
||||||
*
|
*
|
||||||
* Include file for SDL test framework.
|
* Include file for SDL test framework.
|
||||||
@@ -69,7 +69,7 @@ typedef int (*SDLTest_TestCaseFp)(void *arg);
|
|||||||
/* !< Function pointer to a test case teardown function (run after every test) */
|
/* !< Function pointer to a test case teardown function (run after every test) */
|
||||||
typedef void (*SDLTest_TestCaseTearDownFp)(void *arg);
|
typedef void (*SDLTest_TestCaseTearDownFp)(void *arg);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Holds information about a single test case.
|
* Holds information about a single test case.
|
||||||
*/
|
*/
|
||||||
typedef struct SDLTest_TestCaseReference {
|
typedef struct SDLTest_TestCaseReference {
|
||||||
@@ -83,7 +83,7 @@ typedef struct SDLTest_TestCaseReference {
|
|||||||
int enabled;
|
int enabled;
|
||||||
} SDLTest_TestCaseReference;
|
} SDLTest_TestCaseReference;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Holds information about a test suite (multiple test cases).
|
* Holds information about a test suite (multiple test cases).
|
||||||
*/
|
*/
|
||||||
typedef struct SDLTest_TestSuiteReference {
|
typedef struct SDLTest_TestSuiteReference {
|
||||||
@@ -98,7 +98,7 @@ typedef struct SDLTest_TestSuiteReference {
|
|||||||
} SDLTest_TestSuiteReference;
|
} SDLTest_TestSuiteReference;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Generates a random run seed string for the harness. The generated seed will contain alphanumeric characters (0-9A-Z).
|
* \brief Generates a random run seed string for the harness. The generated seed will contain alphanumeric characters (0-9A-Z).
|
||||||
*
|
*
|
||||||
* Note: The returned string needs to be deallocated by the caller.
|
* Note: The returned string needs to be deallocated by the caller.
|
||||||
@@ -109,7 +109,7 @@ typedef struct SDLTest_TestSuiteReference {
|
|||||||
*/
|
*/
|
||||||
char *SDLTest_GenerateRunSeed(const int length);
|
char *SDLTest_GenerateRunSeed(const int length);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Execute a test suite using the given run seed and execution key.
|
* \brief Execute a test suite using the given run seed and execution key.
|
||||||
*
|
*
|
||||||
* \param testSuites Suites containing the test case.
|
* \param testSuites Suites containing the test case.
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \file SDL_test_images.h
|
* \file SDL_test_images.h
|
||||||
*
|
*
|
||||||
* Include file for SDL test framework.
|
* Include file for SDL test framework.
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/*
|
||||||
*Type for test images.
|
*Type for test images.
|
||||||
*/
|
*/
|
||||||
typedef struct SDLTest_SurfaceImage_s {
|
typedef struct SDLTest_SurfaceImage_s {
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \file SDL_test_log.h
|
* \file SDL_test_log.h
|
||||||
*
|
*
|
||||||
* Include file for SDL test framework.
|
* Include file for SDL test framework.
|
||||||
@@ -42,14 +42,14 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Prints given message with a timestamp in the TEST category and INFO priority.
|
* \brief Prints given message with a timestamp in the TEST category and INFO priority.
|
||||||
*
|
*
|
||||||
* \param fmt Message to be logged
|
* \param fmt Message to be logged
|
||||||
*/
|
*/
|
||||||
void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);
|
void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Prints given message with a timestamp in the TEST category and the ERROR priority.
|
* \brief Prints given message with a timestamp in the TEST category and the ERROR priority.
|
||||||
*
|
*
|
||||||
* \param fmt Message to be logged
|
* \param fmt Message to be logged
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \file SDL_test_md5.h
|
* \file SDL_test_md5.h
|
||||||
*
|
*
|
||||||
* Include file for SDL test framework.
|
* Include file for SDL test framework.
|
||||||
@@ -77,7 +77,7 @@ extern "C" {
|
|||||||
|
|
||||||
/* ---------- Function Prototypes ------------- */
|
/* ---------- Function Prototypes ------------- */
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief initialize the context
|
* \brief initialize the context
|
||||||
*
|
*
|
||||||
* \param mdContext pointer to context variable
|
* \param mdContext pointer to context variable
|
||||||
@@ -89,7 +89,7 @@ extern "C" {
|
|||||||
void SDLTest_Md5Init(SDLTest_Md5Context * mdContext);
|
void SDLTest_Md5Init(SDLTest_Md5Context * mdContext);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief update digest from variable length data
|
* \brief update digest from variable length data
|
||||||
*
|
*
|
||||||
* \param mdContext pointer to context variable
|
* \param mdContext pointer to context variable
|
||||||
@@ -105,7 +105,7 @@ extern "C" {
|
|||||||
unsigned int inLen);
|
unsigned int inLen);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief complete digest computation
|
* \brief complete digest computation
|
||||||
*
|
*
|
||||||
* \param mdContext pointer to context variable
|
* \param mdContext pointer to context variable
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \file SDL_test_memory.h
|
* \file SDL_test_memory.h
|
||||||
*
|
*
|
||||||
* Include file for SDL test framework.
|
* Include file for SDL test framework.
|
||||||
@@ -37,14 +37,14 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Start tracking SDL memory allocations
|
* \brief Start tracking SDL memory allocations
|
||||||
*
|
*
|
||||||
* \note This should be called before any other SDL functions for complete tracking coverage
|
* \note This should be called before any other SDL functions for complete tracking coverage
|
||||||
*/
|
*/
|
||||||
int SDLTest_TrackAllocations(void);
|
int SDLTest_TrackAllocations(void);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Print a log of any outstanding allocations
|
* \brief Print a log of any outstanding allocations
|
||||||
*
|
*
|
||||||
* \note This can be called after SDL_Quit()
|
* \note This can be called after SDL_Quit()
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \file SDL_test_random.h
|
* \file SDL_test_random.h
|
||||||
*
|
*
|
||||||
* Include file for SDL test framework.
|
* Include file for SDL test framework.
|
||||||
@@ -67,7 +67,7 @@ extern "C" {
|
|||||||
|
|
||||||
/* --- Function prototypes */
|
/* --- Function prototypes */
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Initialize random number generator with two integers.
|
* \brief Initialize random number generator with two integers.
|
||||||
*
|
*
|
||||||
* Note: The random sequence of numbers returned by ...Random() is the
|
* Note: The random sequence of numbers returned by ...Random() is the
|
||||||
@@ -81,7 +81,7 @@ extern "C" {
|
|||||||
void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi,
|
void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi,
|
||||||
unsigned int ci);
|
unsigned int ci);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Initialize random number generator based on current system time.
|
* \brief Initialize random number generator based on current system time.
|
||||||
*
|
*
|
||||||
* \param rndContext pointer to context structure
|
* \param rndContext pointer to context structure
|
||||||
@@ -90,7 +90,7 @@ extern "C" {
|
|||||||
void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext);
|
void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* \brief Initialize random number generator based on current system time.
|
* \brief Initialize random number generator based on current system time.
|
||||||
*
|
*
|
||||||
* Note: ...RandomInit() or ...RandomInitTime() must have been called
|
* Note: ...RandomInit() or ...RandomInitTime() must have been called
|
||||||
|
@@ -63,14 +63,16 @@ typedef unsigned long SDL_threadID;
|
|||||||
typedef unsigned int SDL_TLSID;
|
typedef unsigned int SDL_TLSID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The SDL thread priority.
|
* The SDL thread priority.
|
||||||
*
|
*
|
||||||
* SDL will make system changes as necessary in order to apply the thread priority.
|
* SDL will make system changes as necessary in order to apply the thread
|
||||||
* Code which attempts to control thread state related to priority should be aware
|
* priority. Code which attempts to control thread state related to priority
|
||||||
* that calling SDL_SetThreadPriority may alter such state.
|
* should be aware that calling SDL_SetThreadPriority may alter such state.
|
||||||
* SDL_HINT_THREAD_PRIORITY_POLICY can be used to control aspects of this behavior.
|
* SDL_HINT_THREAD_PRIORITY_POLICY can be used to control aspects of this
|
||||||
|
* behavior.
|
||||||
*
|
*
|
||||||
* \note On many systems you require special privileges to set high or time critical priority.
|
* On many systems you require special privileges to set high or time critical
|
||||||
|
* priority.
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_ThreadPriority {
|
typedef enum SDL_ThreadPriority {
|
||||||
SDL_THREAD_PRIORITY_LOW,
|
SDL_THREAD_PRIORITY_LOW,
|
||||||
|
@@ -89,8 +89,8 @@ extern DECLSPEC Uint64 SDLCALL SDL_GetTicks64(void);
|
|||||||
* days, but should _not_ be used with SDL_GetTicks64(), which does not have
|
* days, but should _not_ be used with SDL_GetTicks64(), which does not have
|
||||||
* that problem.
|
* that problem.
|
||||||
*
|
*
|
||||||
* For example, with SDL_GetTicks(), if you want to wait 100 ms, you could
|
* For example, with SDL_GetTicks(), if you want to wait 100 ms, you could do
|
||||||
* do this:
|
* this:
|
||||||
*
|
*
|
||||||
* ```c
|
* ```c
|
||||||
* const Uint32 timeout = SDL_GetTicks() + 100;
|
* const Uint32 timeout = SDL_GetTicks() + 100;
|
||||||
@@ -99,9 +99,9 @@ extern DECLSPEC Uint64 SDLCALL SDL_GetTicks64(void);
|
|||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* Note that this does not handle tick differences greater
|
* Note that this does not handle tick differences greater than 2^31 so take
|
||||||
* than 2^31 so take care when using the above kind of code
|
* care when using the above kind of code with large timeout delays (tens of
|
||||||
* with large timeout delays (tens of days).
|
* days).
|
||||||
*/
|
*/
|
||||||
#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0)
|
#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0)
|
||||||
|
|
||||||
@@ -149,10 +149,10 @@ extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
|
|||||||
/**
|
/**
|
||||||
* Function prototype for the timer callback function.
|
* Function prototype for the timer callback function.
|
||||||
*
|
*
|
||||||
* The callback function is passed the current timer interval and returns
|
* The callback function is passed the current timer interval and returns the
|
||||||
* the next timer interval. If the returned value is the same as the one
|
* next timer interval. If the returned value is the same as the one passed
|
||||||
* passed in, the periodic alarm continues, otherwise a new alarm is
|
* in, the periodic alarm continues, otherwise a new alarm is scheduled. If
|
||||||
* scheduled. If the callback returns 0, the periodic alarm is cancelled.
|
* the callback returns 0, the periodic alarm is cancelled.
|
||||||
*/
|
*/
|
||||||
typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param);
|
typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param);
|
||||||
|
|
||||||
|
@@ -40,10 +40,9 @@ extern "C" {
|
|||||||
* Information about the version of SDL in use.
|
* Information about the version of SDL in use.
|
||||||
*
|
*
|
||||||
* Represents the library's version as three levels: major revision
|
* Represents the library's version as three levels: major revision
|
||||||
* (increments with massive changes, additions, and enhancements),
|
* (increments with massive changes, additions, and enhancements), minor
|
||||||
* minor revision (increments with backwards-compatible changes to the
|
* revision (increments with backwards-compatible changes to the major
|
||||||
* major revision), and patchlevel (increments with fixes to the minor
|
* revision), and patchlevel (increments with fixes to the minor revision).
|
||||||
* revision).
|
|
||||||
*
|
*
|
||||||
* \sa SDL_VERSION
|
* \sa SDL_VERSION
|
||||||
* \sa SDL_GetVersion
|
* \sa SDL_GetVersion
|
||||||
@@ -64,12 +63,11 @@ typedef struct SDL_version
|
|||||||
/**
|
/**
|
||||||
* Macro to determine SDL version program was compiled against.
|
* Macro to determine SDL version program was compiled against.
|
||||||
*
|
*
|
||||||
* This macro fills in a SDL_version structure with the version of the
|
* This macro fills in a SDL_version structure with the version of the library
|
||||||
* library you compiled against. This is determined by what header the
|
* you compiled against. This is determined by what header the compiler uses.
|
||||||
* compiler uses. Note that if you dynamically linked the library, you might
|
* Note that if you dynamically linked the library, you might have a slightly
|
||||||
* have a slightly newer or older version at runtime. That version can be
|
* newer or older version at runtime. That version can be determined with
|
||||||
* determined with SDL_GetVersion(), which, unlike SDL_VERSION(),
|
* SDL_GetVersion(), which, unlike SDL_VERSION(), is not a macro.
|
||||||
* is not a macro.
|
|
||||||
*
|
*
|
||||||
* \param x A pointer to a SDL_version struct to initialize.
|
* \param x A pointer to a SDL_version struct to initialize.
|
||||||
*
|
*
|
||||||
@@ -85,37 +83,40 @@ typedef struct SDL_version
|
|||||||
|
|
||||||
/* TODO: Remove this whole block in SDL 3 */
|
/* TODO: Remove this whole block in SDL 3 */
|
||||||
#if SDL_MAJOR_VERSION < 3
|
#if SDL_MAJOR_VERSION < 3
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This macro turns the version numbers into a numeric value:
|
* This macro turns the version numbers into a numeric value:
|
||||||
* \verbatim
|
|
||||||
(1,2,3) -> (1203)
|
|
||||||
\endverbatim
|
|
||||||
*
|
*
|
||||||
* This assumes that there will never be more than 100 patchlevels.
|
* ```
|
||||||
|
* (1,2,3) -> (1203)
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* In versions higher than 2.9.0, the minor version overflows into
|
* This assumes that there will never be more than 100 patchlevels.
|
||||||
* the thousands digit: for example, 2.23.0 is encoded as 4300,
|
*
|
||||||
* and 2.255.99 would be encoded as 25799.
|
* In versions higher than 2.9.0, the minor version overflows into the
|
||||||
* This macro will not be available in SDL 3.x.
|
* thousands digit: for example, 2.23.0 is encoded as 4300, and 2.255.99 would
|
||||||
|
* be encoded as 25799.
|
||||||
|
*
|
||||||
|
* This macro will not be available in SDL 3.x.
|
||||||
*/
|
*/
|
||||||
#define SDL_VERSIONNUM(X, Y, Z) \
|
#define SDL_VERSIONNUM(X, Y, Z) \
|
||||||
((X)*1000 + (Y)*100 + (Z))
|
((X)*1000 + (Y)*100 + (Z))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the version number macro for the current SDL version.
|
* This is the version number macro for the current SDL version.
|
||||||
*
|
*
|
||||||
* In versions higher than 2.9.0, the minor version overflows into
|
* In versions higher than 2.9.0, the minor version overflows into the
|
||||||
* the thousands digit: for example, 2.23.0 is encoded as 4300.
|
* thousands digit: for example, 2.23.0 is encoded as 4300. This macro will
|
||||||
* This macro will not be available in SDL 3.x.
|
* not be available in SDL 3.x.
|
||||||
*
|
*
|
||||||
* Deprecated, use SDL_VERSION_ATLEAST or SDL_VERSION instead.
|
* Deprecated, use SDL_VERSION_ATLEAST or SDL_VERSION instead.
|
||||||
*/
|
*/
|
||||||
#define SDL_COMPILEDVERSION \
|
#define SDL_COMPILEDVERSION \
|
||||||
SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
|
SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
|
||||||
#endif /* SDL_MAJOR_VERSION < 3 */
|
#endif /* SDL_MAJOR_VERSION < 3 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This macro will evaluate to true if compiled with SDL at least X.Y.Z.
|
* This macro will evaluate to true if compiled with SDL at least X.Y.Z.
|
||||||
*/
|
*/
|
||||||
#define SDL_VERSION_ATLEAST(X, Y, Z) \
|
#define SDL_VERSION_ATLEAST(X, Y, Z) \
|
||||||
((SDL_MAJOR_VERSION >= X) && \
|
((SDL_MAJOR_VERSION >= X) && \
|
||||||
|
@@ -40,15 +40,15 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The structure that defines a display mode
|
* The structure that defines a display mode
|
||||||
*
|
*
|
||||||
* \sa SDL_GetNumDisplayModes()
|
* \sa SDL_GetNumDisplayModes
|
||||||
* \sa SDL_GetDisplayMode()
|
* \sa SDL_GetDisplayMode
|
||||||
* \sa SDL_GetDesktopDisplayMode()
|
* \sa SDL_GetDesktopDisplayMode
|
||||||
* \sa SDL_GetCurrentDisplayMode()
|
* \sa SDL_GetCurrentDisplayMode
|
||||||
* \sa SDL_GetClosestDisplayMode()
|
* \sa SDL_GetClosestDisplayMode
|
||||||
* \sa SDL_SetWindowDisplayMode()
|
* \sa SDL_SetWindowDisplayMode
|
||||||
* \sa SDL_GetWindowDisplayMode()
|
* \sa SDL_GetWindowDisplayMode
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_DisplayMode
|
typedef struct SDL_DisplayMode
|
||||||
{
|
{
|
||||||
@@ -60,44 +60,44 @@ typedef struct SDL_DisplayMode
|
|||||||
} SDL_DisplayMode;
|
} SDL_DisplayMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The type used to identify a window
|
* The type used to identify a window
|
||||||
*
|
*
|
||||||
* \sa SDL_CreateWindow()
|
* \sa SDL_CreateWindow
|
||||||
* \sa SDL_CreateWindowFrom()
|
* \sa SDL_CreateWindowFrom
|
||||||
* \sa SDL_DestroyWindow()
|
* \sa SDL_DestroyWindow
|
||||||
* \sa SDL_FlashWindow()
|
* \sa SDL_FlashWindow
|
||||||
* \sa SDL_GetWindowData()
|
* \sa SDL_GetWindowData
|
||||||
* \sa SDL_GetWindowFlags()
|
* \sa SDL_GetWindowFlags
|
||||||
* \sa SDL_GetWindowGrab()
|
* \sa SDL_GetWindowGrab
|
||||||
* \sa SDL_GetWindowKeyboardGrab()
|
* \sa SDL_GetWindowKeyboardGrab
|
||||||
* \sa SDL_GetWindowMouseGrab()
|
* \sa SDL_GetWindowMouseGrab
|
||||||
* \sa SDL_GetWindowPosition()
|
* \sa SDL_GetWindowPosition
|
||||||
* \sa SDL_GetWindowSize()
|
* \sa SDL_GetWindowSize
|
||||||
* \sa SDL_GetWindowTitle()
|
* \sa SDL_GetWindowTitle
|
||||||
* \sa SDL_HideWindow()
|
* \sa SDL_HideWindow
|
||||||
* \sa SDL_MaximizeWindow()
|
* \sa SDL_MaximizeWindow
|
||||||
* \sa SDL_MinimizeWindow()
|
* \sa SDL_MinimizeWindow
|
||||||
* \sa SDL_RaiseWindow()
|
* \sa SDL_RaiseWindow
|
||||||
* \sa SDL_RestoreWindow()
|
* \sa SDL_RestoreWindow
|
||||||
* \sa SDL_SetWindowData()
|
* \sa SDL_SetWindowData
|
||||||
* \sa SDL_SetWindowFullscreen()
|
* \sa SDL_SetWindowFullscreen
|
||||||
* \sa SDL_SetWindowGrab()
|
* \sa SDL_SetWindowGrab
|
||||||
* \sa SDL_SetWindowKeyboardGrab()
|
* \sa SDL_SetWindowKeyboardGrab
|
||||||
* \sa SDL_SetWindowMouseGrab()
|
* \sa SDL_SetWindowMouseGrab
|
||||||
* \sa SDL_SetWindowIcon()
|
* \sa SDL_SetWindowIcon
|
||||||
* \sa SDL_SetWindowPosition()
|
* \sa SDL_SetWindowPosition
|
||||||
* \sa SDL_SetWindowSize()
|
* \sa SDL_SetWindowSize
|
||||||
* \sa SDL_SetWindowBordered()
|
* \sa SDL_SetWindowBordered
|
||||||
* \sa SDL_SetWindowResizable()
|
* \sa SDL_SetWindowResizable
|
||||||
* \sa SDL_SetWindowTitle()
|
* \sa SDL_SetWindowTitle
|
||||||
* \sa SDL_ShowWindow()
|
* \sa SDL_ShowWindow
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_Window SDL_Window;
|
typedef struct SDL_Window SDL_Window;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief The flags on a window
|
* The flags on a window
|
||||||
*
|
*
|
||||||
* \sa SDL_GetWindowFlags()
|
* \sa SDL_GetWindowFlags
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_WindowFlags
|
typedef enum SDL_WindowFlags
|
||||||
{
|
{
|
||||||
@@ -131,7 +131,7 @@ typedef enum SDL_WindowFlags
|
|||||||
} SDL_WindowFlags;
|
} SDL_WindowFlags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Used to indicate that you don't care what the window position is.
|
* Used to indicate that you don't care what the window position is.
|
||||||
*/
|
*/
|
||||||
#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u
|
#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u
|
||||||
#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
|
#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
|
||||||
@@ -140,7 +140,7 @@ typedef enum SDL_WindowFlags
|
|||||||
(((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
|
(((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Used to indicate that the window position should be centered.
|
* Used to indicate that the window position should be centered.
|
||||||
*/
|
*/
|
||||||
#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u
|
#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u
|
||||||
#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X))
|
#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X))
|
||||||
@@ -149,7 +149,7 @@ typedef enum SDL_WindowFlags
|
|||||||
(((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
|
(((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Event subtype for window events
|
* Event subtype for window events
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_WindowEventID
|
typedef enum SDL_WindowEventID
|
||||||
{
|
{
|
||||||
@@ -180,7 +180,7 @@ typedef enum SDL_WindowEventID
|
|||||||
} SDL_WindowEventID;
|
} SDL_WindowEventID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Event subtype for display events
|
* Event subtype for display events
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_DisplayEventID
|
typedef enum SDL_DisplayEventID
|
||||||
{
|
{
|
||||||
@@ -192,7 +192,7 @@ typedef enum SDL_DisplayEventID
|
|||||||
} SDL_DisplayEventID;
|
} SDL_DisplayEventID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Display orientation
|
* Display orientation
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_DisplayOrientation
|
typedef enum SDL_DisplayOrientation
|
||||||
{
|
{
|
||||||
@@ -204,7 +204,7 @@ typedef enum SDL_DisplayOrientation
|
|||||||
} SDL_DisplayOrientation;
|
} SDL_DisplayOrientation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Window flash operation
|
* Window flash operation
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_FlashOperation
|
typedef enum SDL_FlashOperation
|
||||||
{
|
{
|
||||||
@@ -214,12 +214,12 @@ typedef enum SDL_FlashOperation
|
|||||||
} SDL_FlashOperation;
|
} SDL_FlashOperation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief An opaque handle to an OpenGL context.
|
* An opaque handle to an OpenGL context.
|
||||||
*/
|
*/
|
||||||
typedef void *SDL_GLContext;
|
typedef void *SDL_GLContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief OpenGL configuration attributes
|
* OpenGL configuration attributes
|
||||||
*/
|
*/
|
||||||
typedef enum SDL_GLattr
|
typedef enum SDL_GLattr
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user