SDL_SetRenderColorScale(3)

πŸ’– SDL_SetRenderColorScale πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, this one's a lil glow-up function and it's literally called SDL_SetRenderColorScale(3) ✨


🌸 NAME 🌸

SDL_SetRenderColorScale β€” set the color scale used for render operations. that's it, that's the whole vibe πŸ’…


✨ SYNOPSIS ✨

#include <SDL3/SDL_render.h>

bool SDL_SetRenderColorScale(SDL_Renderer *renderer, float scale);

πŸŽ€ DESCRIPTION πŸŽ€

so the color scale is like, an extra scale that gets multiplied into the pixel color value while you're rendering. it's a whole extra layer of math happening on your colors, and she's doing the most 🫢

what's it for? two main girlboss use cases:

  • adjusting the brightness of colors during HDR rendering 🌈
  • changing HDR video brightness when you're playing on an SDR display πŸ‘‘

and the important part, the part you cannot skip, the part that's giving boundaries: the color scale does not touch the alpha channel. nope. not even a little. it only affects the color brightness, periodt. alpha stays exactly where she is πŸ’…


πŸ¦‹ FUNCTION PARAMETERS πŸ¦‹

  • renderer β€” the rendering context. your whole render situation, the main character 🎬
  • scale β€” the color scale value. a float, and this is the number doing the multiplying ✨

πŸ’œ RETURN VALUE πŸ’œ

returns true on success or false on failure 😭 β€” and if it fails, bestie, call SDL_GetError() for more information, she'll tell you what went wrong fr fr


🧚 THREAD SAFETY 🧚

⚠️ this function should only be called on the main thread. no side-quest threads on this one, okay? main thread only. don't try it. i'm watching πŸ‘€

⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0 β€” so if you're on something older than that, no she's not here yet, you gotta update 🌸


πŸ‘‘ SEE ALSO πŸ‘‘

  • SDL_GetRenderColorScale(3) β€” the lil sister function that reads the value back out, the way that they're a matching set, obsessed πŸ’–

and that's the whole page, you ate that πŸ“ go forth and scale your colors responsibly, iykyk 🌈✨

Simple Directmedia Layer β€” SDL 3.4.18 β€” and yeah, SDL_SetRenderColorScale(3) is the one and only, mwah πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from