/** * Copyright (C) 2026 andromeda * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . **/ module rgfw; bitstruct InitFlags : char { bool opengl : 0; bool egl : 1; bool vulkan : 2; bool x11 : 3; } typedef Info = void; typedef Window = void; typedef Window_src = void; constdef Format : char { RGB8 = 0, BGR8, RGBA8, ARGB8, BGRA8, ABGR8, COUNT, } struct ColorLayout { int r; int g; int b; int a; uint channels; } alias ConvertImageDataFunc = fn void(char*, char*, ColorLayout*, ColorLayout*, usz); typedef NativeImage = void; typedef Surface = void; struct GammaRamp { ushort* red; ushort* green; ushort* blue; usz count; } struct MonitorMode { int w; int h; float refresh_rate; char red; char blue; char green; void* src; } typedef MonitorNode = void; struct Monitor { int x; int y; CChar[128] name; float scale_x; float scale_y; float pixel_ratio; float phys_w; float phys_h; MonitorMode mode; void* userPtr; MonitorNode* node; } constdef ModeRequest : char { SCALE = 1 << 0, REFRESH = 1 << 1, RGB = 1 << 2, ALL = SCALE | REFRESH | RGB, } typedef Mouse = void; constdef Key : char { KEY_NULL = 0, KEY_ESCAPE = 27, KEY_BACKTICK = '`', KEY_0 = '0', KEY_1 = '1', KEY_2 = '2', KEY_3 = '3', KEY_4 = '4', KEY_5 = '5', KEY_6 = '6', KEY_7 = '7', KEY_8 = '8', KEY_9 = '9', KEY_MINUS = '-', KEY_EQUAL = '=', KEY_EQUALS = KEY_EQUAL, KEY_BACKSPACE = '\b', KEY_TAB = '\t', KEY_SPACE = ' ', KEY_A = 'a', KEY_B = 'b', KEY_C = 'c', KEY_D = 'd', KEY_E = 'e', KEY_F = 'f', KEY_G = 'g', KEY_H = 'h', KEY_I = 'i', KEY_J = 'j', KEY_K = 'k', KEY_L = 'l', KEY_M = 'm', KEY_N = 'n', KEY_O = 'o', KEY_P = 'p', KEY_Q = 'q', KEY_R = 'r', KEY_S = 's', KEY_T = 't', KEY_U = 'u', KEY_V = 'v', KEY_W = 'w', KEY_X = 'x', KEY_Y = 'y', KEY_Z = 'z', KEY_PERIOD = '.', KEY_COMMA = ',', KEY_SLASH = '/', KEY_BRACKET = '[', KEY_CLOSEBRACKET = ']', KEY_SEMICOLON = ';', KEY_APOSTROPHE = '\'', KEY_BACKSLASH = '\\', KEY_RETURN = '\n', KEY_ENTER = KEY_RETURN, KEY_DELETE = 127, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_F13, KEY_F14, KEY_F15, KEY_F16, KEY_F17, KEY_F18, KEY_F19, KEY_F20, KEY_F21, KEY_F22, KEY_F23, KEY_F24, KEY_F25, KEY_CAPSLOCK, KEY_SHIFTL, KEY_CONTROLL, KEY_ALTL, KEY_SUPERL, KEY_SHIFTR, KEY_CONTROLR, KEY_ALTR, KEY_SUPERR, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_INSERT, KEY_MENU, KEY_END, KEY_HOME, KEY_PAGEUP, KEY_PAGEDOWN, KEY_NUMLOCK, KEY_PADSLASH, KEY_PADMULTIPLY, KEY_PADPLUS, KEY_PADMINUS, KEY_PADEQUAL, KEY_PADEQUALS = KEY_PADEQUAL, KEY_PAD1, KEY_PAD2, KEY_PAD3, KEY_PAD4, KEY_PAD5, KEY_PAD6, KEY_PAD7, KEY_PAD8, KEY_PAD9, KEY_PAD0, KEY_PADPERIOD, KEY_PADRETURN, KEY_SCROLLLOCK, KEY_PRINTSCREEN, KEY_PAUSE, KEY_WORLD1, KEY_WORLD2, KEY_LAST = 255, } constdef MouseButton : char { LEFT = 0, MIDDLE, RIGHT, MISC1, MISC2, MISC3, MISC4, MISC5, FINAL, } bitstruct Keymod : char { bool caps_lock : 0; bool num_lock : 1; bool control : 2; bool alt : 3; bool shift : 4; bool super : 5; bool scroll_lock : 6; } constdef DndActionType : char { NONE = 0, ENTER, MOVE, EXIT, } constdef DataTransferType : char { NONE = 0, TEXT, FILE, URL, IMAGE, UNKNOWN, } struct DataTransfer { ZString data; usz length; DataTransferType type; } struct DataDropNode { ZString data; usz size; DataTransferType type; DataDropNode* next; } constdef EventType : char { EVENT_NONE = 0, KEY_PRESSED, KEY_RELEASED, KEY_CHAR, MOUSE_BUTTON_PRESSED, MOUSE_BUTTON_RELEASED, MOUSE_SCROLL, MOUSE_MOTION, MOUSE_RAW_MOTION, MOUSE_ENTER, MOUSE_LEAVE, WINDOW_MOVED, WINDOW_RESIZED, WINDOW_FOCUS_IN, WINDOW_FOCUS_OUT, WINDOW_REFRESH, WINDOW_CLOSE, WINDOW_MAXIMIZED, WINDOW_MINIMIZED, WINDOW_RESTORED, DATA_DROP, DATA_DRAG, SCALE_UPDATED, MONITOR_CONNECTED, MONITOR_DISCONNECTED, EVENT_COUNT, } bitstruct EventFlag : uint @overlap { bool key_pressed : (char)EventType.KEY_PRESSED; bool key_released : (char)EventType.KEY_RELEASED; bool key_char : (char)EventType.KEY_CHAR; bool mouse_scroll : (char)EventType.MOUSE_SCROLL; bool mouse_button_pressed : (char)EventType.MOUSE_BUTTON_PRESSED; bool mouse_button_released : (char)EventType.MOUSE_BUTTON_RELEASED; bool mouse_motion : (char)EventType.MOUSE_MOTION; bool mouse_raw_motion : (char)EventType.MOUSE_RAW_MOTION; bool mouse_enter : (char)EventType.MOUSE_ENTER; bool mouse_leave : (char)EventType.MOUSE_LEAVE; bool window_moved : (char)EventType.WINDOW_MOVED; bool window_resized : (char)EventType.WINDOW_RESIZED; bool window_focus_in : (char)EventType.WINDOW_FOCUS_IN; bool window_focus_out : (char)EventType.WINDOW_FOCUS_OUT; bool window_refresh : (char)EventType.WINDOW_REFRESH; bool window_maximized : (char)EventType.WINDOW_MAXIMIZED; bool window_minimized : (char)EventType.WINDOW_MINIMIZED; bool window_restored : (char)EventType.WINDOW_RESTORED; bool scale_updated : (char)EventType.SCALE_UPDATED; bool window_close : (char)EventType.WINDOW_CLOSE; bool data_drop : (char)EventType.DATA_DROP; bool data_drag : (char)EventType.DATA_DRAG; bool monitor_connected : (char)EventType.MONITOR_CONNECTED; bool monitor_disconnected : (char)EventType.MONITOR_DISCONNECTED; bool key_events : (char)EventType.KEY_PRESSED | (char)EventType.KEY_RELEASED | (char)EventType.KEY_CHAR; bool mouse_events : (char)EventType.MOUSE_BUTTON_PRESSED | (char)EventType.MOUSE_BUTTON_RELEASED | (char)EventType.MOUSE_MOTION | (char)EventType.MOUSE_ENTER | (char)EventType.MOUSE_LEAVE | (char)EventType.MOUSE_SCROLL | (char)EventType.MOUSE_RAW_MOTION; bool window_events : (char)EventType.WINDOW_MOVED | (char)EventType.WINDOW_RESIZED | (char)EventType.WINDOW_REFRESH | (char)EventType.WINDOW_MAXIMIZED | (char)EventType.WINDOW_RESTORED | (char)EventType.SCALE_UPDATED; bool window_focus_events : (char)EventType.WINDOW_FOCUS_IN | (char)EventType.WINDOW_FOCUS_OUT; bool data_drag_drop_events : (char)EventType.DATA_DROP | (char)EventType.DATA_DRAG; bool monitor_events : (char)EventType.MONITOR_CONNECTED | (char)EventType.MONITOR_DISCONNECTED; } const EventFlag ALL_EVENTS = { .key_events, .mouse_events, .window_events, .window_focus_events, .data_drag_drop_events, .monitor_events }; struct CommonEvent { EventType type; Window* win; } struct WindowFocusEvent { inline CommonEvent meta; bool state; } struct MouseButtonEvent { inline CommonEvent meta; MouseButton value; bool state; } struct MouseDeltaEvent { inline CommonEvent meta; float x; float y; } struct MousePosEvent { inline CommonEvent meta; int x; int y; bool inWindow; } struct KeyEvent { inline CommonEvent meta; Key value; bool repeat; Keymod mod; bool state; } struct KeyCharEvent { inline CommonEvent meta; Char32 value; } struct DataDropEvent { inline CommonEvent meta; DataDropNode* value; } struct DataDragEvent { inline CommonEvent meta; int x; int y; DndActionType action; DataTransferType dataType; } struct ScaleUpdatedEvent { inline CommonEvent meta; float x; float y; } struct MonitorEvent { inline CommonEvent meta; Monitor* monitor; bool state; } struct WindowUpdateEvent { inline CommonEvent meta; int x; int y; int w; int h; } union Event { EventType type; CommonEvent common; WindowFocusEvent focus; WindowUpdateEvent update; MouseButtonEvent button; MouseDeltaEvent delta; MousePosEvent mouse; KeyEvent key; KeyCharEvent keyChar; DataDropEvent drop; DataDragEvent drag; ScaleUpdatedEvent scale; MonitorEvent monitor; } constdef EventWait : int { NO_WAIT = 0, WAIT_NEXT = -1, } alias GenericFunc = fn void(Event*); struct Callbacks { GenericFunc* arr; } constdef FullscreenMode : char { NONE, BORDERLESS, EXCLUSIVE, } bitstruct WindowFlags : uint @overlap { bool no_border : 0; bool no_resize : 1; bool allow_DND : 2; bool hide_mouse : 3; bool fullscreen_exclusive : 4; bool translucent : 5; bool transparent : 5; bool center : 6; bool raw_mouse : 7; bool scale_to_monitor : 8; bool hide : 9; bool maximize : 10; bool center_cursor : 11; bool floating : 12; bool focus_on_show : 13; bool minimize : 14; bool focus : 15; bool capture_mouse : 16; bool openGL : 17; bool egl : 18; bool fullscreen_borderless : 19; bool capture_raw_mouse : 7 | 16; } bitstruct Icon : char @overlap { bool taskbar : 0; bool window : 1; bool both : 0 | 1; } constdef MouseIcon : char { NORMAL = 0, ARROW, IBEAM, TEXT = IBEAM, CROSSHAIR, POINTING_HAND, RESIZE_EW, RESIZE_NS, RESIZE_NWSE, RESIZE_NESW, RESIZE_NW, RESIZE_N, RESIZE_NE, RESIZE_E, RESIZE_SE, RESIZE_S, RESIZE_SW, RESIZE_W, RESIZE_ALL, NOT_ALLOWED, WAIT, PROGRESS, ICON_COUNT, ICON_FINAL = 16, // padding } constdef FlashRequest : char { CANCEL = 0, BRIEFLY, UNTIL_FOCUSED, } constdef DebugType : char { ERROR = 0, WARNING, INFO, } constdef ErrorCode : char { NO_ERROR = 0, ERR_OUT_OF_MEMORY, ERR_OPENGL_CONTEXT, ERR_EGL_CONTEXT, ERR_WAYLAND, ERR_X11, ERR_DIRECTX_CONTEXT, ERR_IOKIT, ERR_CLIPBOARD, ERR_FAILED_FUNC_LOAD, ERR_BUFFER, ERR_METAL, ERR_OBJC_RUNTIME, ERR_PLATFORM, ERR_EVENT_QUEUE, ERR_NO_INIT, INFO_WINDOW, INFO_BUFFER, INFO_GLOBAL, INFO_OPENGL, WARNING_WAYLAND, WARNING_OPENGL, } struct DebugInfo { DebugType type; ErrorCode code; ZString msg; } alias DebugFunc = fn void(DebugInfo*); alias Proc = fn void(); typedef GlContext @feat(OPENGL) = void; typedef EglContext @feat(OPENGL) = void; constdef GlReleaseBehavior : int @feat(OPENGL) { FLUSH = 0, NONE, } constdef GlProfile : int @feat(OPENGL) { CORE = 0, FORWARD_COMPATIBILITY, COMPATIBILITY, ES, WEB, } constdef GlRenderer : int @feat(OPENGL) { ACCELERATED = 0, SOFTWARE, } struct GlHints @feat(OPENGL) { int stencil; int samples; int stereo; int auxBuffers; int doubleBuffer; int red; int green; int blue; int alpha; int depth; int accumRed; int accumGreen; int accumBlue; int accumAlpha; bool sRGB; bool robustness; bool debug; bool noError; GlReleaseBehavior releaseBehavior; GlProfile profile; int major; int minor; GlContext* share; EglContext* shareEGL; GlRenderer renderer; } extern fn void* alloc(usz) @cname("RGFW_alloc"); extern fn void free(void*) @cname("RGFW_free"); extern fn usz sizeof_info() @cname("RGFW_sizeofInfo"); extern fn int init(ZString, InitFlags) @cname("RGFW_init"); extern fn void deinit() @cname("RGFW_deinit"); extern fn int init_ptr(ZString, InitFlags, Info*) @cname("RGFW_init_ptr"); extern fn void deinit_ptr(Info*) @cname("RGFW_deinit_ptr"); extern fn void set_info(Info*) @cname("RGFW_setInfo"); extern fn Info* get_info() @cname("RGFW_getInfo"); extern fn usz sizeof_window() @cname("RGFW_sizeofWindow"); extern fn usz sizeof_window_src() @cname("RGFW_sizeofWindowSrc"); extern fn bool using_wayland() @cname("RGFW_usingWayland"); extern fn void* get_layer_OSX() @cname("RGFW_getLayer_OSX"); extern fn void* get_display_X11() @cname("RGFW_getDisplay_X11"); extern fn void* get_display_wayland() @cname("RGFW_getDisplay_Wayland"); extern fn void move_to_macos_resource_dir() @cname("RGFW_moveToMacOSResourceDir"); extern fn void copy_image_data(char*, int, int, Format, char*, Format, ConvertImageDataFunc) @cname("RGFW_copyImageData"); extern fn usz sizeof_native_image() @cname("RGFW_sizeofNativeImage"); extern fn usz sizeof_surface() @cname("RGFW_sizeofSurface"); extern fn Format native_format() @cname("RGFW_nativeFormat"); extern fn Surface* create_surface(char*, int, int, Format) @cname("RGFW_createSurface"); extern fn bool create_surface_ptr(char*, int, int, Format, Surface*) @cname("RGFW_createSurfacePtr"); extern fn NativeImage* Surface.get_native_image(&self) @cname("RGFW_surface_getNativeImage"); extern fn void Surface.free(&self) @cname("RGFW_surface_free"); extern fn void Surface.free_ptr(&self) @cname("RGFW_surface_freePtr"); extern fn Mouse* create_mouse(char*, int, int, Format) @cname("RGFW_createMouse"); extern fn Mouse* create_mouse_standard(MouseIcon) @cname("RGFW_createMouseStandard"); extern fn void Mouse.free(Mouse*) @cname("RGFW_freeMouse"); extern fn MonitorMode* Monitor.get_modes(&self, usz*) @cname("RGFW_monitor_getModes"); extern fn void free_modes(MonitorMode*) @cname("RGFW_freeModes"); extern fn usz Monitor.get_modes_ptr(&self, MonitorMode**) @cname("RGFW_monitor_getModesPtr"); extern fn bool Monitor.find_closest_mode(&self, MonitorMode*, MonitorMode*) @cname("RGFW_monitor_findClosestMode"); extern fn GammaRamp* Monitor.get_gamma_ramp(&self) @cname("RGFW_monitor_getGammaRamp"); extern fn void GammaRamp.free(&self) @cname("RGFW_freeGammaRamp"); extern fn usz Monitor.get_gamma_ramp_ptr(&self, GammaRamp*) @cname("RGFW_monitor_getGammaRampPtr"); extern fn bool Monitor.set_gamma_ramp(&self, GammaRamp*) @cname("RGFW_monitor_setGammaRamp"); extern fn bool Monitor.set_gamma(&self, float) @cname("RGFW_monitor_setGamma"); extern fn bool Monitor.set_gamma_ptr(&self, float, ushort*, usz) @cname("RGFW_monitor_setGammaPtr"); extern fn bool Monitor.get_workarea(&self, int*, int*, int*, int*) @cname("RGFW_monitor_getWorkarea"); extern fn bool Monitor.get_position(&self, int*, int*) @cname("RGFW_monitor_getPosition"); extern fn ZString Monitor.get_name(&self) @cname("RGFW_monitor_getName"); extern fn bool Monitor.get_scale(&self, float*, float*) @cname("RGFW_monitor_getScale"); extern fn bool Monitor.get_physical_size(&self, float*, float*) @cname("RGFW_monitor_getPhysicalSize"); extern fn void Monitor.set_user_ptr(&self, void*) @cname("RGFW_monitor_setUserPtr"); extern fn void* Monitor.get_user_ptr(&self) @cname("RGFW_monitor_getUserPtr"); extern fn bool Monitor.get_mode(&self, MonitorMode*) @cname("RGFW_monitor_getMode"); extern fn void poll_monitors() @cname("RGFW_pollMonitors"); extern fn void free_monitors() @cname("RGFW_freeMonitors"); extern fn Monitor** get_monitors(usz*) @cname("RGFW_getMonitors"); extern fn bool get_monitors_ptr(usz, Monitor**, usz*) @cname("RGFW_getMonitorsPtr"); extern fn Monitor* get_primary_monitor() @cname("RGFW_getPrimaryMonitor"); extern fn bool Monitor.request_mode(&self, MonitorMode*, ModeRequest) @cname("RGFW_monitor_requestMode"); extern fn bool Monitor.set_mode(&self, MonitorMode*) @cname("RGFW_monitor_setMode"); extern fn bool monitor_mode_compare(MonitorMode*, MonitorMode*, ModeRequest) @cname("RGFW_monitorModeCompare"); extern fn bool Monitor.scale_to_window(&self, Window*) @cname("RGFW_monitor_scaleToWindow"); extern fn void set_raw_mouse_mode(bool) @cname("RGFW_setRawMouseMode"); extern fn void set_build_DND(bool) @cname("RGFW_setbuildDND"); extern fn void wait_for_event(int) @cname("RGFW_waitForEvent"); extern fn void set_queue_events(bool) @cname("RGFW_setQueueEvents"); extern fn GenericFunc* set_event_callback(EventType, GenericFunc) @cname("RGFW_setEventCallback"); extern fn void set_dual_event_callback(EventType, GenericFunc, GenericFunc*, GenericFunc*) @cname("RGFW_setDualEventCallback"); extern fn void set_all_event_callbacks(GenericFunc, Callbacks*) @cname("RGFW_setAllEventCallbacks"); extern fn void poll_events() @cname("RGFW_pollEvents"); extern fn void stop_check_events() @cname("RGFW_stopCheckEvents"); extern fn bool check_event(Event*) @cname("RGFW_checkEvent"); extern fn bool check_queued_event(Event*) @cname("RGFW_checkQueuedEvent"); extern fn bool Key.is_pressed(self) @cname("RGFW_isKeyPressed"); extern fn bool Key.is_released(self) @cname("RGFW_isKeyReleased"); extern fn bool Key.is_down(self) @cname("RGFW_isKeyDown"); extern fn bool MouseButton.is_pressed(self) @cname("RGFW_isMousePressed"); extern fn bool MouseButton.is_released(self) @cname("RGFW_isMouseReleased"); extern fn bool MouseButton.is_down(self) @cname("RGFW_isMouseDown"); extern fn void get_mouse_scroll(float*, float*) @cname("RGFW_getMouseScroll"); extern fn void get_mouse_vector(float*, float*) @cname("RGFW_getMouseVector"); extern fn Window* create_window(ZString, int, int, int, int, WindowFlags) @cname("RGFW_createWindow"); extern fn Window* create_window_ptr(ZString, int, int, int, int, WindowFlags, Window*) @cname("RGFW_createWindowPtr"); extern fn Surface* Window.create_surface(&self, char*, int, int, Format) @cname("RGFW_window_createSurface"); extern fn Surface* Window.create_surface_ptr(&self, char*, int, int, Format, Surface*) @cname("RGFW_window_createSurfacePtr"); extern fn void Surface.set_convert_func(&self, ConvertImageDataFunc) @cname("RGFW_surface_setConvertFunc"); extern fn void Window.blit_suface(&self, Surface*) @cname("RGFW_window_blitSurface"); extern fn bool Window.get_position(&self, int*, int*) @cname("RGFW_window_getPosition"); extern fn bool Window.get_size(&self, int*, int*) @cname("RGFW_window_getSize"); extern fn bool Window.get_size_in_pixels(&self, int*, int*) @cname("RGFW_window_getSizeInPixels"); extern fn uint Window.get_flags(&self) @cname("RGFW_window_getFlags"); extern fn Key Window.get_exit_key(&self) @cname("RGFW_window_getExitKey"); extern fn void Window.set_exit_key(&self, Key) @cname("RGFW_window_setExitKey"); extern fn void Window.set_enabled_events(&self, EventFlag) @cname("RGFW_window_setEnabledEvents"); extern fn EventFlag Window.get_enabled_events(&self) @cname("RGFW_window_getEnabledEvents"); extern fn void Window.set_disabled_events(&self, EventFlag) @cname("RGFW_window_setDisabledEvents"); extern fn void Window.set_event_state(&self, EventFlag, bool) @cname("RGFW_window_setEventState"); extern fn void* Window.get_user_ptr(&self) @cname("RGFW_window_getUserPtr"); extern fn void Window.set_user_ptr(&self, void*) @cname("RGFW_window_setUserPtr"); extern fn Window_src* Window.get_src(&self) @cname("RGFW_window_getSrc"); extern fn void Window.set_layer_OSX(&self, void*) @cname("RGFW_window_setLayer_OSX"); extern fn void* Window.get_view_OSX(&self) @cname("RGFW_window_getView_OSX"); extern fn void* Window.get_window_OSX(&self) @cname("RGFW_window_getWindow_OSX"); extern fn void* Window.get_HWND(&self) @cname("RGFW_window_getHWND"); extern fn void* Window.get_HDC(&self) @cname("RGFW_window_getHDC"); extern fn ulong Window.get_window_X11(&self) @cname("RGFW_window_getWindow_X11"); extern fn void* Window.get_window_wayland(&self) @cname("RGFW_window_getWindow_Wayland"); extern fn void Window.set_flags(&self, WindowFlags) @cname("RGFW_window_setFlags"); extern fn bool Window.check_event(&self, Event*) @cname("RGFW_window_checkEvent"); extern fn bool Window.check_queued_event(&self, Event*) @cname("RGFW_window_checkQueuedEvent"); extern fn bool Window.is_key_pressed(&self, Key) @cname("RGFW_window_isKeyPressed"); extern fn bool Window.is_key_down(&self, Key) @cname("RGFW_window_isKeyDown"); extern fn bool Window.is_key_released(&self, Key) @cname("RGFW_window_isKeyReleased"); extern fn bool Window.is_mouse_pressed(&self, MouseButton) @cname("RGFW_window_isMousePressed"); extern fn bool Window.is_mouse_down(&self, MouseButton) @cname("RGFW_window_isMouseDown"); extern fn bool Window.is_mouse_released(&self, MouseButton) @cname("RGFW_window_isMouseReleased"); extern fn bool Window.did_mouse_leave(&self) @cname("RGFW_window_didMouseLeave"); extern fn bool Window.did_mouse_enter(&self) @cname("RGFW_window_didMouseEnter"); extern fn bool Window.is_mouse_inside(&self) @cname("RGFW_window_isMouseInside"); extern fn bool Window.is_data_dragging(&self) @cname("RGFW_window_isDataDragging"); extern fn bool Window.get_data_drag(&self, int*, int*) @cname("RGFW_window_getDataDrag"); extern fn bool Window.did_data_drop(&self) @cname("RGFW_window_didDataDrop"); extern fn DataDropNode* Window.get_data_drop(&self) @cname("RGFW_window_getDataDrop"); extern fn void Window.close(&self) @cname("RGFW_window_close"); extern fn void Window.close_ptr(&self) @cname("RGFW_window_closePtr"); extern fn bool Window.fetch_size(&self, int*, int*) @cname("RGFW_window_fetchSize"); extern fn void Window.move(&self, int, int) @cname("RGFW_window_move"); extern fn void Window.move_to_monitor(&self, Monitor*) @cname("RGFW_window_moveToMonitor"); extern fn void Window.resize(&self, int, int) @cname("RGFW_window_resize"); extern fn void Window.set_aspect_ratio(&self, int, int) @cname("RGFW_window_setAspectRatio"); extern fn void Window.set_min_size(&self, int, int) @cname("RGFW_window_setMinSize"); extern fn void Window.set_max_size(&self, int, int) @cname("RGFW_window_setMaxSize"); extern fn void Window.focus(&self) @cname("RGFW_window_focus"); extern fn bool Window.is_in_focus(&self) @cname("RGFW_window_isInFocus"); extern fn void Window.raise(&self) @cname("RGFW_window_raise"); extern fn void Window.maximize(&self) @cname("RGFW_window_maximize"); extern fn void Window.set_fullscreen(&self, bool) @cname("RGFW_window_setFullscreen"); extern fn void Window.center(&self) @cname("RGFW_window_center"); extern fn void Window.minimize(&self) @cname("RGFW_window_minimize"); extern fn void Window.restore(&self) @cname("RGFW_window_restore"); extern fn void Window.set_floating(&self, bool) @cname("RGFW_window_setFloating"); extern fn void Window.set_opacity(&self, char) @cname("RGFW_window_setOpacity"); extern fn void Window.set_border(&self, bool) @cname("RGFW_window_setBorder"); extern fn bool Window.borderless(&self) @cname("RGFW_window_borderless"); extern fn void Window.set_DND(&self, bool) @cname("RGFW_window_setDND"); extern fn bool Window.allows_DND(&self) @cname("RGFW_window_allowsDND"); extern fn void Window.set_mouse_passthrough(&self, bool) @cname("RGFW_window_setMousePassthrough"); extern fn void Window.set_name(&self, ZString) @cname("RGFW_window_setName"); extern fn bool Window.set_icon(&self, char*, int, int, Format) @cname("RGFW_window_seticon"); extern fn bool Window.set_icon_ex(&self, char*, int, int, Format, Icon) @cname("RGFW_window_setIconEx"); extern fn bool Window.set_mouse(&self, Mouse*) @cname("RGFW_window_setMouse"); extern fn bool Window.set_mouse_standard(&self, MouseIcon) @cname("RGFW_window_setMouseStandard"); extern fn bool Window.set_mouse_default(&self) @cname("RGFW_window_setMouseDefault"); extern fn void Window.set_raw_mouse_mode(&self, bool) @cname("RGFW_window_setRawMouseMode"); extern fn void Window.capture_mouse(&self, bool) @cname("RGFW_window_captureMouse"); extern fn void Window.capture_raw_mouse_mode(&self, bool) @cname("RGFW_window_captureRawMouse"); extern fn bool Window.is_raw_mouse_mode(&self) @cname("RGFW_window_isRawMouseMode"); extern fn bool Window.is_captured(&self) @cname("RGFW_window_isCaptured"); extern fn void Window.hide(&self) @cname("RGFW_window_hide"); extern fn void Window.show(&self) @cname("RGFW_window_show"); extern fn void Window.flash(&self, FlashRequest) @cname("RGFW_window_flash"); extern fn void Window.set_should_close(&self, bool) @cname("RGFW_window_setShouldClose"); extern fn bool get_global_mouse(int*, int*) @cname("RGFW_getGlobalMouse"); extern fn bool Window.get_mouse(&self, int*, int*) @cname("RGFW_window_getMouse"); extern fn void Window.show_mouse(&self, bool) @cname("RGFW_window_showMouse"); extern fn bool Window.is_mouse_hidden(&self) @cname("RGFW_window_isMouseHidden"); extern fn void Window.move_mouse(&self, int, int) @cname("RGFW_window_moveMouse"); extern fn bool Window.should_close(&self) @cname("RGFW_window_shouldClose"); extern fn bool Window.is_fullscreen(&self) @cname("RGFW_window_isFullscreen"); extern fn bool Window.is_fullscreen_exclusive(&self) @cname("RGFW_window_isFullscreenExclusive"); extern fn bool Window.is_fullscreen_borderless(&self) @cname("RGFW_window_isFullscreenBorderless"); extern fn bool Window.is_hidden(&self) @cname("RGFW_window_isHidden"); extern fn bool Window.is_minimized(&self) @cname("RGFW_window_isMinimized"); extern fn bool Window.is_maximized(&self) @cname("RGFW_window_isMaximized"); extern fn bool Window.is_floating(&self) @cname("RGFW_window_isFloating"); extern fn void Window.scale_to_monitor(&self) @cname("RGFW_window_scaleToMonitor"); extern fn Monitor* Window.get_monitor(&self) @cname("RGFW_window_getMonitor"); extern fn DataTransfer* read_clipboard(DataTransferType) @cname("RGFW_readClipboard"); extern fn bool read_clipboard_ptr(DataTransferType, char*, usz, DataTransfer*) @cname("RGFW_readClipboardPtr"); // TODO tell upstream the following function's docs are wrong extern fn DataTransfer* read_clipboard_string() @cname("RGFW_readClipboardString"); extern fn bool read_clipboard_string_ptr(char*, usz, DataTransfer*) @cname("RGFW_readClipboardStringPtr"); extern fn bool write_clipboard(DataTransfer*) @cname("RGFW_writeClipboard"); extern fn DebugFunc set_debug_callback(DebugFunc) @cname("RGFW_setDebugCallback"); extern fn void debug_callback(DebugType, ErrorCode, ZString) @cname("RGFW_debugCallback"); extern fn void Window.set_root(&self) @cname("RGFW_setRootWindow"); extern fn Window* get_root_window() @cname("RGFW_getRootWindow"); extern fn void event_queue_push(Event*) @cname("RGFW_eventQueuePush"); extern fn void event_queue_push_and_call(Event*) @cname("RGFW_eventQueuePushAndCall"); extern fn void event_queue_flush() @cname("RGFW_eventQueueFlush"); extern fn Event* event_queue_pop() @cname("RGFW_eventQueuePop"); extern fn Event* Window.event_queue_pop(&self) @cname("RGFW_window_eventQueuePop"); extern fn Key api_key_to_rgfw(uint) @cname("RGFW_apiKeyToRGFW"); extern fn uint rgfw_to_api_key(Key) @cname("RGFW_rgfwToApiKey"); extern fn Key physical_to_mapped_key(Key) @cname("RGFW_physicalToMappedKey"); module rgfw::opengl @feat(OPENGL | EGL); extern fn void set_global_hints(GlHints*) @cname("RGFW_setGlobalHints_OpenGL"); extern fn void reset_global_hints() @cname("RGFW_resetGlobalHints_OpenGL"); extern fn GlHints* get_global_hints() @cname("RGFW_getGlobalHints_OpenGL"); module rgfw::opengl @feat(OPENGL); extern fn GlContext* create_context(GlHints*) @cname("RGFW_createContext_OpenGL"); extern fn bool create_context_ptr(GlContext*, GlHints*) @cname("RGFW_createContextPtr_OpenGL"); extern fn void delete_context(GlContext*) @cname("RGFW_deleteContext_OpenGL"); extern fn void delete_context_ptr(GlContext*) @cname("RGFW_deleteContextPtr_OpenGL"); extern fn GlContext* copy_context(GlContext*) @cname("RGFW_copyContext_OpenGL"); extern fn bool copy_context_ptr(GlContext*, GlContext*) @cname("RGFW_copyContextPtr_OpenGL"); extern fn void* GlContext.get_source_context(&self) @cname("RGFW_glContext_getSourceContext"); extern fn void* get_current_context() @cname("RGFW_getCurrentContext_OpenGL"); extern fn void* get_current_surface() @cname("RGFW_getCurrentSurface_OpenGL"); extern fn Window* get_current_window() @cname("RGFW_getCurrentWindow_OpenGL"); extern fn Proc get_proc_address(ZString) @cname("RGFW_getProcAddress_OpenGL"); extern fn bool extension_supported(ZString, usz) @cname("RGFW_extensionSupported_OpenGL"); extern fn bool extension_supported_platform(ZString, usz) @cname("RGFW_extensionSupportedPlatform_OpenGL"); // if EGL is defined, prefer those methods as they (should) fall back module rgfw::opengl @feat(OPENGL & !EGL); extern fn bool Window.set_context(&self, GlContext*) @cname("RGFW_window_setContext_OpenGL"); extern fn GlContext* Window.get_context(&self) @cname("RGFW_window_getContext_OpenGL"); extern fn void Window.make_current_window(&self) @cname("RGFW_window_makeCurrentWindow_OpenGL"); extern fn void Window.make_current_context(&self) @cname("RGFW_window_makeCurrentContext_OpenGL"); extern fn void Window.swap_buffers(&self) @cname("RGFW_window_swapBuffers_OpenGL"); extern fn void Window.swap_interval(&self, int) @cname("RGFW_window_swapInterval_OpenGL"); module rgfw::egl @feat(EGL); extern fn EglContext* create_context(GlHints*) @cname("RGFW_window_createContext_EGL"); extern fn bool create_context_ptr(EglContext*, GlHints*) @cname("RGFW_window_createContextPtr_EGL"); extern fn void delete_context(EglContext*) @cname("RGFW_window_deleteContext_EGL"); extern fn void delete_context_ptr(EglContext*) @cname("RGFW_window_deleteContextPtr_EGL"); extern fn EglContext* copy_context(EglContext*) @cname("RGFW_copyContext_EGL"); extern fn bool copy_context_ptr(EglContext*, EglContext*) @cname("RGFW_copyContextPtr_EGL"); extern fn bool Window.set_context(&self, EglContext*) @cname("RGFW_window_setContext_EGL"); extern fn EglContext* Window.get_context(&self) @cname("RGFW_window_getContext_EGL"); extern fn void* get_display() @cname("RGFW_getDisplay_EGL"); extern fn void* EglContext.get_source_context(&self) @cname("RGFW_eglContext_getSourceContext"); extern fn void* EglContext.get_surface(&self) @cname("RGFW_eglContext_getSurface"); extern fn void* EglContext.wl_egl_window(&self) @cname("RGFW_eglContext_wlEGLWindow"); extern fn void Window.swap_buffers(&self) @cname("RGFW_window_swapBuffers_EGL"); extern fn void Window.make_current_window(&self) @cname("RGFW_window_makeCurrentWindow_EGL"); extern fn void Window.make_current_context(&self) @cname("RGFW_window_makeCurrentContext_EGL"); extern fn void* get_current_context() @cname("RGFW_getCurrentContext_EGL"); extern fn void* get_current_surface() @cname("RGFW_getCurrentSurface_EGL"); extern fn Window* get_current_window() @cname("RGFW_getCurrentWindow_EGL"); extern fn void Window.swap_interval(&self, int) @cname("RGFW_window_swapInterval_EGL"); extern fn Proc get_proc_address(ZString) @cname("RGFW_getProcAddress_EGL"); extern fn bool extension_supported(ZString, usz) @cname("RGFW_extensionSupported_EGL"); extern fn bool extension_supported_platform(ZString, usz) @cname("RGFW_extensionSupportedPlatform_EGL"); module rgfw::vulkan @feat(VULKAN); alias VkResult = int; alias VkInstance = void*; alias VkSurfaceKHR = ulong; alias VkPhysicalDevice = void*; extern fn Proc VkInstance.get_proc_address(self, ZString) @cname("RGFW_getInstanceProcAddress_Vulkan"); extern fn ZString[] get_required_instance_extensions(usz*) @cname("RGFW_getRequiredInstanceExtensions_Vulkan"); extern fn VkResult create_surface(Window*, VkInstance, VkSurfaceKHR*) @cname("RGFW_window_createSurface_Vulkan"); extern fn bool VkInstance.get_physical_device_presentation_support( self, VkPhysicalDevice, uint ) @cname("RGFW_getPhysicalDevicePresentationSupport_Vulkan"); module rgfw::directx @feat(DIRECTX); alias IDXGIFactory = void; alias IUnknown = void; alias UDXGISwapChain = void; extern fn int create_swap_chain(Window*, IDXGIFactory*, IUnknown*, UDXGISwapChain**) @cname("RGFW_window_createSwapChain_DirectX"); module rgfw::wgpu @feat(WGPU); alias WGPUSurface = void*; alias WGPUInstance = void*; extern fn WGPUSurface create_surface(Window*, WGPUInstance) @cname("RGFW_window_createSurface_WebGPU");