raylib — Custom cursor recipe

Hide the OS cursor and DrawTextureV your sprite each frame. The simplest possible custom-cursor pattern.

Recipe

#include "raylib.h"
int main() {
    InitWindow(800, 600, "raylib cursor");
    Texture2D cursor = LoadTexture("pointer.png");
    SetTextureFilter(cursor, TEXTURE_FILTER_POINT);
    HideCursor();
    while (!WindowShouldClose()) {
        BeginDrawing();
        ClearBackground(BLACK);
        DrawTextureV(cursor, GetMousePosition(), WHITE);
        EndDrawing();
    }
    UnloadTexture(cursor);
    CloseWindow();
}

Notes

This is the minimum viable code to ship a custom cursor in raylib. It does not handle per-state cursors (hover, drag, busy) — for that, see the matching tutorial linked below. It also assumes your cursor PNG is imported with point/nearest filtering; if your engine defaults to bilinear, the cursor will look fuzzy on HiDPI.

Hotspot tuning

Every snippet above passes a hotspot vector (often (4, 4) for an arrow, (8, 8) for a hand). The hotspot is the pixel inside the image that counts as the click point. If your cursor "feels off," adjust by single pixels. The hotspot tuning tutorial has the full debugging workflow.

Where to get a cursor pack

If you have not designed a cursor yet, browse CursorCraft collections for ready-made packs, or pick a free CC0 pack from the community assets page. The design-your-own tutorial walks through making one from scratch.