TTF_GetGPUTextDrawData(3)

✨ NAME ✨

TTF_GetGPUTextDrawData β€” bestie, this is the one that hands you the geometry data you need to actually draw your text. πŸ’–


πŸŽ€ HEADER FILE πŸŽ€

It lives in SDL3_ttf/SDL_ttf.h, duh. πŸ¦‹


🌸 SYNOPSIS 🌸

#include "SDL3_ttf/SDL_ttf.h"

TTF_GPUAtlasDrawSequence * TTF_GetGPUTextDrawData(TTF_Text *text);

πŸ’… DESCRIPTION πŸ’…

okay so first things first: your text must have been created using a TTF_TextEngine that came from

TTF_CreateGPUTextEngine()

like, that's non-negotiable bestie, that's the whole vibe check. πŸ”₯

Now for the coordinate situation, and this is the part where you gotta pay attention: the positive X-axis goes off to the right, and the positive Y-axis goes upwards β€” and that's true for both the vertex coordinates and the texture coordinates. It's giving very much the same convention the SDL_GPU API uses, so if you're already comfy there you're golden. ✨ But if you wanna use a different coordinate system? Then you gotta transform the vertices yourself, no cap. That's on you, not on this function. 😭

Oh and one more lil thing β€” if your text is looking blocky, use linear filtering. That's the fix, that's the tea. 🫢


🌈 FUNCTION PARAMETERS 🌈

  • text β€” the text you wanna draw. that's it, that's the parameter. πŸ‘‘

⭐ RETURN VALUE ⭐

It returns a TTF_GPUAtlasDrawSequence * β€” which is a NULL terminated linked list of TTF_GPUAtlasDrawSequence objects. πŸŽ€

And if things go sideways? You get NULL back when the text you passed in is empty, or in case of failure. Call SDL_GetError() for more info, she'll tell you what went wrong. πŸ’€


🧚 THREAD SAFETY 🧚

Real talk: call this on the thread that created the text. Don't be out here being messy across threads. πŸ™ˆ


πŸ‘‘ AVAILABILITY πŸ‘‘

This function has been available since SDL_ttf 3.0.0. Iconic behavior, honestly. πŸ’œ


πŸ¦‹ SEE ALSO πŸ¦‹


k bye bestie, go forth and render that text, you got this fr fr πŸ’–βœ¨πŸŒΈ

this lil love letter came to you from SDL_ttf 3.2.2 β€” mwah, xoxo πŸ’…

πŸ“¦ where this page comes from