SDL_GetWindowOpacity(3)

✨ SDL_GetWindowOpacity ✨

okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_GetWindowOpacity(3) β€” she's giving "how see-through is this window rn" energy πŸ’…


🌸 NAME 🌸

SDL_GetWindowOpacity β€” get the opacity of a window. that's it. that's the whole job. she tells you how transparent your window is and she does NOT elaborate 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3/SDL_video.h>

float SDL_GetWindowOpacity(SDL_Window *window);

look at her. one parameter. one float. no drama. iconic ✨


πŸ’– DESCRIPTION πŸ’–

So here's the vibe: you call this, you get the opacity. Simple.

But important caveat, bestie: if transparency isn't supported on this platform, then opacity will just be returned as 1.0f β€” and it will not throw an error at you. Like, no fuss, no drama, no SDL_GetError() moment. She just quietly hands you a fully opaque 1.0f and moves on. That's the whole note. don't @ me 😭


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • window β€” the window you want to pull the current opacity value from. give her the window, she gives you the number πŸͺŸ

πŸ’… RETURN VALUE πŸ’…

Returns the opacity, and the scale goes like this:

  • 0.0f β€” fully transparent, ghost mode, you can see right through her πŸ‘»
  • 1.0f β€” fully opaque, solid, no peeking through, periodt

orrrr -1.0f on failure πŸ’€ β€” and if that happens you gotta call SDL_GetError() for more info, because she's not gonna tell you what went wrong unprompted. go ask.


🧚 THREAD SAFETY 🧚

⚠️ main thread only, bestie. this function should only be called on the main thread. no side-quests, no background threads, no "but I thought it'd be fine." it will not be fine. stay on main. 😀

🌈 AVAILABILITY 🌈

this function has been available since SDL 3.2.0 β€” so if you're on something older, she simply does not exist yet for you, sorry πŸ“


πŸ‘‘ SEE ALSO πŸ‘‘

  • SDL_SetWindowOpacity(3) β€” the other half of the duo, the setter to this getter, the yin to her yang, go read it next 🫢

and that's the page, babe!! source is Simple Directmedia Layer, this is SDL 3.4.18 β€” the SDL_GetWindowOpacity(3) of it all, no date on the footer because she's timeless like that πŸ’œ thanks for reading, mwah, go check your window opacity responsibly βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from