Carp/core/GLFW.carp
2020-06-18 23:19:31 +02:00

163 lines
9.9 KiB
Plaintext

(system-include "GLFW/glfw3.h")
(add-pkg "glfw3")
(defmodule GLFW
;; Methods
(register init (λ [] Int) "glfwInit")
(register terminate (λ [] ()) "glfwTerminate")
(register get-version (λ [(Ptr Int) (Ptr Int) (Ptr Int)] ()) "glfwGetVersion")
(register set-error-callback (λ [GLFWerrorfun] GLFWerrorfun) "glfwSetErrorCallback")
(register get-monitors (λ [(Ptr Int)] (Ptr (Ptr GLFWmonitor))) "glfwGetMonitors")
(register get-primary-monitor (λ [] (Ptr GLFWmonitor)) "glfwGetPrimaryMonitor")
(register get-monitor-pos (λ [(Ptr GLFWmonitor) (Ptr Int) (Ptr Int)] ()) "glfwGetMonitorPos")
(register get-monitor-physical-size (λ [(Ptr GLFWmonitor) (Ptr Int) (Ptr Int)] ()) "glfwGetMonitorPhysicalSize")
(register set-monitor-callback (λ [GLFWmonitorfun] GLFWmonitorfun) "glfwSetMonitorCallback")
(register set-gamma (λ [(Ptr GLFWmonitor) Float] ()) "glfwSetGamma")
(register set-gamma-ramp (λ [(Ptr GLFWmonitor) (Ptr GLFWgammaramp)] ()) "glfwSetGammaRamp")
(register default-window-hints (λ [] ()) "glfwDefaultWindowHints")
(register window-hint (λ [Int Int] ()) "glfwWindowHint")
(register create-window (λ [Int Int (Ptr CChar) (Ptr GLFWmonitor) (Ptr GLFWwindow)] (Ptr GLFWwindow)) "glfwCreateWindow")
(register destroy-window (λ [(Ptr GLFWwindow)] ()) "glfwDestroyWindow")
(register window-should-close (λ [(Ptr GLFWwindow)] Int) "glfwWindowShouldClose")
(register set-window-should-close (λ [(Ptr GLFWwindow) Int] ()) "glfwSetWindowShouldClose")
(register set-window-title (λ [(Ptr GLFWwindow) (Ptr CChar)] ()) "glfwSetWindowTitle")
(register set-window-icon (λ [(Ptr GLFWwindow) Int (Ptr GLFWimage)] ()) "glfwSetWindowIcon")
(register get-window-pos (λ [(Ptr GLFWwindow) (Ptr Int) (Ptr Int)] ()) "glfwGetWindowPos")
(register set-window-pos (λ [(Ptr GLFWwindow) Int Int] ()) "glfwSetWindowPos")
(register get-window-size (λ [(Ptr GLFWwindow) (Ptr Int) (Ptr Int)] ()) "glfwGetWindowSize")
(register set-window-size-limits (λ [(Ptr GLFWwindow) Int Int Int Int] ()) "glfwSetWindowSizeLimits")
(register set-window-aspect-ratio (λ [(Ptr GLFWwindow) Int Int] ()) "glfwSetWindowAspectRatio")
(register set-window-size (λ [(Ptr GLFWwindow) Int Int] ()) "glfwSetWindowSize")
(register get-framebuffer-size (λ [(Ptr GLFWwindow) (Ptr Int) (Ptr Int)] ()) "glfwGetFramebufferSize")
(register get-window-frame-size (λ [(Ptr GLFWwindow) (Ptr Int) (Ptr Int) (Ptr Int) (Ptr Int)] ()) "glfwGetWindowFrameSize")
(register iconify-window (λ [(Ptr GLFWwindow)] ()) "glfwIconifyWindow")
(register restore-window (λ [(Ptr GLFWwindow)] ()) "glfwRestoreWindow")
(register maximize-window (λ [(Ptr GLFWwindow)] ()) "glfwMaximizeWindow")
(register show-window (λ [(Ptr GLFWwindow)] ()) "glfwShowWindow")
(register hide-window (λ [(Ptr GLFWwindow)] ()) "glfwHideWindow")
(register focus-window (λ [(Ptr GLFWwindow)] ()) "glfwFocusWindow")
(register get-window-monitor (λ [(Ptr GLFWwindow)] (Ptr GLFWmonitor)) "glfwGetWindowMonitor")
(register set-window-monitor (λ [(Ptr GLFWwindow) (Ptr GLFWmonitor) Int Int Int Int Int] ()) "glfwSetWindowMonitor")
(register get-window-attrib (λ [(Ptr GLFWwindow) Int] Int) "glfwGetWindowAttrib")
(register set-window-user-pointer (λ [(Ptr GLFWwindow) (Ptr ())] ()) "glfwSetWindowUserPointer")
(register get-window-user-pointer (λ [(Ptr GLFWwindow)] (Ptr ())) "glfwGetWindowUserPointer")
(register set-window-pos-callback (λ [(Ptr GLFWwindow) GLFWwindowposfun] GLFWwindowposfun) "glfwSetWindowPosCallback")
(register set-window-size-callback (λ [(Ptr GLFWwindow) GLFWwindowsizefun] GLFWwindowsizefun) "glfwSetWindowSizeCallback")
(register set-window-close-callback (λ [(Ptr GLFWwindow) GLFWwindowclosefun] GLFWwindowclosefun) "glfwSetWindowCloseCallback")
(register set-window-refresh-callback (λ [(Ptr GLFWwindow) GLFWwindowrefreshfun] GLFWwindowrefreshfun) "glfwSetWindowRefreshCallback")
(register set-window-focus-callback (λ [(Ptr GLFWwindow) GLFWwindowfocusfun] GLFWwindowfocusfun) "glfwSetWindowFocusCallback")
(register set-window-iconify-callback (λ [(Ptr GLFWwindow) GLFWwindowiconifyfun] GLFWwindowiconifyfun) "glfwSetWindowIconifyCallback")
(register set-framebuffer-size-callback (λ [(Ptr GLFWwindow) GLFWframebuffersizefun] GLFWframebuffersizefun) "glfwSetFramebufferSizeCallback")
(register poll-events (λ [] ()) "glfwPollEvents")
(register wait-events (λ [] ()) "glfwWaitEvents")
(register wait-events-timeout (λ [Double] ()) "glfwWaitEventsTimeout")
(register post-empty-event (λ [] ()) "glfwPostEmptyEvent")
(register get-input-mode (λ [(Ptr GLFWwindow) Int] Int) "glfwGetInputMode")
(register set-input-mode (λ [(Ptr GLFWwindow) Int Int] ()) "glfwSetInputMode")
(register get-key (λ [(Ptr GLFWwindow) Int] Int) "glfwGetKey")
(register get-mouse-button (λ [(Ptr GLFWwindow) Int] Int) "glfwGetMouseButton")
(register get-cursor-pos (λ [(Ptr GLFWwindow) (Ptr Double) (Ptr Double)] ()) "glfwGetCursorPos")
(register set-cursor-pos (λ [(Ptr GLFWwindow) Double Double] ()) "glfwSetCursorPos")
(register create-cursor (λ [(Ptr GLFWimage) Int Int] (Ptr GLFWcursor)) "glfwCreateCursor")
(register create-standard-cursor (λ [Int] (Ptr GLFWcursor)) "glfwCreateStandardCursor")
(register destroy-cursor (λ [(Ptr GLFWcursor)] ()) "glfwDestroyCursor")
(register set-cursor (λ [(Ptr GLFWwindow) (Ptr GLFWcursor)] ()) "glfwSetCursor")
(register set-key-callback (λ [(Ptr GLFWwindow) GLFWkeyfun] GLFWkeyfun) "glfwSetKeyCallback")
(register set-char-callback (λ [(Ptr GLFWwindow) GLFWcharfun] GLFWcharfun) "glfwSetCharCallback")
(register set-char-mods-callback (λ [(Ptr GLFWwindow) GLFWcharmodsfun] GLFWcharmodsfun) "glfwSetCharModsCallback")
(register set-mouse-button-callback (λ [(Ptr GLFWwindow) GLFWmousebuttonfun] GLFWmousebuttonfun) "glfwSetMouseButtonCallback")
(register set-cursor-pos-callback (λ [(Ptr GLFWwindow) GLFWcursorposfun] GLFWcursorposfun) "glfwSetCursorPosCallback")
(register set-cursor-enter-callback (λ [(Ptr GLFWwindow) GLFWcursorenterfun] GLFWcursorenterfun) "glfwSetCursorEnterCallback")
(register set-scroll-callback (λ [(Ptr GLFWwindow) GLFWscrollfun] GLFWscrollfun) "glfwSetScrollCallback")
(register set-drop-callback (λ [(Ptr GLFWwindow) GLFWdropfun] GLFWdropfun) "glfwSetDropCallback")
(register joystick-present (λ [Int] Int) "glfwJoystickPresent")
(register set-joystick-callback (λ [GLFWjoystickfun] GLFWjoystickfun) "glfwSetJoystickCallback")
(register set-clipboard-string (λ [(Ptr GLFWwindow) (Ptr CChar)] ()) "glfwSetClipboardString")
(register get-time (λ [] Double) "glfwGetTime")
(register set-time (λ [Double] ()) "glfwSetTime")
(register get-timer-value (λ [] uint64_t) "glfwGetTimerValue")
(register get-timer-frequency (λ [] uint64_t) "glfwGetTimerFrequency")
(register make-context-current (λ [(Ptr GLFWwindow)] ()) "glfwMakeContextCurrent")
(register get-current-context (λ [] (Ptr GLFWwindow)) "glfwGetCurrentContext")
(register swap-buffers (λ [(Ptr GLFWwindow)] ()) "glfwSwapBuffers")
(register swap-interval (λ [Int] ()) "glfwSwapInterval")
(register extension-supported (λ [(Ptr CChar)] Int) "glfwExtensionSupported")
(register get-proc-address (λ [(Ptr CChar)] GLFWglproc) "glfwGetProcAddress")
(register vulkan-supported (λ [] Int) "glfwVulkanSupported")
(register get-instance-proc-address (λ [VkInstance (Ptr CChar)] GLFWvkproc) "glfwGetInstanceProcAddress")
(register get-physical-device-presentation-support (λ [VkInstance VkPhysicalDevice uint32_t] Int) "glfwGetPhysicalDevicePresentationSupport")
(register create-window-surface (λ [VkInstance (Ptr GLFWwindow) (Ptr VkAllocationCallbacks) (Ptr VkSurfaceKHR)] VkResult) "glfwCreateWindowSurface")
;; Basic constants
(register FALSE Int "GLFW_FALSE")
(register TRUE Int "GLFW_TRUE")
(register STICKY_KEYS Int "GLFW_STICKY_KEYS")
;; Key and button actions
(register RELEASE Int "GLFW_RELEASE")
(register PRESS Int "GLFW_PRESS")
(register REPEAT Int "GLFW_REPEAT")
;; Keycodes
(defmodule Keycode
(register RETURN Int "GLFW_KEY_ENTER")
(register SPACE Int "GLFW_KEY_SPACE")
(register ESCAPE Int "GLFW_KEY_ESCAPE")
(register LEFT Int "GLFW_KEY_LEFT")
(register RIGHT Int "GLFW_KEY_RIGHT")
(register UP Int "GLFW_KEY_UP")
(register DOWN Int "GLFW_KEY_DOWN")
(register NUM_1 Int "GLFW_KEY_1")
(register NUM_2 Int "GLFW_KEY_2")
(register NUM_3 Int "GLFW_KEY_3")
(register NUM_4 Int "GLFW_KEY_4")
(register NUM_5 Int "GLFW_KEY_5")
(register NUM_6 Int "GLFW_KEY_6")
(register NUM_7 Int "GLFW_KEY_7")
(register NUM_8 Int "GLFW_KEY_8")
(register NUM_9 Int "GLFW_KEY_9")
(register NUM_0 Int "GLFW_KEY_0")
(register A Int "GLFW_KEY_A")
(register B Int "GLFW_KEY_B")
(register C Int "GLFW_KEY_C")
(register D Int "GLFW_KEY_D")
(register E Int "GLFW_KEY_E")
(register F Int "GLFW_KEY_F")
(register G Int "GLFW_KEY_G")
(register H Int "GLFW_KEY_H")
(register I Int "GLFW_KEY_I")
(register J Int "GLFW_KEY_J")
(register K Int "GLFW_KEY_K")
(register L Int "GLFW_KEY_L")
(register M Int "GLFW_KEY_M")
(register N Int "GLFW_KEY_N")
(register O Int "GLFW_KEY_O")
(register P Int "GLFW_KEY_P")
(register Q Int "GLFW_KEY_Q")
(register R Int "GLFW_KEY_R")
(register S Int "GLFW_KEY_S")
(register T Int "GLFW_KEY_T")
(register U Int "GLFW_KEY_U")
(register V Int "GLFW_KEY_V")
(register W Int "GLFW_KEY_W")
(register X Int "GLFW_KEY_X")
(register Y Int "GLFW_KEY_Y")
(register Z Int "GLFW_KEY_Z")
(register PERIOD Int "GLFW_KEY_PERIOD")
(register COMMA Int "GLFW_KEY_COMMA")
(register MINUS Int "GLFW_KEY_MINUS")
(register TAB Int "GLFW_KEY_TAB")
(register BACKSPACE Int "GLFW_KEY_BACKSPACE")
)
;; Mouse buttons
(defmodule Mouse
(register BUTTON_LEFT Int "GLFW_MOUSE_BUTTON_LEFT")
(register BUTTON_RIGHT Int "GLFW_MOUSE_BUTTON_RIGHT")
(register BUTTON_MIDDLE Int "GLFW_MOUSE_BUTTON_MIDDLE")
)
)