SDL_CreateTe...ithProperties(3)

โœจ NAME โœจ

SDL_CreateTextureWithProperties โ€” bestie, this one makes you a texture for a rendering context, and you get to pick the properties. it's giving bespoke โœจ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <SDL3/SDL_render.h>

SDL_Texture * SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props);

๐Ÿ’… DESCRIPTION ๐Ÿ’…

okay so instead of passing a million boring args, you hand this girl a bag of properties and she builds your texture exactly how you like it. here's the supported properties, no cap ๐Ÿซถ

  • SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER โ€” an SDL_Colorspace value that says what colorspace the texture lives in. defaults? it's giving variety: SDL_COLORSPACE_SRGB_LINEAR for floating point textures, SDL_COLORSPACE_HDR10 for 10-bit textures, SDL_COLORSPACE_SRGB for other RGB textures, and SDL_COLORSPACE_JPEG for YUV textures. slay ๐ŸŒˆ
  • SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER โ€” one of the enumerated values in SDL_PixelFormat. defaults to the best RGBA format for the renderer ๐Ÿ’–
  • SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER โ€” one of the enumerated values in SDL_TextureAccess. defaults to SDL_TEXTUREACCESS_STATIC
  • SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER โ€” the width of the texture in pixels. required, not optional, she's not playing ๐Ÿ˜ค
  • SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER โ€” the height of the texture in pixels. also required fr fr
  • SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER โ€” an SDL_Palette to use with palettized texture formats. you can also set this later with SDL_SetTexturePalette() ๐ŸŽจ
  • SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT โ€” for HDR10 and floating point textures, this defines the value of 100% diffuse white, with higher values being displayed in the High Dynamic Range headroom. defaults to 100 for HDR10 textures and 1.0 for floating point textures ๐ŸŒŸ
  • SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT โ€” for HDR10 and floating point textures, this defines the maximum dynamic range used by the content, in terms of the SDR white point. this would be equivalent to maxCLL / SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT for HDR10 content. if this is defined, any values outside the range supported by the display will be scaled into the available HDR headroom, otherwise they are clipped. important little caveat, don't skip it ๐Ÿ’œ

๐ŸŽฎ With the direct3d11 renderer

  • SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER โ€” the ID3D11Texture2D associated with the texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER โ€” the ID3D11Texture2D associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER โ€” the ID3D11Texture2D associated with the V plane of a YUV texture, if you want to wrap an existing texture.

๐ŸŽฎ With the direct3d12 renderer

  • SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER โ€” the ID3D12Resource associated with the texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER โ€” the ID3D12Resource associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER โ€” the ID3D12Resource associated with the V plane of a YUV texture, if you want to wrap an existing texture.

๐ŸŽ With the metal renderer

  • SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER โ€” the CVPixelBufferRef associated with the texture, if you want to create a texture from an existing pixel buffer.

๐ŸŒˆ With the opengl renderer

  • SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER โ€” the GLuint texture associated with the texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER โ€” the GLuint texture associated with the UV plane of an NV12 texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER โ€” the GLuint texture associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER โ€” the GLuint texture associated with the V plane of a YUV texture, if you want to wrap an existing texture.

๐ŸŒธ With the opengles2 renderer

  • SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER โ€” the GLuint texture associated with the texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER โ€” the GLuint texture associated with the UV plane of an NV12 texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER โ€” the GLuint texture associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER โ€” the GLuint texture associated with the V plane of a YUV texture, if you want to wrap an existing texture.

๐Ÿฆ‹ With the vulkan renderer

  • SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER โ€” the VkImage associated with the texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_VULKAN_LAYOUT_NUMBER โ€” the VkImageLayout for the VkImage. defaults to VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL โœจ

๐Ÿ‘‘ With the GPU renderer

  • SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER โ€” the SDL_GPUTexture associated with the texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_NUMBER โ€” the SDL_GPUTexture associated with the UV plane of an NV12 texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_NUMBER โ€” the SDL_GPUTexture associated with the U plane of a YUV texture, if you want to wrap an existing texture.
  • SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_NUMBER โ€” the SDL_GPUTexture associated with the V plane of a YUV texture, if you want to wrap an existing texture.

๐Ÿซถ FUNCTION PARAMETERS ๐Ÿซถ

  • renderer โ€” the rendering context. your main character ๐Ÿ’ซ
  • props โ€” the properties to use. the whole vibe check, basically ๐ŸŽ€

๐Ÿ’€ RETURN VALUE ๐Ÿ’€

Returns the created texture, or NULL on failure. if it flops, call SDL_GetError() for more information โ€” she will tell you what went wrong, ngl ๐Ÿ˜ญ


๐Ÿ”’ THREAD SAFETY ๐Ÿ”’

This function should only be called on the main thread. no side-quests, no other threads, periodt โœ‹


โญ AVAILABILITY โญ

This function is available since SDL 3.2.0. so if you're on an older version... not me finding out the hard way ๐Ÿ™ˆ


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€


and that's the whole page bestie, every single property, every default, every required field, all of it. go make something iconic ๐Ÿ’œ

this has been your girl from Simple Directmedia Layer, serving SDL 3.4.18 โ€” mwah, ily, bye ๐Ÿซถโœจ๐Ÿ’…

๐Ÿ“ฆ where this page comes from