package glfw-ocaml

  1. Overview
  2. Docs

Module GLFWSource

OCaml binding for GLFW 3.3

Sourceval version_major : int

GLFW-OCaml version numbers.

Sourceval version_minor : int
Sourceval version_revision : int
Sourceexception NotInitialized of string

Exceptions raised by the various functions of this module.

If you ever get an InvalidEnum exception and are not using unsafe features that would be a bug in GLFW-OCaml. Please fill an issue on GitHub.

Sourceexception NoCurrentContext of string
Sourceexception InvalidEnum of string
Sourceexception InvalidValue of string
Sourceexception OutOfMemory of string
Sourceexception ApiUnavailable of string
Sourceexception VersionUnavailable of string
Sourceexception PlatformError of string
Sourceexception FormatUnavailable of string
Sourceexception NoWindowContext of string
Sourcetype key_action =
  1. | Release
  2. | Press
  3. | Repeat
Sourcetype 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
Sourcetype key_mod =
  1. | Shift
  2. | Control
  3. | Alt
  4. | Super

Keyboard key and mouse button modifiers.

Sourceval mouse_button_max_count : int

Maximum number of buttons handled for a mouse.

Sourceval mouse_button_left : int

Values of common mouse buttons.

Sourceval mouse_button_right : int
Sourceval mouse_button_middle : int
Sourceval joystick_max_count : int

Maximum number of joysticks connected.

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

Client OpenGL API hint

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

Context robustness hint

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

OpenGL profile hint

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

Context release behavior hint

Sourcetype context_creation_api =
  1. | NativeContextApi
  2. | EGLContextApi
  3. | OSMesaContextApi

Context creation API hint

Sourcemodule A : sig ... end

Window hints and attributes. Use with windowHint, getWindowAttrib and setWindowAttrib like this:

include module type of A
Sourcetype ('a, _) window_attr =
  1. | Focused : (bool, [< `hint | `attr ]) window_attr
  2. | Iconified : (bool, [< `attr ]) window_attr
  3. | Resizable : (bool, [< `hint | `attr | `update ]) window_attr
  4. | Visible : (bool, [< `hint | `attr ]) window_attr
  5. | Decorated : (bool, [< `hint | `attr | `update ]) window_attr
  6. | AutoIconify : (bool, [< `hint | `attr | `update ]) window_attr
  7. | Floating : (bool, [< `hint | `attr | `update ]) window_attr
  8. | Maximized : (bool, [< `hint | `attr ]) window_attr
  9. | CenterCursor : (bool, [< `hint ]) window_attr
  10. | TransparentFramebuffer : (bool, [< `hint | `attr ]) window_attr
  11. | Hovered : (bool, [< `attr ]) window_attr
  12. | FocusOnShow : (bool, [< `hint | `attr | `update ]) window_attr
  13. | RedBits : (int option, [< `hint ]) window_attr
  14. | GreenBits : (int option, [< `hint ]) window_attr
  15. | BlueBits : (int option, [< `hint ]) window_attr
  16. | AlphaBits : (int option, [< `hint ]) window_attr
  17. | DepthBits : (int option, [< `hint ]) window_attr
  18. | StencilBits : (int option, [< `hint ]) window_attr
  19. | AccumRedBits : (int option, [< `hint ]) window_attr
  20. | AccumGreenBits : (int option, [< `hint ]) window_attr
  21. | AccumBlueBits : (int option, [< `hint ]) window_attr
  22. | AccumAlphaBits : (int option, [< `hint ]) window_attr
  23. | AuxBuffers : (int option, [< `hint ]) window_attr
  24. | Stereo : (bool, [< `hint ]) window_attr
  25. | Samples : (int option, [< `hint ]) window_attr
  26. | SrgbCapable : (bool, [< `hint ]) window_attr
  27. | RefreshRate : (int option, [< `hint ]) window_attr
  28. | DoubleBuffer : (bool, [< `hint ]) window_attr
  29. | ClientApi : (client_api, [< `hint | `attr ]) window_attr
  30. | ContextVersionMajor : (int, [< `hint | `attr ]) window_attr
  31. | ContextVersionMinor : (int, [< `hint | `attr ]) window_attr
  32. | ContextRevision : (int, [< `attr ]) window_attr
  33. | ContextRobustness : (context_robustness, [< `hint | `attr ]) window_attr
  34. | OpenGLForwardCompat : (bool, [< `hint | `attr ]) window_attr
  35. | OpenGLDebugContext : (bool, [< `hint | `attr ]) window_attr
  36. | OpenGLProfile : (opengl_profile, [< `hint | `attr ]) window_attr
  37. | ContextReleaseBehavior : (context_release_behavior, [< `hint ]) window_attr
  38. | ContextNoError : (bool, [< `hint ]) window_attr
  39. | ContextCreationApi : (context_creation_api, [< `hint | `attr ]) window_attr
  40. | ScaleToMonitor : (bool, [< `hint ]) window_attr
  41. | CocoaRetinaFramebuffer : (bool, [< `hint ]) window_attr
  42. | CocoaFrameName : (string, [< `hint ]) window_attr
  43. | CocoaGraphicsSwitching : (bool, [< `hint ]) window_attr
  44. | X11ClassName : (string, [< `hint ]) window_attr
  45. | X11InstanceName : (string, [< `hint ]) window_attr
Sourcemodule type S = sig ... end

Deprecated window hints and attributes modules.

Sourcemodule WindowHint : S with type 'a t = ('a, [ `hint ]) window_attr
Sourcemodule WindowAttribute : S with type 'a t = ('a, [ `attr ]) window_attr
Sourcemodule WindowUpdateableAttribute : S with type 'a t = ('a, [ `update ]) window_attr
Sourcetype cursor_mode =
  1. | Normal
  2. | Hidden
  3. | Disabled

Mouse cursor input mode.

Sourcetype _ input_mode =
  1. | Cursor : cursor_mode input_mode
  2. | StickyKeys : bool input_mode
  3. | StickyMouseButtons : bool input_mode
  4. | LockKeyMods : bool input_mode
  5. | RawMouseMotion : bool input_mode

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

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

Standard cursor shapes.

Sourcetype connection_event =
  1. | Connected
  2. | Disconnected

Joystick connection event.

Sourcetype _ init_hint =
  1. | JoystickHatButtons : bool init_hint
  2. | CocoaChdirResources : bool init_hint
  3. | CocoaMenubar : bool init_hint
Sourcetype 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).

Sourcetype monitor
Sourcetype window
Sourcetype cursor
Sourcemodule GammaRamp : sig ... end

GammaRamp module. Describes the gamma ramp for a monitor.

Sourcemodule Image : sig ... end

Image data for creating custom cursors and window icons.

Sourcetype hat_status =
  1. | HatUp
  2. | HatRight
  3. | HatDown
  4. | HatLeft
Sourcetype gamepad_state = {
  1. buttons : bool array;
  2. axes : float array;
}

Gamepad state data as returned by getGamepadState.

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

There are no bindings for the glfwSet,Get*UserPointer 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 glfwWindowHintString function. Simply pass your string to the windowHint function as you would for any other value type.

The window parameter of the set,getClipboardString functions has been deprecated and is no longer used. You may pass the unit value (or anything) as the window argument.

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. 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.

Sourceval init : unit -> unit
Sourceval terminate : unit -> unit
Sourceval initHint : hint:'a init_hint -> value:'a -> unit
Sourceval getVersion : unit -> int * int * int
Sourceval getVersionString : unit -> string
Sourceval getMonitors : unit -> monitor list
Sourceval getPrimaryMonitor : unit -> monitor
Sourceval getMonitorPos : monitor:monitor -> int * int
Sourceval getMonitorWorkarea : monitor:monitor -> int * int * int * int
Sourceval getMonitorPhysicalSize : monitor:monitor -> int * int
Sourceval getMonitorContentScale : monitor:monitor -> float * float
Sourceval getMonitorName : monitor:monitor -> string
Sourceval setMonitorCallback : f:(monitor -> connection_event -> unit) option -> (monitor -> connection_event -> unit) option
Sourceval getVideoModes : monitor:monitor -> video_mode list
Sourceval getVideoMode : monitor:monitor -> video_mode
Sourceval setGamma : monitor:monitor -> gamma:float -> unit
Sourceval getGammaRamp : monitor:monitor -> GammaRamp.t
Sourceval setGammaRamp : monitor:monitor -> gamma_ramp:GammaRamp.t -> unit
Sourceval defaultWindowHints : unit -> unit
Sourceval windowHint : hint:('a, [ `hint ]) window_attr -> value:'a -> unit
Sourceval createWindow : width:int -> height:int -> title:string -> ?monitor:monitor -> ?share:window -> unit -> window
Sourceval destroyWindow : window:window -> unit
Sourceval windowShouldClose : window:window -> bool
Sourceval setWindowShouldClose : window:window -> b:bool -> unit
Sourceval setWindowTitle : window:window -> title:string -> unit
Sourceval setWindowIcon : window:window -> images:Image.t list -> unit
Sourceval getWindowPos : window:window -> int * int
Sourceval setWindowPos : window:window -> xpos:int -> ypos:int -> unit
Sourceval getWindowSize : window:window -> int * int
Sourceval setWindowSizeLimits : window:window -> minWidth:int option -> minHeight:int option -> maxWidth:int option -> maxHeight:int option -> unit
Sourceval setWindowAspectRatio : window:window -> numer:int -> denom:int -> unit
Sourceval setWindowSize : window:window -> width:int -> height:int -> unit
Sourceval getFramebufferSize : window:window -> int * int
Sourceval getWindowFrameSize : window:window -> int * int * int * int
Sourceval getWindowContentScale : window:window -> float * float
Sourceval getWindowOpacity : window:window -> float
Sourceval setWindowOpacity : window:window -> opacity:float -> unit
Sourceval iconifyWindow : window:window -> unit
Sourceval restoreWindow : window:window -> unit
Sourceval maximizeWindow : window:window -> unit
Sourceval showWindow : window:window -> unit
Sourceval hideWindow : window:window -> unit
Sourceval focusWindow : window:window -> unit
Sourceval requestWindowAttention : window:window -> unit
Sourceval getWindowMonitor : window:window -> monitor option
Sourceval setWindowMonitor : window:window -> monitor:monitor option -> xpos:int -> ypos:int -> width:int -> height:int -> refreshRate:int option -> unit
Sourceval getWindowAttrib : window:window -> attribute:('a, [ `attr ]) window_attr -> 'a
Sourceval setWindowAttrib : window:window -> attribute:('a, [ `update ]) window_attr -> value:'a -> unit
Sourceval setWindowPosCallback : window:window -> f:(window -> int -> int -> unit) option -> (window -> int -> int -> unit) option
Sourceval setWindowSizeCallback : window:window -> f:(window -> int -> int -> unit) option -> (window -> int -> int -> unit) option
Sourceval setWindowCloseCallback : window:window -> f:(window -> unit) option -> (window -> unit) option
Sourceval setWindowRefreshCallback : window:window -> f:(window -> unit) option -> (window -> unit) option
Sourceval setWindowFocusCallback : window:window -> f:(window -> bool -> unit) option -> (window -> bool -> unit) option
Sourceval setWindowIconifyCallback : window:window -> f:(window -> bool -> unit) option -> (window -> bool -> unit) option
Sourceval setWindowMaximizeCallback : window:window -> f:(window -> bool -> unit) option -> (window -> bool -> unit) option
Sourceval setFramebufferSizeCallback : window:window -> f:(window -> int -> int -> unit) option -> (window -> int -> int -> unit) option
Sourceval setWindowContentScaleCallback : window:window -> f:(window -> float -> float -> unit) option -> (window -> float -> float -> unit) option
Sourceval pollEvents : unit -> unit
Sourceval waitEvents : unit -> unit
Sourceval waitEventsTimeout : timeout:float -> unit
Sourceval postEmptyEvent : unit -> unit
Sourceval getInputMode : window:window -> mode:'a input_mode -> 'a
Sourceval setInputMode : window:window -> mode:'a input_mode -> value:'a -> unit
Sourceval rawMouseMotionSupported : unit -> bool
Sourceval getKeyName : key:key -> scancode:int -> string option
Sourceval getKeyScancode : key:key -> int
Sourceval getKey : window:window -> key:key -> bool
Sourceval getMouseButton : window:window -> button:int -> bool
Sourceval getCursorPos : window:window -> float * float
Sourceval setCursorPos : window:window -> xpos:float -> ypos:float -> unit
Sourceval createCursor : image:Image.t -> xhot:int -> yhot:int -> cursor
Sourceval createStandardCursor : shape:cursor_shape -> cursor
Sourceval destroyCursor : cursor:cursor -> unit
Sourceval setCursor : window:window -> cursor:cursor -> unit
Sourceval setKeyCallback : window:window -> f:(window -> key -> int -> key_action -> key_mod list -> unit) option -> (window -> key -> int -> key_action -> key_mod list -> unit) option
Sourceval setCharCallback : window:window -> f:(window -> int -> unit) option -> (window -> int -> unit) option
Sourceval setCharModsCallback : window:window -> f:(window -> int -> key_mod list -> unit) option -> (window -> int -> key_mod list -> unit) option
  • deprecated
Sourceval setMouseButtonCallback : window:window -> f:(window -> int -> bool -> key_mod list -> unit) option -> (window -> int -> bool -> key_mod list -> unit) option
Sourceval setCursorPosCallback : window:window -> f:(window -> float -> float -> unit) option -> (window -> float -> float -> unit) option
Sourceval setCursorEnterCallback : window:window -> f:(window -> bool -> unit) option -> (window -> bool -> unit) option
Sourceval setScrollCallback : window:window -> f:(window -> float -> float -> unit) option -> (window -> float -> float -> unit) option
Sourceval setDropCallback : window:window -> f:(window -> string list -> unit) option -> (window -> string list -> unit) option
Sourceval joystickPresent : joy:int -> bool
Sourceval getJoystickAxes : joy:int -> float array
Sourceval getJoystickButtons : joy:int -> bool array
Sourceval getJoystickHats : joy:int -> hat_status list array
Sourceval getJoystickName : joy:int -> string option
Sourceval getJoystickGUID : joy:int -> string option
Sourceval joystickIsGamepad : joy:int -> bool
Sourceval setJoystickCallback : f:(int -> connection_event -> unit) option -> (int -> connection_event -> unit) option
Sourceval updateGamepadMappings : string:string -> unit
Sourceval getGamepadName : joy:int -> string option
Sourceval getGamepadState : joy:int -> gamepad_state
Sourceval setClipboardString : window:_ -> string:string -> unit
Sourceval getClipboardString : window:_ -> string
Sourceval getTime : unit -> float
Sourceval setTime : time:float -> unit
Sourceval getTimerValue : unit -> int64
Sourceval getTimerFrequency : unit -> int64
Sourceval makeContextCurrent : window:window option -> unit
Sourceval getCurrentContext : unit -> window option
Sourceval swapBuffers : window:window -> unit
Sourceval swapInterval : interval:int -> unit
Sourceval extensionSupported : extension:string -> bool
OCaml

Innovation. Community. Security.