SDL2/SDL3 compatibility layer. More...
#include <SDL.h>
Go to the source code of this file.
Namespaces | |
| namespace | yaze |
| namespace | yaze::platform |
Macros | |
| #define | YAZE_SDL_QUIT SDL_QUIT |
| #define | YAZE_SDL_WINDOWEVENT SDL_WINDOWEVENT |
| #define | YAZE_SDL_WINDOW_CLOSE SDL_WINDOWEVENT_CLOSE |
| #define | YAZE_SDL_WINDOW_RESIZED SDL_WINDOWEVENT_RESIZED |
| #define | YAZE_SDL_WINDOW_SIZE_CHANGED SDL_WINDOWEVENT_SIZE_CHANGED |
| #define | YAZE_SDL_WINDOW_MINIMIZED SDL_WINDOWEVENT_MINIMIZED |
| #define | YAZE_SDL_WINDOW_MAXIMIZED SDL_WINDOWEVENT_MAXIMIZED |
| #define | YAZE_SDL_WINDOW_RESTORED SDL_WINDOWEVENT_RESTORED |
| #define | YAZE_SDL_WINDOW_SHOWN SDL_WINDOWEVENT_SHOWN |
| #define | YAZE_SDL_WINDOW_HIDDEN SDL_WINDOWEVENT_HIDDEN |
| #define | YAZE_SDL_WINDOW_EXPOSED SDL_WINDOWEVENT_EXPOSED |
| #define | YAZE_SDL_WINDOW_FOCUS_GAINED SDL_WINDOWEVENT_FOCUS_GAINED |
| #define | YAZE_SDL_WINDOW_FOCUS_LOST SDL_WINDOWEVENT_FOCUS_LOST |
| #define | YAZE_SDL_HAS_INDIVIDUAL_WINDOW_EVENTS 0 |
Typedefs | |
| using | yaze::platform::KeyboardState = const Uint8* |
| using | yaze::platform::GamepadHandle = SDL_GameController* |
| using | yaze::platform::GamepadButton = SDL_GameControllerButton |
| using | yaze::platform::GamepadAxis = SDL_GameControllerAxis |
Functions | |
| SDL_Keycode | yaze::platform::GetKeyFromEvent (const SDL_Event &event) |
| Get keyboard state from SDL event. | |
| SDL_Scancode | yaze::platform::GetScancodeFromKey (SDL_Keycode key) |
| Get scancode from keycode. | |
| bool | yaze::platform::IsKeyPressed (KeyboardState state, SDL_Scancode scancode) |
| Check if a key is pressed using the keyboard state. | |
| GamepadHandle | yaze::platform::OpenGamepad (int index) |
| void | yaze::platform::CloseGamepad (GamepadHandle gamepad) |
| bool | yaze::platform::GetGamepadButton (GamepadHandle gamepad, SDL_GameControllerButton button) |
| int16_t | yaze::platform::GetGamepadAxis (GamepadHandle gamepad, SDL_GameControllerAxis axis) |
| bool | yaze::platform::IsGamepadConnected (int index) |
| SDL_Renderer * | yaze::platform::CreateRenderer (SDL_Window *window) |
| Create a renderer with default settings. | |
| void | yaze::platform::SetRenderVSync (SDL_Renderer *renderer, int interval) |
| Set vertical sync for the renderer. | |
| bool | yaze::platform::RenderTexture (SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_Rect *dstrect) |
| Render a texture to the current render target. | |
| void | yaze::platform::FreeSurface (SDL_Surface *surface) |
| Free/destroy a surface. | |
| SDL_Surface * | yaze::platform::ConvertSurfaceFormat (SDL_Surface *surface, uint32_t format, uint32_t flags=0) |
| Convert a surface to a specific pixel format. | |
| SDL_Palette * | yaze::platform::GetSurfacePalette (SDL_Surface *surface) |
| Get the palette attached to a surface. | |
| Uint32 | yaze::platform::GetSurfaceFormat (SDL_Surface *surface) |
| Get the pixel format of a surface as Uint32. | |
| Uint32 | yaze::platform::MapRGB (SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b) |
| Map an RGB color to the surface's pixel format. | |
| SDL_Surface * | yaze::platform::CreateSurface (int width, int height, int depth, uint32_t format) |
| Create a surface using the appropriate API. | |
| int | yaze::platform::GetSurfaceBitsPerPixel (SDL_Surface *surface) |
| Get bits per pixel from a surface. | |
| bool | yaze::platform::EnsureSurfacePalette256 (SDL_Surface *surface) |
| Ensure the surface has a proper 256-color palette for indexed formats. | |
| int | yaze::platform::GetSurfaceBytesPerPixel (SDL_Surface *surface) |
| Get bytes per pixel from a surface. | |
| bool | yaze::platform::IsWindowCloseEvent (const SDL_Event &event) |
| Check if an event is a window close event Works correctly for both SDL2 (nested) and SDL3 (individual) events. | |
| bool | yaze::platform::IsWindowResizeEvent (const SDL_Event &event) |
| Check if an event is a window resize event. | |
| bool | yaze::platform::IsWindowMinimizedEvent (const SDL_Event &event) |
| Check if an event is a window minimize event. | |
| bool | yaze::platform::IsWindowRestoredEvent (const SDL_Event &event) |
| Check if an event is a window restore event. | |
| int | yaze::platform::GetWindowEventWidth (const SDL_Event &event) |
| Get window width from resize event data. | |
| int | yaze::platform::GetWindowEventHeight (const SDL_Event &event) |
| Get window height from resize event data. | |
| bool | yaze::platform::InitSucceeded (int result) |
| Check if SDL initialization succeeded. | |
| uint32_t | yaze::platform::GetDefaultInitFlags () |
| Get recommended init flags. | |
| SDL_Surface * | yaze::platform::CreateRGBSurface (Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) |
| Create an RGB surface. | |
| void | yaze::platform::DestroySurface (SDL_Surface *surface) |
| Destroy a surface. | |
| int | yaze::platform::GetRendererOutputSize (SDL_Renderer *renderer, int *w, int *h) |
| Get renderer output size. | |
| SDL_Surface * | yaze::platform::ReadPixelsToSurface (SDL_Renderer *renderer, int width, int height, const SDL_Rect *rect) |
| Read pixels from renderer to a surface. | |
| SDL_Surface * | yaze::platform::LoadBMP (const char *file) |
| Load a BMP file. | |
Variables | |
| constexpr auto | yaze::platform::kEventKeyDown = SDL_KEYDOWN |
| constexpr auto | yaze::platform::kEventKeyUp = SDL_KEYUP |
| constexpr auto | yaze::platform::kEventMouseMotion = SDL_MOUSEMOTION |
| constexpr auto | yaze::platform::kEventMouseButtonDown = SDL_MOUSEBUTTONDOWN |
| constexpr auto | yaze::platform::kEventMouseButtonUp = SDL_MOUSEBUTTONUP |
| constexpr auto | yaze::platform::kEventMouseWheel = SDL_MOUSEWHEEL |
| constexpr auto | yaze::platform::kEventQuit = SDL_QUIT |
| constexpr auto | yaze::platform::kEventDropFile = SDL_DROPFILE |
| constexpr auto | yaze::platform::kEventWindowEvent = SDL_WINDOWEVENT |
| constexpr auto | yaze::platform::kEventControllerDeviceAdded = SDL_CONTROLLERDEVICEADDED |
| constexpr auto | yaze::platform::kEventControllerDeviceRemoved = SDL_CONTROLLERDEVICEREMOVED |
| constexpr auto | yaze::platform::kKeyA = SDLK_a |
| constexpr auto | yaze::platform::kKeyB = SDLK_b |
| constexpr auto | yaze::platform::kKeyC = SDLK_c |
| constexpr auto | yaze::platform::kKeyD = SDLK_d |
| constexpr auto | yaze::platform::kKeyS = SDLK_s |
| constexpr auto | yaze::platform::kKeyX = SDLK_x |
| constexpr auto | yaze::platform::kKeyY = SDLK_y |
| constexpr auto | yaze::platform::kKeyZ = SDLK_z |
| constexpr auto | yaze::platform::kKeyReturn = SDLK_RETURN |
| constexpr auto | yaze::platform::kKeyRShift = SDLK_RSHIFT |
| constexpr auto | yaze::platform::kKeyUp = SDLK_UP |
| constexpr auto | yaze::platform::kKeyDown = SDLK_DOWN |
| constexpr auto | yaze::platform::kKeyLeft = SDLK_LEFT |
| constexpr auto | yaze::platform::kKeyRight = SDLK_RIGHT |
| constexpr auto | yaze::platform::kGamepadButtonA = SDL_CONTROLLER_BUTTON_A |
| constexpr auto | yaze::platform::kGamepadButtonB = SDL_CONTROLLER_BUTTON_B |
| constexpr auto | yaze::platform::kGamepadButtonX = SDL_CONTROLLER_BUTTON_X |
| constexpr auto | yaze::platform::kGamepadButtonY = SDL_CONTROLLER_BUTTON_Y |
| constexpr auto | yaze::platform::kGamepadButtonBack = SDL_CONTROLLER_BUTTON_BACK |
| constexpr auto | yaze::platform::kGamepadButtonStart = SDL_CONTROLLER_BUTTON_START |
| constexpr auto | yaze::platform::kGamepadButtonLeftShoulder = SDL_CONTROLLER_BUTTON_LEFTSHOULDER |
| constexpr auto | yaze::platform::kGamepadButtonRightShoulder = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER |
| constexpr auto | yaze::platform::kGamepadButtonDpadUp = SDL_CONTROLLER_BUTTON_DPAD_UP |
| constexpr auto | yaze::platform::kGamepadButtonDpadDown = SDL_CONTROLLER_BUTTON_DPAD_DOWN |
| constexpr auto | yaze::platform::kGamepadButtonDpadLeft = SDL_CONTROLLER_BUTTON_DPAD_LEFT |
| constexpr auto | yaze::platform::kGamepadButtonDpadRight = SDL_CONTROLLER_BUTTON_DPAD_RIGHT |
| constexpr auto | yaze::platform::kGamepadAxisLeftX = SDL_CONTROLLER_AXIS_LEFTX |
| constexpr auto | yaze::platform::kGamepadAxisLeftY = SDL_CONTROLLER_AXIS_LEFTY |
SDL2/SDL3 compatibility layer.
This header provides cross-version compatibility between SDL2 and SDL3. It defines type aliases, macros, and wrapper functions that allow application code to work with both versions.
Definition in file sdl_compat.h.
| #define YAZE_SDL_QUIT SDL_QUIT |
Definition at line 548 of file sdl_compat.h.
| #define YAZE_SDL_WINDOWEVENT SDL_WINDOWEVENT |
Definition at line 549 of file sdl_compat.h.
| #define YAZE_SDL_WINDOW_CLOSE SDL_WINDOWEVENT_CLOSE |
Definition at line 552 of file sdl_compat.h.
| #define YAZE_SDL_WINDOW_RESIZED SDL_WINDOWEVENT_RESIZED |
Definition at line 553 of file sdl_compat.h.
| #define YAZE_SDL_WINDOW_SIZE_CHANGED SDL_WINDOWEVENT_SIZE_CHANGED |
Definition at line 554 of file sdl_compat.h.
| #define YAZE_SDL_WINDOW_MINIMIZED SDL_WINDOWEVENT_MINIMIZED |
Definition at line 555 of file sdl_compat.h.
| #define YAZE_SDL_WINDOW_MAXIMIZED SDL_WINDOWEVENT_MAXIMIZED |
Definition at line 556 of file sdl_compat.h.
| #define YAZE_SDL_WINDOW_RESTORED SDL_WINDOWEVENT_RESTORED |
Definition at line 557 of file sdl_compat.h.
| #define YAZE_SDL_WINDOW_SHOWN SDL_WINDOWEVENT_SHOWN |
Definition at line 558 of file sdl_compat.h.
| #define YAZE_SDL_WINDOW_HIDDEN SDL_WINDOWEVENT_HIDDEN |
Definition at line 559 of file sdl_compat.h.
| #define YAZE_SDL_WINDOW_EXPOSED SDL_WINDOWEVENT_EXPOSED |
Definition at line 560 of file sdl_compat.h.
| #define YAZE_SDL_WINDOW_FOCUS_GAINED SDL_WINDOWEVENT_FOCUS_GAINED |
Definition at line 561 of file sdl_compat.h.
| #define YAZE_SDL_WINDOW_FOCUS_LOST SDL_WINDOWEVENT_FOCUS_LOST |
Definition at line 562 of file sdl_compat.h.
| #define YAZE_SDL_HAS_INDIVIDUAL_WINDOW_EVENTS 0 |
Definition at line 565 of file sdl_compat.h.