Added constant definitions for SDL properties

Fixes https://github.com/libsdl-org/SDL/issues/8622
This commit is contained in:
Sam Lantinga 2024-01-07 16:59:41 -08:00
parent 3deefa6b43
commit 1a13dae219
30 changed files with 322 additions and 390 deletions

View file

@ -805,9 +805,9 @@ static void SDL_CalculateSimulatedVSyncInterval(SDL_Renderer *renderer, SDL_Wind
SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props)
{
#ifndef SDL_RENDER_DISABLED
SDL_Window *window = SDL_GetProperty(props, "window", NULL);
SDL_Surface *surface = SDL_GetProperty(props, "surface", NULL);
const char *name = SDL_GetStringProperty(props, "name", NULL);
SDL_Window *window = SDL_GetProperty(props, SDL_PROPERTY_RENDERER_CREATE_WINDOW_POINTER, NULL);
SDL_Surface *surface = SDL_GetProperty(props, SDL_PROPERTY_RENDERER_CREATE_SURFACE_POINTER, NULL);
const char *name = SDL_GetStringProperty(props, SDL_PROPERTY_RENDERER_CREATE_NAME_STRING, NULL);
SDL_Renderer *renderer = NULL;
const int n = SDL_GetNumRenderDrivers();
const char *hint;
@ -838,7 +838,7 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props)
hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
if (hint && *hint) {
SDL_SetBooleanProperty(props, "present_vsync", SDL_GetHintBoolean(SDL_HINT_RENDER_VSYNC, SDL_TRUE));
SDL_SetBooleanProperty(props, SDL_PROPERTY_RENDERER_CREATE_PRESENT_VSYNC_BOOLEAN, SDL_GetHintBoolean(SDL_HINT_RENDER_VSYNC, SDL_TRUE));
}
if (!name) {
@ -871,7 +871,7 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props)
goto error;
}
if (SDL_GetBooleanProperty(props, "present_vsync", SDL_FALSE)) {
if (SDL_GetBooleanProperty(props, SDL_PROPERTY_RENDERER_CREATE_PRESENT_VSYNC_BOOLEAN, SDL_FALSE)) {
renderer->wanted_vsync = SDL_TRUE;
if (!(renderer->info.flags & SDL_RENDERER_PRESENTVSYNC)) {
@ -947,14 +947,14 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, const char *name, Uint32 fl
{
SDL_Renderer *renderer;
SDL_PropertiesID props = SDL_CreateProperties();
SDL_SetProperty(props, "window", window);
SDL_SetProperty(props, SDL_PROPERTY_RENDERER_CREATE_WINDOW_POINTER, window);
if (flags & SDL_RENDERER_SOFTWARE) {
SDL_SetStringProperty(props, "name", "software");
SDL_SetStringProperty(props, SDL_PROPERTY_RENDERER_CREATE_NAME_STRING, "software");
} else {
SDL_SetStringProperty(props, "name", name);
SDL_SetStringProperty(props, SDL_PROPERTY_RENDERER_CREATE_NAME_STRING, name);
}
if (flags & SDL_RENDERER_PRESENTVSYNC) {
SDL_SetBooleanProperty(props, "present_vsync", SDL_TRUE);
SDL_SetBooleanProperty(props, SDL_PROPERTY_RENDERER_CREATE_PRESENT_VSYNC_BOOLEAN, SDL_TRUE);
}
renderer = SDL_CreateRendererWithProperties(props);
SDL_DestroyProperties(props);
@ -1124,10 +1124,10 @@ static SDL_ScaleMode SDL_GetScaleMode(void)
SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props)
{
SDL_Texture *texture;
Uint32 format = (Uint32)SDL_GetNumberProperty(props, "format", SDL_PIXELFORMAT_UNKNOWN);
int access = (int)SDL_GetNumberProperty(props, "access", SDL_TEXTUREACCESS_STATIC);
int w = (int)SDL_GetNumberProperty(props, "width", 0);
int h = (int)SDL_GetNumberProperty(props, "height", 0);
Uint32 format = (Uint32)SDL_GetNumberProperty(props, SDL_PROPERTY_TEXTURE_CREATE_FORMAT_NUMBER, SDL_PIXELFORMAT_UNKNOWN);
int access = (int)SDL_GetNumberProperty(props, SDL_PROPERTY_TEXTURE_CREATE_ACCESS_NUMBER, SDL_TEXTUREACCESS_STATIC);
int w = (int)SDL_GetNumberProperty(props, SDL_PROPERTY_TEXTURE_CREATE_WIDTH_NUMBER, 0);
int h = (int)SDL_GetNumberProperty(props, SDL_PROPERTY_TEXTURE_CREATE_HEIGHT_NUMBER, 0);
SDL_bool texture_is_fourcc_and_target;
CHECK_RENDERER_MAGIC(renderer, NULL);
@ -1244,10 +1244,10 @@ SDL_Texture *SDL_CreateTexture(SDL_Renderer *renderer, Uint32 format, int access
{
SDL_Texture *texture;
SDL_PropertiesID props = SDL_CreateProperties();
SDL_SetNumberProperty(props, "format", format);
SDL_SetNumberProperty(props, "access", access);
SDL_SetNumberProperty(props, "width", w);
SDL_SetNumberProperty(props, "height", h);
SDL_SetNumberProperty(props, SDL_PROPERTY_TEXTURE_CREATE_FORMAT_NUMBER, format);
SDL_SetNumberProperty(props, SDL_PROPERTY_TEXTURE_CREATE_ACCESS_NUMBER, access);
SDL_SetNumberProperty(props, SDL_PROPERTY_TEXTURE_CREATE_WIDTH_NUMBER, w);
SDL_SetNumberProperty(props, SDL_PROPERTY_TEXTURE_CREATE_HEIGHT_NUMBER, h);
texture = SDL_CreateTextureWithProperties(renderer, props);
SDL_DestroyProperties(props);
return texture;