#!/usr/bin/env dub
/+ dub.sdl:
name "cursor-shapes"
description "Hover/click tiles to exercise raylib SetMouseCursor / GLFW standard shapes"
targetType "executable"
targetPath "build"
dependency "raylib-d" version="~>6.0.1"
libs "raylib"
+/
/// Click / hover the tiles to ask raylib (`SetMouseCursor`) for each standard
/// pointer shape. Stock GLFW 3.5.1 fails most of these on GNOME/Adwaita;
/// the sparkles glfw overlay (wp_cursor_shape_v1) is what makes them work.
/// See index.md.
module (module) cursor_shapesClick / hover the tiles to ask raylib (SetMouseCursor) for each standard
pointer shape. Stock GLFW 3.5.1 fails most of these on GNOME/Adwaita;
the sparkles glfw overlay (wp_cursor_shape_v1) is what makes them work.
See index.md.
cursor_shapes;
import (module) raylibraylib v6.0 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
FEATURES
NO external dependencies, all required libraries included with raylib
Multiplatform: Windows, Linux, macOS, FreeBSD, Web, Android, Raspberry Pi, DRM native...
Written in plain C code (C99) in PascalCase/camelCase notation
Hardware accelerated with OpenGL (1.1, 2.1, 3.3, 4.3, ES2, ES3 - choose at compile)
Software renderer optional, for systems with no GPU: rlsw
Custom OpenGL abstraction layer (usable as standalone module): rlgl
Multiple Fonts formats supported (TTF, OTF, FNT, BDF, Sprite fonts)
Many texture formats supported, including compressed formats (DXT, ETC, ASTC)
Full 3d support for 3d Shapes, Models, Billboards, Heightmaps and more!
Flexible Materials system, supporting classic maps and PBR maps
Animated 3D models supported (skeletal bones animation) (IQM, M3D, GLTF)
Shaders support, including Model shaders and Postprocessing shaders
Powerful math module for Vector, Matrix and Quaternion operations: raymath
Audio loading and playing with streaming support (WAV, OGG, MP3, FLAC, QOA, XM, MOD)
VR stereo rendering with configurable HMD device parameters
Bindings to multiple programming languages available!
NOTES
One default Font is loaded on InitWindow()->LoadFontDefault() core, text
One default Texture2D is loaded on rlglInit(), 1x1 white pixel R8G8B8A8 rlgl (OpenGL 3.3 or ES2)
One default Shader is loaded on rlglInit()->rlLoadShaderDefault() rlgl (OpenGL 3.3 or ES2)
One default RenderBatch is loaded on rlglInit()->rlLoadRenderBatch() rlgl (OpenGL 3.3 or ES2)
DEPENDENCIES
rcore Depends on the selected platform backend, check rcore.c header for details
rlgl glad/glad_gles2 (David Herberth - github.com/Dav1dde/glad) for OpenGL extensions loading
raudio miniaudio (David Reid - github.com/mackron/miniaudio) for audio device/context management
OPTIONAL DEPENDENCIES (included):
rcore sinfl (Micha Mettke) for DEFLATE decompression algorithm
rcore sdefl (Micha Mettke) for DEFLATE compression algorithm
rcore rprand (Ramon Santamaria) for pseudo-random numbers generation
rtextures qoi (Dominic Szablewski - https://phoboslab.org) for QOI image management
rtextures stb_image (Sean Barrett) for images loading (BMP, TGA, PNG, JPEG, HDR...)
rtextures stb_image_write (Sean Barrett) for image writing (BMP, TGA, PNG, JPG)
rtextures stb_image_resize2 (Sean Barrett) for image resizing algorithms
rtextures stb_perlin (Sean Barrett) for Perlin Noise image generation
rtextures rltexgpu (Ramon Santamaria) for GPU-compressed texture formats
rtext stb_truetype (Sean Barrett) for ttf fonts loading
rtext stb_rect_pack (Sean Barrett) for rectangles packing
rmodels par_shapes (Philip Rideout) for parametric 3d shapes generation
rmodels tinyobj_loader_c (Syoyo Fujita) for models loading (OBJ, MTL)
rmodels cgltf (Johannes Kuhlmann) for models loading (glTF)
rmodels m3d (bzt) for models loading (M3D, https://bztsrc.gitlab.io/model3d)
rmodels vox_loader (Johann Nadalutti) for models loading (VOX)
raudio dr_wav (David Reid) for WAV audio file loading
raudio dr_flac (David Reid) for FLAC audio file loading
raudio dr_mp3 (David Reid) for MP3 audio file loading
raudio stb_vorbis (Sean Barrett) for OGG audio loading
raudio jar_xm (Joshua Reisenauer) for XM audio module loading
raudio jar_mod (Joshua Reisenauer) for MOD audio module loading
raudio qoa (Dominic Szablewski - https://phoboslab.org) for QOA audio management
raylib;
struct (struct) cursor_shapes.TileTile
{
const(char)* (field) const(char)* cursor_shapes.Tile.labellabel;
(enum) raylib.MouseCursorMouseCursor (field) raylib.MouseCursor cursor_shapes.Tile.cursorcursor;
}
void void D main()main()
{
void raylib.SetTraceLogLevel(int logLevel) nothrow @nogcSetTraceLogLevel((enum) raylib.TraceLogLevelTraceLogLevel.(enum value) raylib.TraceLogLevel.LOG_WARNING = 4LOG_WARNING);
void raylib.SetConfigFlags(uint flags) nothrow @nogcSetConfigFlags((enum) raylib.ConfigFlagsConfigFlags.(enum value) raylib.ConfigFlags.FLAG_WINDOW_RESIZABLE = 4FLAG_WINDOW_RESIZABLE);
void raylib.InitWindow(int width, int height, const(char)* title) nothrow @nogcInitWindow(720, 520, "raylib pointer-shape probe");
void raylib.SetTargetFPS(int fps) nothrow @nogcSetTargetFPS(60);
static immutable (struct) cursor_shapes.TileTile[] (immutable global) immutable(cursor_shapes.Tile[]) cursor_shapes.main.tilestiles = [
(struct) cursor_shapes.TileTile("DEFAULT", (enum) raylib.MouseCursorMouseCursor.(enum value) raylib.MouseCursor.MOUSE_CURSOR_DEFAULT = 0MOUSE_CURSOR_DEFAULT),
(struct) cursor_shapes.TileTile("ARROW", (enum) raylib.MouseCursorMouseCursor.(enum value) raylib.MouseCursor.MOUSE_CURSOR_ARROW = 1MOUSE_CURSOR_ARROW),
(struct) cursor_shapes.TileTile("IBEAM", (enum) raylib.MouseCursorMouseCursor.(enum value) raylib.MouseCursor.MOUSE_CURSOR_IBEAM = 2MOUSE_CURSOR_IBEAM),
(struct) cursor_shapes.TileTile("CROSSHAIR", (enum) raylib.MouseCursorMouseCursor.(enum value) raylib.MouseCursor.MOUSE_CURSOR_CROSSHAIR = 3MOUSE_CURSOR_CROSSHAIR),
(struct) cursor_shapes.TileTile("POINTING_HAND", (enum) raylib.MouseCursorMouseCursor.(enum value) raylib.MouseCursor.MOUSE_CURSOR_POINTING_HAND = 4MOUSE_CURSOR_POINTING_HAND),
(struct) cursor_shapes.TileTile("RESIZE_EW", (enum) raylib.MouseCursorMouseCursor.(enum value) raylib.MouseCursor.MOUSE_CURSOR_RESIZE_EW = 5MOUSE_CURSOR_RESIZE_EW),
(struct) cursor_shapes.TileTile("RESIZE_NS", (enum) raylib.MouseCursorMouseCursor.(enum value) raylib.MouseCursor.MOUSE_CURSOR_RESIZE_NS = 6MOUSE_CURSOR_RESIZE_NS),
(struct) cursor_shapes.TileTile("RESIZE_NWSE", (enum) raylib.MouseCursorMouseCursor.(enum value) raylib.MouseCursor.MOUSE_CURSOR_RESIZE_NWSE = 7MOUSE_CURSOR_RESIZE_NWSE),
(struct) cursor_shapes.TileTile("RESIZE_NESW", (enum) raylib.MouseCursorMouseCursor.(enum value) raylib.MouseCursor.MOUSE_CURSOR_RESIZE_NESW = 8MOUSE_CURSOR_RESIZE_NESW),
(struct) cursor_shapes.TileTile("RESIZE_ALL", (enum) raylib.MouseCursorMouseCursor.(enum value) raylib.MouseCursor.MOUSE_CURSOR_RESIZE_ALL = 9MOUSE_CURSOR_RESIZE_ALL),
(struct) cursor_shapes.TileTile("NOT_ALLOWED", (enum) raylib.MouseCursorMouseCursor.(enum value) raylib.MouseCursor.MOUSE_CURSOR_NOT_ALLOWED = 10MOUSE_CURSOR_NOT_ALLOWED),
];
(enum) raylib.MouseCursorMouseCursor (local variable) raylib.MouseCursor currentcurrent = (enum) raylib.MouseCursorMouseCursor.(enum value) raylib.MouseCursor.MOUSE_CURSOR_DEFAULT = 0MOUSE_CURSOR_DEFAULT;
const(char)* (local variable) const(char)* currentNamecurrentName = "DEFAULT";
while (!bool raylib.WindowShouldClose() nothrow @nogcWindowShouldClose())
{
const (local variable) const(raylib.raylib_types.Vector2) mousemouse = raylib.raylib_types.Vector2 raylib.GetMousePosition() nothrow @nogcGetMousePosition();
const (local variable) const(int) colscols = 3;
const (local variable) const(int) marginmargin = 16;
const (local variable) const(int) gapgap = 10;
const (local variable) const(int) headerheader = 88;
const (local variable) const(int) twtw = (int raylib.GetScreenWidth() nothrow @nogcGetScreenWidth() - (local variable) const(int) marginmargin * 2 - (local variable) const(int) gapgap * ((local variable) const(int) colscols - 1)) / (local variable) const(int) colscols;
const (local variable) const(int) thth = 56;
bool (local variable) bool overAnyoverAny;
foreach ((parameter) ulong ii, (parameter) immutable(cursor_shapes.Tile) tiletile; (immutable global) immutable(cursor_shapes.Tile[]) cursor_shapes.main.tilestiles)
{
const (local variable) const(int) colcol = cast(int)((local variable) ulong ii % (local variable) const(int) colscols);
const (local variable) const(int) rowrow = cast(int)((local variable) ulong ii / (local variable) const(int) colscols);
const (local variable) const(raylib.raylib_types.Rectangle) rr = (struct) raylib.raylib_types.RectangleRectangle(
(local variable) const(int) marginmargin + (local variable) const(int) colcol * ((local variable) const(int) twtw + (local variable) const(int) gapgap),
(local variable) const(int) headerheader + (local variable) const(int) rowrow * ((local variable) const(int) thth + (local variable) const(int) gapgap),
(local variable) const(int) twtw, (local variable) const(int) thth);
const (local variable) const(bool) hothot = bool raylib.CheckCollisionPointRec(raylib.raylib_types.Vector2 point, raylib.raylib_types.Rectangle rec) nothrow @nogcCheckCollisionPointRec((local variable) const(raylib.raylib_types.Vector2) mousemouse, (local variable) const(raylib.raylib_types.Rectangle) rr);
if ((local variable) const(bool) hothot)
{
(local variable) bool overAnyoverAny = true;
(local variable) raylib.MouseCursor currentcurrent = (local variable) immutable(cursor_shapes.Tile) tiletile.(field) raylib.MouseCursor cursor_shapes.Tile.cursorcursor;
(local variable) const(char)* currentNamecurrentName = (local variable) immutable(cursor_shapes.Tile) tiletile.(field) const(char)* cursor_shapes.Tile.labellabel;
if (bool raylib.IsMouseButtonPressed(int button) nothrow @nogcIsMouseButtonPressed((enum) raylib.MouseButtonMouseButton.(enum value) raylib.MouseButton.MOUSE_BUTTON_LEFT = 0MOUSE_BUTTON_LEFT))
(local variable) const(char)* currentNamecurrentName = (local variable) immutable(cursor_shapes.Tile) tiletile.(field) const(char)* cursor_shapes.Tile.labellabel;
}
}
if (!(local variable) bool overAnyoverAny)
{
(local variable) raylib.MouseCursor currentcurrent = (enum) raylib.MouseCursorMouseCursor.(enum value) raylib.MouseCursor.MOUSE_CURSOR_DEFAULT = 0MOUSE_CURSOR_DEFAULT;
(local variable) const(char)* currentNamecurrentName = "DEFAULT";
}
void raylib.SetMouseCursor(int cursor) nothrow @nogcSetMouseCursor((local variable) raylib.MouseCursor currentcurrent);
void raylib.BeginDrawing() nothrow @nogcBeginDrawing();
void raylib.ClearBackground(raylib.raylib_types.Color color) nothrow @nogcClearBackground((struct) raylib.raylib_types.ColorColor(28, 30, 34, 255));
void raylib.DrawText(const(char)* text, int posX, int posY, int fontSize, raylib.raylib_types.Color color) nothrow @nogcDrawText("Hover or click a tile to SetMouseCursor(...)", 16, 16, 20, (enum) raylib.raylib_types.ColorsColors.(enum value) raylib.raylib_types.Colors.RAYWHITE = Color(cast(ubyte)245u, cast(ubyte)245u, cast(ubyte)245u, cast(ubyte)255u)RAYWHITE);
void raylib.DrawText(const(char)* text, int posX, int posY, int fontSize, raylib.raylib_types.Color color) nothrow @nogcDrawText(const(char)* raylib.TextFormat(const(char)* text, ...) nothrow @nogcTextFormat("requested: %s (raylib %s)", (local variable) const(char)* currentNamecurrentName, (constant) string raylib.RAYLIB_VERSION = "6.0"RAYLIB_VERSION.(constant) immutable(char)* "6.0".ptr = "6.0"ptr),
16, 44, 18, (struct) raylib.raylib_types.ColorColor(180, 200, 140, 255));
void raylib.DrawText(const(char)* text, int posX, int posY, int fontSize, raylib.raylib_types.Color color) nothrow @nogcDrawText("If the OS pointer does not change, GLFW could not realise that shape.",
16, 66, 16, (struct) raylib.raylib_types.ColorColor(160, 160, 160, 255));
foreach ((parameter) ulong ii, (parameter) immutable(cursor_shapes.Tile) tiletile; (immutable global) immutable(cursor_shapes.Tile[]) cursor_shapes.main.tilestiles)
{
const (local variable) const(int) colcol = cast(int)((local variable) ulong ii % (local variable) const(int) colscols);
const (local variable) const(int) rowrow = cast(int)((local variable) ulong ii / (local variable) const(int) colscols);
const (local variable) const(raylib.raylib_types.Rectangle) rr = (struct) raylib.raylib_types.RectangleRectangle(
(local variable) const(int) marginmargin + (local variable) const(int) colcol * ((local variable) const(int) twtw + (local variable) const(int) gapgap),
(local variable) const(int) headerheader + (local variable) const(int) rowrow * ((local variable) const(int) thth + (local variable) const(int) gapgap),
(local variable) const(int) twtw, (local variable) const(int) thth);
const (local variable) const(bool) hothot = (local variable) immutable(cursor_shapes.Tile) tiletile.(field) raylib.MouseCursor cursor_shapes.Tile.cursorcursor == (local variable) raylib.MouseCursor currentcurrent && (local variable) bool overAnyoverAny;
void raylib.DrawRectangleRec(raylib.raylib_types.Rectangle rec, raylib.raylib_types.Color color) nothrow @nogcDrawRectangleRec((local variable) const(raylib.raylib_types.Rectangle) rr, (local variable) const(bool) hothot ? (struct) raylib.raylib_types.ColorColor(70, 110, 160, 255) : (struct) raylib.raylib_types.ColorColor(50, 54, 60, 255));
void raylib.DrawRectangleLinesEx(raylib.raylib_types.Rectangle rec, float lineThick, raylib.raylib_types.Color color) nothrow @nogcDrawRectangleLinesEx((local variable) const(raylib.raylib_types.Rectangle) rr, 2, (local variable) const(bool) hothot ? (enum) raylib.raylib_types.ColorsColors.(enum value) raylib.raylib_types.Colors.RAYWHITE = Color(cast(ubyte)245u, cast(ubyte)245u, cast(ubyte)245u, cast(ubyte)255u)RAYWHITE : (struct) raylib.raylib_types.ColorColor(90, 94, 100, 255));
const (local variable) const(int) twidtwid = int raylib.MeasureText(const(char)* text, int fontSize) nothrow @nogcMeasureText((local variable) immutable(cursor_shapes.Tile) tiletile.(field) const(char)* cursor_shapes.Tile.labellabel, 18);
void raylib.DrawText(const(char)* text, int posX, int posY, int fontSize, raylib.raylib_types.Color color) nothrow @nogcDrawText((local variable) immutable(cursor_shapes.Tile) tiletile.(field) const(char)* cursor_shapes.Tile.labellabel,
cast(int)((local variable) const(raylib.raylib_types.Rectangle) rr.(field) float raylib.raylib_types.Rectangle.xx + ((local variable) const(raylib.raylib_types.Rectangle) rr.(field) float raylib.raylib_types.Rectangle.widthwidth - (local variable) const(int) twidtwid) / 2),
cast(int)((local variable) const(raylib.raylib_types.Rectangle) rr.(field) float raylib.raylib_types.Rectangle.yy + ((local variable) const(raylib.raylib_types.Rectangle) rr.(field) float raylib.raylib_types.Rectangle.heightheight - 18) / 2),
18, (enum) raylib.raylib_types.ColorsColors.(enum value) raylib.raylib_types.Colors.RAYWHITE = Color(cast(ubyte)245u, cast(ubyte)245u, cast(ubyte)245u, cast(ubyte)255u)RAYWHITE);
}
void raylib.EndDrawing() nothrow @nogcEndDrawing();
}
void raylib.CloseWindow() nothrow @nogcCloseWindow();
}