SDL_WriteU16BE(3)

πŸ’– SDL_WriteU16BE(3) β€” the SDL3 functions era πŸ’–

okay bestie, sit down, hydrate, and let me tell you about SDL_WriteU16BE from the SDL3 FUNCTIONS lineup πŸŽ€


✨ NAME ✨

SDL_WriteU16BE β€” the glow-up function you use to write 16 bits in native format into an SDL_IOStream, and have it come out the other side as big-endian data πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_iostream.h>

bool SDL_WriteU16BE(SDL_IOStream *dst, Uint16 value);

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the vibe: SDL byteswaps the data only if necessary. That means you β€” the application, the main character β€” always hand over the value in native format, and SDL handles the flipping so what actually gets written is in big-endian format. No cap. You don't do the byte math, SDL does. Iconic behaviour honestly πŸ‘‘


πŸ“ FUNCTION PARAMETERS πŸ“

  • dst β€” the stream to which data will be written 🫢
  • value β€” the data to be written, in native format ✨

πŸ’œ RETURN VALUE πŸ’œ

Returns true on a successful write, or false on failure 😭 β€” and if it's a fail, call SDL_GetError() for more information, because it will tell you what went wrong, fr fr.


πŸ”₯ THREAD SAFETY πŸ”₯

Do not use the same SDL_IOStream from two threads at once. That's it, that's the rule. Two threads, one stream = chaos, and not the cute kind πŸ’€

⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. If you're on anything older, bestie, it's giving "not yet" πŸ™ˆ


and that's the whole page!! brought to you by Simple Directmedia Layer, running SDL 3.4.18 β€” go write some big-endian bytes, you absolute legend πŸ‘‘πŸ’–βœ¨

πŸ“¦ where this page comes from