SDL_SetCursor(3)

✨ SDL_SetCursor ✨

okay bestie, welcome to the SDL3 FUNCTIONS corner of the man pages πŸ’– this one's SDL_SetCursor(3) and it's literally about making your cursor be the cursor. yes queen, cursor management. we love to see it 🫢


🌸 NAME 🌸

SDL_SetCursor β€” set the active cursor. that's it. that's the whole job. main character energy only πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_mouse.h>

bool SDL_SetCursor(SDL_Cursor *cursor);

like, include the header, call the function, cursor happens ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so the way this works is: this function sets the currently active cursor to the one you hand it. simple as that, no cap.

and if the cursor is currently visible? the change shows up on the display immediately β€” no waiting, no refresh, it just appears. iconic behaviour fr fr πŸ’…

also, plot twist that is lowkey useful: SDL_SetCursor(NULL) can be used to force a cursor redraw, if that's something you want for any reason. yes, passing NULL on purpose. it's giving "chaos but make it intentional" 😌


🌈 FUNCTION PARAMETERS 🌈

  • cursor β€” a cursor to make active. that's your little guy. your pointer protagonist. give it the spotlight 🌟

⭐ RETURN VALUE ⭐

returns true on success or false on failure 😭 and if it fails, bestie, you gotta call SDL_GetError() for more information. she will tell you what went wrong. always ask her. πŸ“


πŸ’œ THREAD SAFETY πŸ’œ

🚨 okay so this is important: this function should only be called on the main thread. no side-quest threads. no sneaky background thread energy. main thread or nothing, periodt. πŸ’€

🌸 AVAILABILITY 🌸

this function is available since SDL 3.2.0. so if you're on anything older, sorry babe, she's not there yet πŸ™ˆ


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie!! go forth and set those cursors πŸ’–βœ¨

Simple Directmedia Layer Β· SDL 3.4.18 Β· SDL_SetCursor(3) β€” mwah, catch you in the next man page, ily, bye!! πŸŽ€πŸ¦‹πŸ’…

πŸ“¦ where this page comes from