SDL_GPUTextureCreateInfo(3type)

πŸ’– SDL_GPUTextureCreateInfo πŸ’–

okay bestie, sit down, hydrate, because we're about to talk about the blueprint for every texture you'll ever make in SDL3's GPU API. this is a structure specifying the parameters of a texture β€” and yes it lives in the SDL3 DATATYPES section of the man pages, so you already know it's giving main character energy. ✨


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_gpu.h>

typedef struct SDL_GPUTextureCreateInfo
{
    SDL_GPUTextureType type;          /**< The base dimensionality of the texture. */
    SDL_GPUTextureFormat format;      /**< The pixel format of the texture. */
    SDL_GPUTextureUsageFlags usage;   /**< How the texture is intended to be used by the client. */
    Uint32 width;                     /**< The width of the texture. */
    Uint32 height;                    /**< The height of the texture. */
    Uint32 layer_count_or_depth;      /**< The layer count or depth of the texture. This value is treated as a layer count on 2D array textures, and as a depth value on 3D textures. */
    Uint32 num_levels;                /**< The number of mip levels in the texture. */
    SDL_GPUSampleCount sample_count;  /**< The number of samples per texel. Only applies if the texture is used as a render target. */

    SDL_PropertiesID props;           /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
} SDL_GPUTextureCreateInfo;

✨ DESCRIPTION ✨

so basically this struct is the lil form you fill out before the GPU gods hand you a texture. every field is a vibe check, and the texture you get back is exactly as iconic as the form you submitted. πŸ’…

one thing you need to know, no cap: usage flags can be bitwise OR'd together for combinations of usages. OR it up, bestie, mix and match, go feral. πŸŽ€

⚠️ BUT. and this is a big but. certain usage combinations are invalid β€” for example SAMPLER and GRAPHICS_STORAGE. the way that these two simply cannot coexist… it's giving enemies to lovers except they never get together. 😭 pick a lane or the call will fail on you fr fr.

🧚 the fields, one by one 🧚

  • type β€” a SDL_GPUTextureType. this is the base dimensionality of your texture. is it 2D? 3D? cube? that's a whole separate type, go read it. 🌈
  • format β€” a SDL_GPUTextureFormat. the pixel format of the texture. what's actually inside each pixel, the lore, the texture of the texture. πŸ“
  • usage β€” a SDL_GPUTextureUsageFlags. how the texture is intended to be used by the client. remember the OR-ing thing and the invalid-combo thing from above? this is that field. don't forget it. πŸ™ˆ
  • width β€” a Uint32. the width of the texture. yes. that's it. she's straightforward. ✨
  • height β€” a Uint32. the height of the texture. equally straightforward. slay. πŸ’…
  • layer_count_or_depth β€” a Uint32. the layer count or depth of the texture. okay this one has range: the value is treated as a layer count on 2D array textures, and as a depth value on 3D textures. one field, two jobs, she works hard. πŸ‘‘
  • num_levels β€” a Uint32. the number of mip levels in the texture. mipmaps, bestie. it's the tiny versions of your texture that make it look good from far away. iconic behavior honestly. πŸ¦‹
  • sample_count β€” a SDL_GPUSampleCount. the number of samples per texel. and heads up: this only applies if the texture is used as a render target. if you're not render-targeting, she does nothing. read the room. 🌸
  • props β€” a SDL_PropertiesID. a properties ID for extensions. should be 0 if no extensions are needed. default behavior is 0, don't overthink it, just put 0 and move on. πŸ’œ

⭐ AVAILABILITY ⭐

this struct is available since SDL 3.2.0. so if you're on anything older… girl. upgrade. 😭


🌈 SEE ALSO 🌈

go read these next, they're all connected, it's a whole cinematic universe:


and that's the whole page bestie, you ate it up, no crumbs left. 🫢

this lil masterpiece came to you courtesy of Simple Directmedia Layer, version SDL 3.4.18, dated right alongside SDL_GPUTextureCreateInfo(3type) β€” iykyk. go make something gorgeous with it. πŸ’–πŸ”₯πŸ‘‘

πŸ“¦ where this page comes from