Added colorspace to SDL_CameraSpec

This commit is contained in:
Sam Lantinga
2024-06-12 11:18:26 -07:00
parent 98499d6818
commit aeea819494
10 changed files with 407 additions and 167 deletions

View File

@@ -274,8 +274,18 @@ int SDL_AppIterate(void *appstate)
SDL_DestroyTexture(texture);
}
SDL_Colorspace colorspace = SDL_COLORSPACE_UNKNOWN;
SDL_GetSurfaceColorspace(frame_current, &colorspace);
/* Create texture with appropriate format */
texture = SDL_CreateTexture(renderer, frame_current->format->format, SDL_TEXTUREACCESS_STREAMING, frame_current->w, frame_current->h);
SDL_PropertiesID props = SDL_CreateProperties();
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER, frame_current->format->format);
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER, colorspace);
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER, SDL_TEXTUREACCESS_STREAMING);
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER, frame_current->w);
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER, frame_current->h);
texture = SDL_CreateTextureWithProperties(renderer, props);
SDL_DestroyProperties(props);
if (!texture) {
SDL_Log("Couldn't create texture: %s", SDL_GetError());
return SDL_APP_FAILURE;