SDL_WriteSurfacePixel(3)
β¨ SDL_WriteSurfacePixel β¨
okay bestie, welcome to the SDL_WriteSurfacePixel(3) page β part of the SDL3 FUNCTIONS collection, obviously π
πΈ NAME πΈ
SDL_WriteSurfacePixel β Writes a single pixel to a surface.
like... one pixel. a single lil guy. that's the whole job π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_surface.h>
bool SDL_WriteSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
π¦ DESCRIPTION π¦
okay so here's the vibe: this function is prioritizing correctness over speed. it's not trying to be fast, it's trying to be right. so it's giving very much unit tests energy β but not intended for use in a game engine, bestie, please don't ship it in your render loop π
and lowkey important: like SDL_MapRGBA, this uses the entire 0..255 range when converting color components from pixel formats with less than 8 bits per RGB component. so no weird half-range shenanigans, it's full range, no cap β¨
π FUNCTION PARAMETERS π
surfaceβ the surface to write to. your canvas, your moment, your main character π«Άxβ the horizontal coordinate,0 <= x < width. stay in bounds pls πyβ the vertical coordinate,0 <= y < height. same energy, vertical edition πrβ the red channel value,0-255. β€οΈgβ the green channel value,0-255. πbβ the blue channel value,0-255. πaβ the alpha channel value,0-255. π»
β RETURN VALUE β
Returns true on success or false on failure π₯² β and if it fails, call SDL_GetError() for more information. she will tell you what went wrong, periodt.
π§ THREAD SAFETY π§
This function can be called on different threads with different surfaces. so like, go off, parallelize β just keep your surfaces separate, iykyk π
πΈ AVAILABILITY πΈ
This function is available since SDL 3.2.0. so if you're on anything older... girl. upgrade π
no cap: it's correctness-first on purpose. don't be out here using it in a game engine and then acting surprised, bestie π
Simple Directmedia Layer Β· SDL 3.4.18 Β· SDL_WriteSurfacePixel(3)
and that's the whole page, mwah π tysm for reading, go write exactly one pixel and slay ππ¦β¨
π¦ 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