SDL_CreateColorCursor(3)
π SDL_CreateColorCursor β like, the color cursor maker π
okay bestie, gather round, because this one lives in the SDL3 FUNCTIONS section of the manual and it's literally the glow-up your mouse pointer has been waiting for. Say hi to SDL_CreateColorCursor(3). π¦
β¨ NAME β¨
SDL_CreateColorCursor β Create a color cursor.
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_mouse.h>
SDL_Cursor * SDL_CreateColorCursor(SDL_Surface *surface,
int hot_x,
int hot_y);
π DESCRIPTION π
So here's the tea, and it's giving high-DPI main character energy. If you hand this function a surface that's got alternate representations added onto it via SDL_AddSurfaceAlternateImage(), then that surface is the one that gets interpreted as the content for 100% display scale. Meanwhile the alternate representations get used for high DPI situations β but only if SDL_HINT_MOUSE_DPI_SCALE_CURSORS is enabled. iykyk. π
Example time, because examples ate: if your original surface is 32x32, then on a 2x macOS display, or a 200% display scale on Windows, a 64x64 version of the image will be used β if one's available. β¨
And if a matching version of the image isn't available? No worries, it's not a crisis. The closest larger size image will be downscaled to the appropriate size and used instead, if available. And if even that's not available? Then the closest smaller image gets upscaled and used instead. Adaptive queen behavior fr fr. π
π«Ά FUNCTION PARAMETERS π«Ά
surfaceβ anSDL_Surfacestructure representing the cursor image. Like, the actual picture of your cursor. πΌοΈhot_xβ the x position of the cursor hot spot. This is the pixel that's actually "clicking", so pick wisely bestie. π―hot_yβ the y position of the cursor hot spot. Same deal, vertical edition. π―
β RETURN VALUE β
Returns the new cursor on success, or NULL on failure. π And if it fails, call SDL_GetError() for more information β she will tell you what went wrong, no gatekeeping.
π THREAD SAFETY π
This function should only be called on the main thread. No sneaking it onto a worker thread, bestie, I'm serious. π«π§΅
π AVAILABILITY π
This function is available since SDL 3.2.0. So if you're on something older, it's not you, it's the version. π
π SEE ALSO π
SDL_AddSurfaceAlternateImage(3)SDL_CreateAnimatedCursor(3)SDL_CreateCursor(3)SDL_CreateSystemCursor(3)SDL_DestroyCursor(3)SDL_SetCursor(3)
and that's the whole page, periodt. π this icon was brought to you by Simple Directmedia Layer, running on SDL 3.4.18 β same energy, same date stamp, just with way better vibes. go make something cute with it, 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