SDL_UpdateNVTexture(3)
π SDL_UpdateNVTexture β the glow-up your NV12/NV21 texture deserves π
okay bestie, so this one lives in the SDL3 FUNCTIONS section of the manual, and it's literally the "my pixel planes are NOT cuddling in one contiguous block" edition of texture updating. slay.
β¨ NAME β¨
SDL_UpdateNVTexture β update a rectangle within a planar NV12 or NV21 texture with new pixels. no cap, that's the whole gig π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_render.h>
bool SDL_UpdateNVTexture(SDL_Texture *texture,
const SDL_Rect *rect,
const Uint8 *Yplane, int Ypitch,
const Uint8 *UVplane, int UVpitch);
β¨ DESCRIPTION β¨
so here's the tea π« β you can just use SDL_UpdateTexture() as long as your pixel data is one contiguous block of NV12/21 planes sitting in the proper order. that's the easy route.
but if your pixel data is not contiguous? if your planes are living separate lives, doing their own thing, not sharing a memory block? that's when this function shows up like the main character. it's here for exactly that situation. periodt. π
β¨ FUNCTION PARAMETERS β¨
textureβ the texture you're updating. your canvas, your moment, your icon πrectβ a pointer to the rectangle of pixels you wanna update. or passNULLto update the entire texture, go big or go home πYplaneβ the raw pixel data for the Y plane. the real ones. π¦Ypitchβ the number of bytes between rows of pixel data for the Y plane. how far apart the rows are emotionally (and in memory) πUVplaneβ the raw pixel data for the UV plane. the supporting cast that's actually essential πΈUVpitchβ the number of bytes between rows of pixel data for the UV plane. same deal, different plane β¨
β¨ RETURN VALUE β¨
returns true on success or false on failure π₯² and if it fails, call SDL_GetError() for more info β she will tell you what went wrong, she's not shy.
β¨ THREAD SAFETY β¨
π¨ bestie listen. this function should only be called on the main thread. no side quests, no background threads, no "but it worked that one time." main thread only. that's the vibe check and you passed it by reading this. β
β¨ AVAILABILITY β¨
this function is available since SDL 3.2.0. if you're on something older, it's giving... not available. π
β¨ SEE ALSO β¨
go read those too, they're the sister functions and they ate π β¨
and that's the whole page, bestie!! brought to you by Simple Directmedia Layer, version SDL 3.4.18 π«Ά go forth and update those NV12/NV21 planes, you absolute legend ππβ
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms