SDL_GPUVertexAttribute(3type)

πŸ’… SDL_GPUVertexAttribute β€” ok bestie, let's talk vertex attributes

Manual name: SDL3 DATATYPES ✨ (yes it's a type page, not a function page, and that's on purpose, slay)


🌸 NAME 🌸

SDL_GPUVertexAttribute β€” a structure specifying a vertex attribute. it's giving "one little piece of data about one little vertex" πŸŽ€


✨ SYNOPSIS ✨

#include <SDL3/SDL_gpu.h>

typedef struct SDL_GPUVertexAttribute
{
    Uint32 location;                    /**< The shader input location index. */
    Uint32 buffer_slot;                 /**< The binding slot of the associated vertex buffer. */
    SDL_GPUVertexElementFormat format;  /**< The size and type of the attribute data. */
    Uint32 offset;                      /**< The byte offset of this attribute relative to the start of the vertex element. */
} SDL_GPUVertexAttribute;

okay so real quick, field by field, no gatekeeping 🫢

  • location β€” the shader input location index. this is the lil number that tells the shader which input slot you're feeding πŸ‘‘
  • buffer_slot β€” the binding slot of the associated vertex buffer. which buffer are we pulling from, bestie? πŸ¦‹
  • format β€” the size and type of the attribute data, as an SDL_GPUVertexElementFormat. it's giving "how big, and what kind" πŸ’–
  • offset β€” the byte offset of this attribute relative to the start of the vertex element. the little scootch from the beginning of the element 🌸

πŸ’œ DESCRIPTION πŸ’œ

THE ONE RULE: all vertex attribute locations provided to an SDL_GPUVertexInputState must be unique.

not me saying it twice because it matters. every single location you hand to an SDL_GPUVertexInputState has to be different from every other one. no duplicates, no twinning, no copy-paste oopsies. πŸ’€

bestie this is not a suggestion, it's a requirement. two attributes sharing a location is a vibe check you will FAIL. 😭

🌈 AVAILABILITY 🌈

this struct is available since SDL 3.2.0. periodt. πŸ’…


πŸŽ€ SEE ALSO πŸŽ€

go read those too, they're all in the same friend group πŸ’–


sign-off time ✨ brought to you by Simple Directmedia Layer, version SDL 3.4.18, and this page is literally titled SDL_GPUVertexAttribute(3type). ily, go slay your vertex buffers πŸ¦‹πŸ’œπŸŒΈ

πŸ“¦ where this page comes from