package glfw-ocaml

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

OCaml binding for GLFW 3.2.1

val version_major : int

GLFW-OCaml version numbers.

val version_minor : int
val version_revision : int
exception NotInitialized of string

Exceptions raised by the various functions of this module.

exception NoCurrentContext of string
exception InvalidEnum of string
exception InvalidValue of string
exception OutOfMemory of string
exception ApiUnavailable of string
exception VersionUnavailable of string
exception PlatformError of string
exception FormatUnavailable of string
exception NoWindowContext of string
type key_action =
  1. | Release
  2. | Press
  3. | Repeat
type key =
  1. | Unknown
  2. | Space
  3. | Apostrophe
  4. | Comma
  5. | Minus
  6. | Period
  7. | Slash
  8. | Num0
  9. | Num1
  10. | Num2
  11. | Num3
  12. | Num4
  13. | Num5
  14. | Num6
  15. | Num7
  16. | Num8
  17. | Num9
  18. | Semicolon
  19. | Equal
  20. | A
  21. | B
  22. | C
  23. | D
  24. | E
  25. | F
  26. | G
  27. | H
  28. | I
  29. | J
  30. | K
  31. | L
  32. | M
  33. | N
  34. | O
  35. | P
  36. | Q
  37. | R
  38. | S
  39. | T
  40. | U
  41. | V
  42. | W
  43. | X
  44. | Y
  45. | Z
  46. | LeftBracket
  47. | Backslash
  48. | RightBracket
  49. | GraveAccent
  50. | World1
  51. | World2
  52. | Escape
  53. | Enter
  54. | Tab
  55. | Backspace
  56. | Insert
  57. | Delete
  58. | Right
  59. | Left
  60. | Down
  61. | Up
  62. | PageUp
  63. | PageDown
  64. | Home
  65. | End
  66. | CapsLock
  67. | ScrollLock
  68. | NumLock
  69. | PrintScreen
  70. | Pause
  71. | F1
  72. | F2
  73. | F3
  74. | F4
  75. | F5
  76. | F6
  77. | F7
  78. | F8
  79. | F9
  80. | F10
  81. | F11
  82. | F12
  83. | F13
  84. | F14
  85. | F15
  86. | F16
  87. | F17
  88. | F18
  89. | F19
  90. | F20
  91. | F21
  92. | F22
  93. | F23
  94. | F24
  95. | F25
  96. | Kp0
  97. | Kp1
  98. | Kp2
  99. | Kp3
  100. | Kp4
  101. | Kp5
  102. | Kp6
  103. | Kp7
  104. | Kp8
  105. | Kp9
  106. | KpDecimal
  107. | KpDivide
  108. | KpMultiply
  109. | KpSubtract
  110. | KpAdd
  111. | KpEnter
  112. | KpEqual
  113. | LeftShift
  114. | LeftControl
  115. | LeftAlt
  116. | LeftSuper
  117. | RightShift
  118. | RightControl
  119. | RightAlt
  120. | RightSuper
  121. | Menu
type key_mod =
  1. | Shift
  2. | Control
  3. | Alt
  4. | Super

Keyboard key and mouse button modifiers.

val mouse_button_max_count : int

Maximum number of buttons handled for a mouse.

val mouse_button_left : int

Values of common mouse buttons.

val mouse_button_right : int
val mouse_button_middle : int
val joystick_max_count : int

Maximum number of joysticks connected.

type client_api =
  1. | NoApi
  2. | OpenGLApi
  3. | OpenGLESApi

Client OpenGL API hint

type context_robustness =
  1. | NoRobustness
  2. | NoResetNotification
  3. | LoseContextOnReset

Context robustness hint

type opengl_profile =
  1. | AnyProfile
  2. | CoreProfile
  3. | CompatProfile

OpenGL profile hint

type context_release_behavior =
  1. | AnyReleaseBehavior
  2. | ReleaseBehaviorFlush
  3. | ReleaseBehaviorNone

Context release behavior hint

type context_creation_api =
  1. | NativeContextApi
  2. | EGLContextApi

Context creation API hint

module WindowHint : sig ... end

Window hints. Use with windowHint like this:

module WindowAttribute : sig ... end

Windows attributes. Use with getWindowAttrib in a similar manner as with window hints.

type cursor_mode =
  1. | Normal
  2. | Hidden
  3. | Disabled

Mouse cursor input mode.

type _ input_mode =
  1. | Cursor : cursor_mode input_mode
  2. | StickyKeys : bool input_mode
  3. | StickyMouseButtons : bool input_mode

Input modes. Use with setInputMode and getInputMode in a similar manner as with window hints.

type cursor_shape =
  1. | ArrowCursor
  2. | IBeamCursor
  3. | CrosshairCursor
  4. | HandCursor
  5. | HResizeCursor
  6. | VResizeCursor

Standard cursor shapes.

type connection_event =
  1. | Connected
  2. | Disconnected

Joystick connection event.

type video_mode = {
  1. width : int;
  2. height : int;
  3. red_bits : int;
  4. green_bits : int;
  5. blue_bits : int;
  6. refresh_rate : int;
}

Video mode description as returned by getVideoMode(s).

type monitor
type window
type cursor
module GammaRamp : sig ... end

GammaRamp module. Describes the gamma ramp for a monitor.

module Image : sig ... end

Image data for creating custom cursors and window icons.

Module functions. These are mostly identical to their original GLFW counterparts.

There are no bindings for the glfwSetWindowUserPointer and glfwGetWindowUserPointer functions because you would have to use unsafe features to set the correct type for your data. If you need to make user data accessible inside a callback you can instead capture it in a closure and use that closure as your callback function.

There is no binding for the glfwGetProcAddress function because it would basicaly require to write an entire OpenGL wrapper to make the functions returned by GLFW usable from OCaml. Incidentaly the glfwExtensionSupported function is not provided either. There are numerous OpenGL bindings available for OCaml that you can use instead.

The Vulkan related functions are not supported as of now but we might look into it at some point.

val init : unit -> unit
val terminate : unit -> unit
val getVersion : unit -> int * int * int
val getVersionString : unit -> string
val getMonitors : unit -> monitor list
val getPrimaryMonitor : unit -> monitor
val getMonitorPos : monitor:monitor -> int * int
val getMonitorPhysicalSize : monitor:monitor -> int * int
val getMonitorName : monitor:monitor -> string
val setMonitorCallback : f:(monitor -> connection_event -> unit) option -> (monitor -> connection_event -> unit) option
val getVideoModes : monitor:monitor -> video_mode list
val getVideoMode : monitor:monitor -> video_mode
val setGamma : monitor:monitor -> gamma:float -> unit
val getGammaRamp : monitor:monitor -> GammaRamp.t
val setGammaRamp : monitor:monitor -> gamma_ramp:GammaRamp.t -> unit
val defaultWindowHints : unit -> unit
val windowHint : hint:'a WindowHint.t -> value:'a -> unit
val createWindow : width:int -> height:int -> title:string -> ?monitor:monitor -> ?share:window -> unit -> window
val destroyWindow : window:window -> unit
val windowShouldClose : window:window -> bool
val setWindowShouldClose : window:window -> b:bool -> unit
val setWindowTitle : window:window -> title:string -> unit
val setWindowIcon : window:window -> images:Image.t list -> unit
val getWindowPos : window:window -> int * int
val setWindowPos : window:window -> xpos:int -> ypos:int -> unit
val getWindowSize : window:window -> int * int
val setWindowSizeLimits : window:window -> minWidth:int option -> minHeight:int option -> maxWidth:int option -> maxHeight:int option -> unit
val setWindowAspectRatio : window:window -> numer:int -> denom:int -> unit
val setWindowSize : window:window -> width:int -> height:int -> unit
val getFramebufferSize : window:window -> int * int
val getWindowFrameSize : window:window -> int * int * int * int
val iconifyWindow : window:window -> unit
val restoreWindow : window:window -> unit
val maximizeWindow : window:window -> unit
val showWindow : window:window -> unit
val hideWindow : window:window -> unit
val focusWindow : window:window -> unit
val getWindowMonitor : window:window -> monitor option
val setWindowMonitor : window:window -> monitor:monitor option -> xpos:int -> ypos:int -> width:int -> height:int -> refreshRate:int option -> unit
val getWindowAttrib : window:window -> attribute:'a WindowAttribute.t -> 'a
val setWindowPosCallback : window:window -> f:(window -> int -> int -> unit) option -> (window -> int -> int -> unit) option
val setWindowSizeCallback : window:window -> f:(window -> int -> int -> unit) option -> (window -> int -> int -> unit) option
val setWindowCloseCallback : window:window -> f:(window -> unit) option -> (window -> unit) option
val setWindowRefreshCallback : window:window -> f:(window -> unit) option -> (window -> unit) option
val setWindowFocusCallback : window:window -> f:(window -> bool -> unit) option -> (window -> bool -> unit) option
val setWindowIconifyCallback : window:window -> f:(window -> bool -> unit) option -> (window -> bool -> unit) option
val setFramebufferSizeCallback : window:window -> f:(window -> int -> int -> unit) option -> (window -> int -> int -> unit) option
val pollEvents : unit -> unit
val waitEvents : unit -> unit
val waitEventsTimeout : timeout:float -> unit
val postEmptyEvent : unit -> unit
val getInputMode : window:window -> mode:'a input_mode -> 'a
val setInputMode : window:window -> mode:'a input_mode -> value:'a -> unit
val getKeyName : key:key -> scancode:int -> string option
val getKey : window:window -> key:key -> bool
val getMouseButton : window:window -> button:int -> bool
val getCursorPos : window:window -> float * float
val setCursorPos : window:window -> xpos:float -> ypos:float -> unit
val createCursor : image:Image.t -> xhot:int -> yhot:int -> cursor
val createStandardCursor : shape:cursor_shape -> cursor
val destroyCursor : cursor:cursor -> unit
val setCursor : window:window -> cursor:cursor -> unit
val setKeyCallback : window:window -> f:(window -> key -> int -> key_action -> key_mod list -> unit) option -> (window -> key -> int -> key_action -> key_mod list -> unit) option
val setCharCallback : window:window -> f:(window -> int -> unit) option -> (window -> int -> unit) option
val setCharModsCallback : window:window -> f:(window -> int -> key_mod list -> unit) option -> (window -> int -> key_mod list -> unit) option
val setMouseButtonCallback : window:window -> f:(window -> int -> bool -> key_mod list -> unit) option -> (window -> int -> bool -> key_mod list -> unit) option
val setCursorPosCallback : window:window -> f:(window -> float -> float -> unit) option -> (window -> float -> float -> unit) option
val setCursorEnterCallback : window:window -> f:(window -> bool -> unit) option -> (window -> bool -> unit) option
val setScrollCallback : window:window -> f:(window -> float -> float -> unit) option -> (window -> float -> float -> unit) option
val setDropCallback : window:window -> f:(window -> string list -> unit) option -> (window -> string list -> unit) option
val joystickPresent : joy:int -> bool
val getJoystickAxes : joy:int -> float array
val getJoystickButtons : joy:int -> bool array
val getJoystickName : joy:int -> string option
val setJoystickCallback : f:(int -> connection_event -> unit) option -> (int -> connection_event -> unit) option
val setClipboardString : window:window -> string:string -> unit
val getClipboardString : window:window -> string
val getTime : unit -> float
val setTime : time:float -> unit
val getTimerValue : unit -> int64
val getTimerFrequency : unit -> int64
val makeContextCurrent : window:window option -> unit
val getCurrentContext : unit -> window option
val swapBuffers : window:window -> unit
val swapInterval : interval:int -> unit
OCaml

Innovation. Community. Security.