Define SDL_PLATFORM_* macros instead of underscored ones (#8875)
This commit is contained in:
committed by
GitHub
parent
ceccf24519
commit
31d133db40
@@ -13,11 +13,17 @@ rename_symbols.py --all-symbols source_code_path
|
||||
|
||||
It's also possible to apply a semantic patch to migrate more easily to SDL3: [SDL_migration.cocci](https://github.com/libsdl-org/SDL/blob/main/build-scripts/SDL_migration.cocci)
|
||||
|
||||
SDL headers should now be included as `#include <SDL3/SDL.h>`. Typically that's the only header you'll need in your application unless you are using OpenGL or Vulkan functionality. We have provided a handy Python script [rename_headers.py](https://github.com/libsdl-org/SDL/blob/main/build-scripts/rename_headers.py) to rename SDL2 headers to their SDL3 counterparts:
|
||||
SDL headers should now be included as `#include <SDL3/SDL.h>`. Typically that's the only SDL header you'll need in your application unless you are using OpenGL or Vulkan functionality. SDL_image, SDL_mixer, SDL_net, SDL_ttf and SDL_rtf have also their preferred include path changed: for SDL_image, it becomes `#include <SDL3_image/SDL_image.h>`. We have provided a handy Python script [rename_headers.py](https://github.com/libsdl-org/SDL/blob/main/build-scripts/rename_headers.py) to rename SDL2 headers to their SDL3 counterparts:
|
||||
```sh
|
||||
rename_headers.py source_code_path
|
||||
```
|
||||
|
||||
Some macros are renamed and/or removed in SDL3. We have provided a handy Python script [rename_macros.py](https://github.com/libsdl-org/SDL/blob/main/build-scripts/rename_macros.py) to replace these, and also add fixme comments on how to further improve the code:
|
||||
```sh
|
||||
rename_macros.py source_code_path
|
||||
```
|
||||
|
||||
|
||||
CMake users should use this snippet to include SDL support in their project:
|
||||
```
|
||||
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
|
||||
@@ -932,7 +938,49 @@ The following symbols have been renamed:
|
||||
|
||||
## SDL_platform.h
|
||||
|
||||
The preprocessor symbol `__MACOSX__` has been renamed `__MACOS__`, and `__IPHONEOS__` has been renamed `__IOS__`
|
||||
The following platform preprocessor macros have been removed:
|
||||
* __DREAMCAST__
|
||||
* __NACL__
|
||||
* __PNACL__
|
||||
|
||||
The following platform preprocessor macros have been renamed:
|
||||
|
||||
| SDL2 | SDL3 |
|
||||
|-------------------|---------------------------|
|
||||
| `__3DS__` | `SDL_PLATFORM_3DS` |
|
||||
| `__AIX__` | `SDL_PLATFORM_AIX` |
|
||||
| `__ANDROID__` | `SDL_PLATFORM_ANDROID` |
|
||||
| `__APPLE__` | `SDL_PLATFORM_APPLE` |
|
||||
| `__BSDI__` | `SDL_PLATFORM_BSDI` |
|
||||
| `__CYGWIN_` | `SDL_PLATFORM_CYGWIN` |
|
||||
| `__EMSCRIPTEN__` | `SDL_PLATFORM_EMSCRIPTEN` |
|
||||
| `__FREEBSD__` | `SDL_PLATFORM_FREEBSD` |
|
||||
| `__GDK__` | `SDL_PLATFORM_GDK` |
|
||||
| `__HAIKU__` | `SDL_PLATFORM_HAIKU` |
|
||||
| `__HPUX__` | `SDL_PLATFORM_HPUX` |
|
||||
| `__IPHONEOS__` | `SDL_PLATFORM_IOS` |
|
||||
| `__IRIX__` | `SDL_PLATFORM_IRIX` |
|
||||
| `__LINUX__` | `SDL_PLATFORM_LINUX` |
|
||||
| `__MACOSX__` | `SDL_PLATFORM_MACOS` |
|
||||
| `__NETBSD__` | `SDL_PLATFORM_NETBSD` |
|
||||
| `__NGAGE__` | `SDL_PLATFORM_NGAGE` |
|
||||
| `__OPENBSD__` | `SDL_PLATFORM_OPENBSD` |
|
||||
| `__OS2__` | `SDL_PLATFORM_OS2` |
|
||||
| `__OSF__` | `SDL_PLATFORM_OSF` |
|
||||
| `__PS2__` | `SDL_PLATFORM_PS2` |
|
||||
| `__PSP__` | `SDL_PLATFORM_PSP` |
|
||||
| `__QNXNTO__` | `SDL_PLATFORM_QNXNTO` |
|
||||
| `__RISCOS__` | `SDL_PLATFORM_RISCOS` |
|
||||
| `__SOLARIS__` | `SDL_PLATFORM_SOLARIS` |
|
||||
| `__TVOS__` | `SDL_PLATFORM_TVOS` |
|
||||
| `__unix__` | `SDL_PLATFORM_UNI` |
|
||||
| `__VITA__` | `SDL_PLATFORM_VITA` |
|
||||
| `__WIN32__` | `SDL_PLATFORM_WINRT` |
|
||||
| `__WINDOWS__` | `SDL_PLATFORM_WINDOWS` |
|
||||
| `__WINGDK__` | `SDL_PLATFORM_WINGDK` |
|
||||
| `__WINRT__` | `SDL_PLATFORM_WINRT` |
|
||||
| `__XBOXONE__` | `SDL_PLATFORM_XBOXONE` |
|
||||
| `__XBOXSERIES__` | `SDL_PLATFORM_XBOXSERIES` |
|
||||
|
||||
## SDL_rect.h
|
||||
|
||||
@@ -1360,7 +1408,7 @@ The information previously available in SDL_GetWindowWMInfo() is now available a
|
||||
if (nswindow) {
|
||||
...
|
||||
}
|
||||
#elif defined(__LINUX__)
|
||||
#elif defined(SDL_PLATFORM_LINUX)
|
||||
if (SDL_GetWindowWMInfo(window, &info)) {
|
||||
if (info.subsystem == SDL_SYSWM_X11) {
|
||||
Display *xdisplay = info.info.x11.display;
|
||||
@@ -1380,17 +1428,17 @@ The information previously available in SDL_GetWindowWMInfo() is now available a
|
||||
```
|
||||
becomes:
|
||||
```c
|
||||
#if defined(__WIN32__)
|
||||
#if defined(SDL_PLATFORM_WIN32)
|
||||
HWND hwnd = (HWND)SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROPERTY_WINDOW_WIN32_HWND_POINTER, NULL);
|
||||
if (hwnd) {
|
||||
...
|
||||
}
|
||||
#elif defined(__MACOS__)
|
||||
#elif defined(SDL_PLATFORM_MACOS)
|
||||
NSWindow *nswindow = (__bridge NSWindow *)SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROPERTY_WINDOW_COCOA_WINDOW_POINTER, NULL);
|
||||
if (nswindow) {
|
||||
...
|
||||
}
|
||||
#elif defined(__LINUX__)
|
||||
#elif defined(SDL_PLATFORM_LINUX)
|
||||
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) {
|
||||
Display *xdisplay = (Display *)SDL_GetProperty(SDL_GetWindowProperties(window), SDL_PROPERTY_WINDOW_X11_DISPLAY_POINTER, NULL);
|
||||
Window xwindow = (Window)SDL_GetNumberProperty(SDL_GetWindowProperties(window), SDL_PROPERTY_WINDOW_X11_WINDOW_NUMBER, 0);
|
||||
|
||||
Reference in New Issue
Block a user