(*========================================================================
 glfw version
 ========================================================================*)

val version_major : int 
val version_minor : int 
val version_revision : int 


(*========================================================================
 input handling definitions
 ========================================================================*)

(* key and button state/action definitions *)
val release : int
val press   : int	

(* keyboard key definitions: 8-bit iso-8859-1 (latin 1) encoding is used 
 for printable keys (such as a-z, 0-9 etc), and values above 256
 represent special (non-printable) keys (e.g. f1, page up etc). *)
val key_unknown     : int
val key_space       : int
val key_special     : int
val key_esc         : int
val key_f1          : int
val key_f2          : int
val key_f3          : int
val key_f4          : int
val key_f5          : int
val key_f6          : int
val key_f7          : int
val key_f8          : int
val key_f9          : int
val key_f10         : int
val key_f11         : int
val key_f12         : int
val key_f13         : int
val key_f14         : int
val key_f15         : int
val key_f16         : int
val key_f17         : int
val key_f18         : int
val key_f19         : int
val key_f20         : int
val key_f21         : int
val key_f22         : int
val key_f23         : int
val key_f24         : int
val key_f25         : int
val key_up          : int
val key_down        : int
val key_left        : int
val key_right       : int
val key_lshift      : int
val key_rshift      : int
val key_lctrl       : int
val key_rctrl       : int
val key_lalt        : int
val key_ralt        : int
val key_tab         : int
val key_enter       : int
val key_backspace   : int
val key_insert      : int
val key_del         : int
val key_pageup      : int
val key_pagedown    : int
val key_home        : int
val key_end         : int
val key_kp_0        : int
val key_kp_1        : int
val key_kp_2        : int
val key_kp_3        : int
val key_kp_4        : int
val key_kp_5        : int
val key_kp_6        : int
val key_kp_7        : int
val key_kp_8        : int
val key_kp_9        : int
val key_kp_divide   : int
val key_kp_multiply : int
val key_kp_subtract : int
val key_kp_add      : int
val key_kp_decimal  : int
val key_kp_equal    : int
val key_kp_enter    : int
val key_last        : int

(* mouse button definitions *)
val mouse_button_left      : int
val mouse_button_right  : int
val mouse_button_middle : int
val mouse_button_last   : int

(* joystick identifiers *)
val joystick_1     : int
val joystick_2     : int
val joystick_3     : int
val joystick_4     : int
val joystick_5     : int
val joystick_6     : int
val joystick_7     : int
val joystick_8     : int
val joystick_9     : int
val joystick_10    : int
val joystick_11    : int
val joystick_12    : int
val joystick_13    : int
val joystick_14    : int
val joystick_15    : int
val joystick_16    : int
val joystick_last  : int


(*========================================================================
 other definitions
 ========================================================================*)

(* glfwopenwindow modes *)
val window       : int
val fullscreen   : int

(* glfwgetwindowparam tokens *)
val opened       : int
val active       : int
val iconified    : int
val accelerated  : int
val red_bits     : int
val green_bits   : int
val blue_bits    : int
val alpha_bits   : int
val depth_bits   : int
val stencil_bits : int

(* the following constants are used for both glfwgetwindowparam
 and glfwopenwindowhint *)
val refresh_rate     : int
val accum_red_bits   : int
val accum_green_bits : int
val accum_blue_bits  : int
val accum_alpha_bits : int
val aux_buffers      : int
val stereo           : int

(* glfwenable/glfwdisable tokens *)
val mouse_cursor         : int
val sticky_keys          : int
val sticky_mouse_buttons : int
val system_keys          : int
val key_repeat           : int
val auto_poll_events     : int

(* glfwwaitthread wait modes *)
val wait     : int
val nowait   : int

(* glfwgetjoystickparam tokens *)
val present : int
val axes    : int
val buttons : int

(* glfwreadimage/glfwloadtexture2d flags *)
val no_rescale_bit    : int (* only for glfwreadimage *)
val origin_ul_bit     : int
val build_mipmaps_bit : int (* only for glfwloadtexture2d *)

(* time spans longer than this (seconds) are considered to be infinity *)
val infinity		   : float
(* File generated from glfw.idl *)

type vidmode = {
  vidmode_width: int;
  vidmode_height: int;
  vidmode_red_bits: int;
  vidmode_blue_bits: int;
  vidmode_green_bits: int;
}
and image = {
  image_width: int;
  image_height: int;
  image_format: int;
  image_bytes_per_pixel: int;
  image_data: char option;
}

external init : unit -> int
	= "camlidl_glfw_glfwInit"

external terminate : unit -> unit
	= "camlidl_glfw_glfwTerminate"

external get_version : unit -> int * int * int
	= "camlidl_glfw_glfwGetVersion"

external open_window : int -> int -> int -> int -> int -> int -> int -> int -> int -> int
	= "camlidl_glfw_glfwOpenWindow_bytecode" "camlidl_glfw_glfwOpenWindow"

external open_window_hint : int -> int -> unit
	= "camlidl_glfw_glfwOpenWindowHint"

external close_window : unit -> unit
	= "camlidl_glfw_glfwCloseWindow"

external set_window_title : string -> unit
	= "camlidl_glfw_glfwSetWindowTitle"

external get_window_size : unit -> int * int
	= "camlidl_glfw_glfwGetWindowSize"

external set_window_size : int -> int -> unit
	= "camlidl_glfw_glfwSetWindowSize"

external set_window_pos : int -> int -> unit
	= "camlidl_glfw_glfwSetWindowPos"

external iconify_window : unit -> unit
	= "camlidl_glfw_glfwIconifyWindow"

external restore_window : unit -> unit
	= "camlidl_glfw_glfwRestoreWindow"

external swap_buffers : unit -> unit
	= "camlidl_glfw_glfwSwapBuffers"

external swap_interval : int -> unit
	= "camlidl_glfw_glfwSwapInterval"

external get_window_param : int -> int
	= "camlidl_glfw_glfwGetWindowParam"

external get_video_modes : int -> int * vidmode array
	= "camlidl_glfw_glfwGetVideoModes"

external get_desktop_mode : unit -> vidmode
	= "camlidl_glfw_glfwGetDesktopMode"

external poll_events : unit -> unit
	= "camlidl_glfw_glfwPollEvents"

external get_key : int -> int
	= "camlidl_glfw_glfwGetKey"

external get_mouse_button : int -> int
	= "camlidl_glfw_glfwGetMouseButton"

external get_mouse_pos : unit -> int * int
	= "camlidl_glfw_glfwGetMousePos"

external set_mouse_pos : int -> int -> unit
	= "camlidl_glfw_glfwSetMousePos"

external get_mouse_wheel : unit -> int
	= "camlidl_glfw_glfwGetMouseWheel"

external set_mouse_wheel : int -> unit
	= "camlidl_glfw_glfwSetMouseWheel"

external get_joystick_param : int -> int -> int
	= "camlidl_glfw_glfwGetJoystickParam"

external get_joystick_pos : int -> int -> int * float
	= "camlidl_glfw_glfwGetJoystickPos"

external get_joystick_buttons : int -> int -> int * char
	= "camlidl_glfw_glfwGetJoystickButtons"

external get_time : unit -> float
	= "camlidl_glfw_glfwGetTime"

external set_time : float -> unit
	= "camlidl_glfw_glfwSetTime"

external sleep : float -> unit
	= "camlidl_glfw_glfwSleep"

external extension_supported : string -> int
	= "camlidl_glfw_glfwExtensionSupported"

external get_gl_version : unit -> int * int * int
	= "camlidl_glfw_glfwGetGLVersion"

external get_number_of_processors : unit -> int
	= "camlidl_glfw_glfwGetNumberOfProcessors"

external enable : int -> unit
	= "camlidl_glfw_glfwEnable"

external disable : int -> unit
	= "camlidl_glfw_glfwDisable"

external read_image : string -> int -> int * image
	= "camlidl_glfw_glfwReadImage"

external free_image : image option -> unit
	= "camlidl_glfw_glfwFreeImage"

external load_texture_2d : string -> int -> int
	= "camlidl_glfw_glfwLoadTexture2D"

val set_window_size_callback : (int -> int -> unit) -> unit
val set_key_callback  : (int -> bool -> unit) -> unit
val set_char_callback : (int -> bool -> unit) -> unit 
val set_mouse_pos_callback : (int -> int -> unit) -> unit
val set_mouse_button_callback : (int -> bool -> unit) -> unit
val set_mouse_wheel_callback : (int -> unit) -> unit
