SDL_CreateAnimatedCursor(3)
β¨ SDL_CreateAnimatedCursor β¨
okay bestie, so this is a page from the SDL3 FUNCTIONS manual and it's literally all about making your mouse cursor move. yes. animated. cursor. the little arrow gets a glow-up π
πΈ NAME πΈ
SDL_CreateAnimatedCursor β create an animated color cursor. that's it, that's the whole vibe π
π¦ SYNOPSIS π¦
#include <SDL3/SDL_mouse.h>
SDL_Cursor* SDL_CreateAnimatedCursor(SDL_CursorFrameInfo *frames,
int frame_count,
int hot_x,
int hot_y);
π DESCRIPTION π
so the tea is: animated cursors are made of a sequential array of frames, and you specify them as surfaces plus durations inside an array of SDL_CursorFrameInfo structs. like a little flipbook but for your pointer. iconic honestly π«Ά
the hot spot coordinates are universal to all frames β one hot spot to rule them all β and ngl all the frames have to have the same dimensions. no mixing sizes, bestie, it's giving consistency queen π
frame durations are specified in milliseconds. and here's the important part: a duration of 0 implies an infinite frame time, and the animation will stop on that frame. so if you want a one-shot animation? set the duration of the last frame in the sequence to 0. periodt π
π¨ lowkey important: that 0 duration means the animation halts right there. it's not a sneaky little pause, it's the end of the road.
if this function is passed surfaces with alternate representations added with SDL_AddSurfaceAlternateImage(), then those surfaces get interpreted as the content used for 100% display scale, and the alternate representations get used for high DPI situations. for example (and I'm quoting the math here, no cap): if the original surfaces are 32x32, then on a 2x macOS display or 200% display scale on Windows, a 64x64 version of the image will be used, if available. and if a matching version of the image isn't available? the closest larger size image will be downscaled to the appropriate size and be used instead, if available. otherwise, the closest smaller image will be upscaled and be used instead. so it's got a whole backup plan, main character energy fr fr β¨
and if the underlying platform does not support animated cursors, this function will fall back to creating a static color cursor using the first frame in the sequence. so you're never left with nothing, she always shows up π
π FUNCTION PARAMETERS π
framesβ an array of cursor images composing the animation. the whole cast, the ensemble π¬frame_countβ the number of frames in the sequence. how many besties are in this lineup π«hot_xβ the x position of the cursor hot spot. the exact spot where the click actually lands, x edition πhot_yβ the y position of the cursor hot spot. same energy, y axis π
β RETURN VALUE β
returns the new cursor on success, or NULL on failure. and if it's NULL? call SDL_GetError() for more information β she will tell you what went wrong, just ask her π
π THREAD SAFETY π
this function should only be called on the main thread. no side quests, no other threads, this one's a main-thread-only girly π
π AVAILABILITY π
this function is available since SDL 3.4.0. so if you're on anything older, bestie, you're not invited to this party π
π₯ SEE ALSO π₯
SDL_AddSurfaceAlternateImage(3)SDL_CreateCursor(3)SDL_CreateColorCursor(3)SDL_CreateSystemCursor(3)SDL_DestroyCursor(3)SDL_SetCursor(3)
and that's the whole page, no notes π this one came to you courtesy of Simple Directmedia Layer, straight from SDL 3.4.18. go make a cursor that slays, bestie π¦β¨π
π¦ 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