    #ifndef _glfw3_bi_
    #define _glfw3_bi_

    /'************************************************************************
     * GLFW - An OpenGL library
     * API version: 3.0.1
     * WWW:         http://www.glfw.org/
     *------------------------------------------------------------------------
     * Copyright (c) 2002-2006 Marcus Geelnard
     * Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
     *
     * This software is provided 'as-is', without any express or implied
     * warranty. In no event will the authors be held liable for any damages
     * arising from the use of this software.
     *
     * Permission is granted to anyone to use this software for any purpose,
     * including commercial applications, and to alter it and redistribute it
     * freely, subject to the following restrictions:
     *
     * 1. The origin of this software must not be misrepresented; you must not
     *    claim that you wrote the original software. If you use this software
     *    in a product, an acknowledgment in the product documentation would
     *    be appreciated but is not required.
     *
     * 2. Altered source versions must be plainly marked as such, and must not
     *    be misrepresented as being the original software.
     *
     * 3. This notice may not be removed or altered from any source
     *    distribution.
     *
     ************************************************************************'/

    #if defined(__FB_WIN32__)
      #define CALLBACK cdecl
      #define APIENTRY stdcall
    #elseif defined(__FB_LINUX__)
      #define CALLBACK cdecl
      #define APIENTRY cdecl
    #else
    #error OS must be Win32 or Linux x86 !
    #endif

    #include once "GL/gl.bi"
    #include once "GL/glu.bi"

    #inclib "glfw3"

    /'************************************************************************
     * GLFW API tokens
     ************************************************************************'/
    #define GLFW_VERSION_MAJOR          3
    #define GLFW_VERSION_MINOR          0
    #define GLFW_VERSION_REVISION       1

    #define GLFW_RELEASE                0
    #define GLFW_PRESS                  1
    #define GLFW_REPEAT                 2

    /' The unknown key '/
    #define GLFW_KEY_UNKNOWN            -1

    /' Printable keys '/
    #define GLFW_KEY_SPACE              32
    #define GLFW_KEY_APOSTROPHE         39  
    #define GLFW_KEY_COMMA              44  /' , '/
    #define GLFW_KEY_MINUS              45  /' - '/
    #define GLFW_KEY_PERIOD             46  /' . '/
    #define GLFW_KEY_SLASH              47  /' / '/
    #define GLFW_KEY_0                  48
    #define GLFW_KEY_1                  49
    #define GLFW_KEY_2                  50
    #define GLFW_KEY_3                  51
    #define GLFW_KEY_4                  52
    #define GLFW_KEY_5                  53
    #define GLFW_KEY_6                  54
    #define GLFW_KEY_7                  55
    #define GLFW_KEY_8                  56
    #define GLFW_KEY_9                  57
    #define GLFW_KEY_SEMICOLON          59  /' ; '/
    #define GLFW_KEY_EQUAL              61  /' = '/
    #define GLFW_KEY_A                  65
    #define GLFW_KEY_B                  66
    #define GLFW_KEY_C                  67
    #define GLFW_KEY_D                  68
    #define GLFW_KEY_E                  69
    #define GLFW_KEY_F                  70
    #define GLFW_KEY_G                  71
    #define GLFW_KEY_H                  72
    #define GLFW_KEY_I                  73
    #define GLFW_KEY_J                  74
    #define GLFW_KEY_K                  75
    #define GLFW_KEY_L                  76
    #define GLFW_KEY_M                  77
    #define GLFW_KEY_N                  78
    #define GLFW_KEY_O                  79
    #define GLFW_KEY_P                  80
    #define GLFW_KEY_Q                  81
    #define GLFW_KEY_R                  82
    #define GLFW_KEY_S                  83
    #define GLFW_KEY_T                  84
    #define GLFW_KEY_U                  85
    #define GLFW_KEY_V                  86
    #define GLFW_KEY_W                  87
    #define GLFW_KEY_X                  88
    #define GLFW_KEY_Y                  89
    #define GLFW_KEY_Z                  90
    #define GLFW_KEY_LEFT_BRACKET       91  /' [ '/
    #define GLFW_KEY_BACKSLASH          92  /' \ '/
    #define GLFW_KEY_RIGHT_BRACKET      93  /' ] '/
    #define GLFW_KEY_GRAVE_ACCENT       96  /' ` '/
    #define GLFW_KEY_WORLD_1            161 /' non-US #1 '/
    #define GLFW_KEY_WORLD_2            162 /' non-US #2 '/

    /' Function keys '/
    #define GLFW_KEY_ESCAPE             256
    #define GLFW_KEY_ENTER              257
    #define GLFW_KEY_TAB                258
    #define GLFW_KEY_BACKSPACE          259
    #define GLFW_KEY_INSERT             260
    #define GLFW_KEY_DELETE             261
    #define GLFW_KEY_RIGHT              262
    #define GLFW_KEY_LEFT               263
    #define GLFW_KEY_DOWN               264
    #define GLFW_KEY_UP                 265
    #define GLFW_KEY_PAGE_UP            266
    #define GLFW_KEY_PAGE_DOWN          267
    #define GLFW_KEY_HOME               268
    #define GLFW_KEY_END                269
    #define GLFW_KEY_CAPS_LOCK          280
    #define GLFW_KEY_SCROLL_LOCK        281
    #define GLFW_KEY_NUM_LOCK           282
    #define GLFW_KEY_PRINT_SCREEN       283
    #define GLFW_KEY_PAUSE              284
    #define GLFW_KEY_F1                 290
    #define GLFW_KEY_F2                 291
    #define GLFW_KEY_F3                 292
    #define GLFW_KEY_F4                 293
    #define GLFW_KEY_F5                 294
    #define GLFW_KEY_F6                 295
    #define GLFW_KEY_F7                 296
    #define GLFW_KEY_F8                 297
    #define GLFW_KEY_F9                 298
    #define GLFW_KEY_F10                299
    #define GLFW_KEY_F11                300
    #define GLFW_KEY_F12                301
    #define GLFW_KEY_F13                302
    #define GLFW_KEY_F14                303
    #define GLFW_KEY_F15                304
    #define GLFW_KEY_F16                305
    #define GLFW_KEY_F17                306
    #define GLFW_KEY_F18                307
    #define GLFW_KEY_F19                308
    #define GLFW_KEY_F20                309
    #define GLFW_KEY_F21                310
    #define GLFW_KEY_F22                311
    #define GLFW_KEY_F23                312
    #define GLFW_KEY_F24                313
    #define GLFW_KEY_F25                314
    #define GLFW_KEY_KP_0               320
    #define GLFW_KEY_KP_1               321
    #define GLFW_KEY_KP_2               322
    #define GLFW_KEY_KP_3               323
    #define GLFW_KEY_KP_4               324
    #define GLFW_KEY_KP_5               325
    #define GLFW_KEY_KP_6               326
    #define GLFW_KEY_KP_7               327
    #define GLFW_KEY_KP_8               328
    #define GLFW_KEY_KP_9               329
    #define GLFW_KEY_KP_DECIMAL         330
    #define GLFW_KEY_KP_DIVIDE          331
    #define GLFW_KEY_KP_MULTIPLY        332
    #define GLFW_KEY_KP_SUBTRACT        333
    #define GLFW_KEY_KP_ADD             334
    #define GLFW_KEY_KP_ENTER           335
    #define GLFW_KEY_KP_EQUAL           336
    #define GLFW_KEY_LEFT_SHIFT         340
    #define GLFW_KEY_LEFT_CONTROL       341
    #define GLFW_KEY_LEFT_ALT           342
    #define GLFW_KEY_LEFT_SUPER         343
    #define GLFW_KEY_RIGHT_SHIFT        344
    #define GLFW_KEY_RIGHT_CONTROL      345
    #define GLFW_KEY_RIGHT_ALT          346
    #define GLFW_KEY_RIGHT_SUPER        347
    #define GLFW_KEY_MENU               348
    #define GLFW_KEY_LAST               GLFW_KEY_MENU

    #define GLFW_MOD_SHIFT           &H0001
    #define GLFW_MOD_CONTROL         &H0002
    #define GLFW_MOD_ALT             &H0004
    #define GLFW_MOD_SUPER           &H0008

    #define GLFW_MOUSE_BUTTON_1         0
    #define GLFW_MOUSE_BUTTON_2         1
    #define GLFW_MOUSE_BUTTON_3         2
    #define GLFW_MOUSE_BUTTON_4         3
    #define GLFW_MOUSE_BUTTON_5         4
    #define GLFW_MOUSE_BUTTON_6         5
    #define GLFW_MOUSE_BUTTON_7         6
    #define GLFW_MOUSE_BUTTON_8         7
    #define GLFW_MOUSE_BUTTON_LAST      GLFW_MOUSE_BUTTON_8
    #define GLFW_MOUSE_BUTTON_LEFT      GLFW_MOUSE_BUTTON_1
    #define GLFW_MOUSE_BUTTON_RIGHT     GLFW_MOUSE_BUTTON_2
    #define GLFW_MOUSE_BUTTON_MIDDLE    GLFW_MOUSE_BUTTON_3

    #define GLFW_JOYSTICK_1             0
    #define GLFW_JOYSTICK_2             1
    #define GLFW_JOYSTICK_3             2
    #define GLFW_JOYSTICK_4             3
    #define GLFW_JOYSTICK_5             4
    #define GLFW_JOYSTICK_6             5
    #define GLFW_JOYSTICK_7             6
    #define GLFW_JOYSTICK_8             7
    #define GLFW_JOYSTICK_9             8
    #define GLFW_JOYSTICK_10            9
    #define GLFW_JOYSTICK_11            10
    #define GLFW_JOYSTICK_12            11
    #define GLFW_JOYSTICK_13            12
    #define GLFW_JOYSTICK_14            13
    #define GLFW_JOYSTICK_15            14
    #define GLFW_JOYSTICK_16            15
    #define GLFW_JOYSTICK_LAST          GLFW_JOYSTICK_16

    #define GLFW_NOT_INITIALIZED        &H00010001
    #define GLFW_NO_CURRENT_CONTEXT     &H00010002
    #define GLFW_INVALID_ENUM           &H00010003
    #define GLFW_INVALID_VALUE          &H00010004
    #define GLFW_OUT_OF_MEMORY          &H00010005
    #define GLFW_API_UNAVAILABLE        &H00010006
    #define GLFW_VERSION_UNAVAILABLE    &H00010007
    #define GLFW_PLATFORM_ERROR         &H00010008
    #define GLFW_FORMAT_UNAVAILABLE     &H00010009

    #define GLFW_FOCUSED                &H00020001
    #define GLFW_ICONIFIED              &H00020002
    #define GLFW_RESIZABLE              &H00020003
    #define GLFW_VISIBLE                &H00020004
    #define GLFW_DECORATED              &H00020005

    #define GLFW_RED_BITS               &H00021001
    #define GLFW_GREEN_BITS             &H00021002
    #define GLFW_BLUE_BITS              &H00021003
    #define GLFW_ALPHA_BITS             &H00021004
    #define GLFW_DEPTH_BITS             &H00021005
    #define GLFW_STENCIL_BITS           &H00021006
    #define GLFW_ACCUM_RED_BITS         &H00021007
    #define GLFW_ACCUM_GREEN_BITS       &H00021008
    #define GLFW_ACCUM_BLUE_BITS        &H00021009
    #define GLFW_ACCUM_ALPHA_BITS       &H0002100A
    #define GLFW_AUX_BUFFERS            &H0002100B
    #define GLFW_STEREO                 &H0002100C
    #define GLFW_SAMPLES                &H0002100D
    #define GLFW_SRGB_CAPABLE           &H0002100E
    #define GLFW_REFRESH_RATE           &H0002100F

    #define GLFW_CLIENT_API             &H00022001
    #define GLFW_CONTEXT_VERSION_MAJOR  &H00022002
    #define GLFW_CONTEXT_VERSION_MINOR  &H00022003
    #define GLFW_CONTEXT_REVISION       &H00022004
    #define GLFW_CONTEXT_ROBUSTNESS     &H00022005
    #define GLFW_OPENGL_FORWARD_COMPAT  &H00022006
    #define GLFW_OPENGL_DEBUG_CONTEXT   &H00022007
    #define GLFW_OPENGL_PROFILE         &H00022008

    #define GLFW_OPENGL_API             &H00030001
    #define GLFW_OPENGL_ES_API          &H00030002

    #define GLFW_NO_ROBUSTNESS                   0
    #define GLFW_NO_RESET_NOTIFICATION  &H00031001
    #define GLFW_LOSE_CONTEXT_ON_RESET  &H00031002

    #define GLFW_OPENGL_ANY_PROFILE              0
    #define GLFW_OPENGL_CORE_PROFILE    &H00032001
    #define GLFW_OPENGL_COMPAT_PROFILE  &H00032002

    #define GLFW_CURSOR                 &H00033001
    #define GLFW_STICKY_KEYS            &H00033002
    #define GLFW_STICKY_MOUSE_BUTTONS   &H00033003

    #define GLFW_CURSOR_NORMAL          &H00034001
    #define GLFW_CURSOR_HIDDEN          &H00034002
    #define GLFW_CURSOR_DISABLED        &H00034003

    #define GLFW_CONNECTED              &H00040001
    #define GLFW_DISCONNECTED           &H00040002


    /'************************************************************************
     * GLFW API types
     ************************************************************************'/
    type GLFWmonitor as any
    type GLFWwindow as any

    type GLFWerrorfun           as sub CALLBACK(errorcode as integer,errordescription as const zstring ptr)
    type GLFWwindowposfun       as sub CALLBACK(win as GLFWwindow ptr, x as integer, y as integer)
    type GLFWwindowsizefun      as sub CALLBACK(win as GLFWwindow ptr, w as integer, h as integer)
    type GLFWwindowclosefun     as sub CALLBACK(win as GLFWwindow ptr)
    type GLFWwindowrefreshfun   as sub CALLBACK(win as GLFWwindow ptr)
    type GLFWwindowfocusfun     as sub CALLBACK(win as GLFWwindow ptr, focused as integer)
    type GLFWwindowiconifyfun   as sub CALLBACK(win as GLFWwindow ptr, iconified as integer)
    type GLFWframebuffersizefun as sub CALLBACK(win as GLFWwindow ptr, w as integer,h as integer)
    type GLFWmousebuttonfun     as sub CALLBACK(win as GLFWwindow ptr, button as integer, action as integer, buttonbits as integer)
    type GLFWcursorposfun       as sub CALLBACK(win as GLFWwindow ptr, x as double, y as double)
    type GLFWcursorenterfun     as sub CALLBACK(win as GLFWwindow ptr, entered as integer)
    type GLFWscrollfun          as sub CALLBACK(win as GLFWwindow ptr, xoff as double, yoff as double)
    type GLFWkeyfun             as sub CALLBACK(win as GLFWwindow ptr, key as integer, scancode as integer, action as integer, bitmask as integer)
    type GLFWcharfun            as sub CALLBACK(win as GLFWwindow ptr, unicode as uinteger)
    type GLFWmonitorfun         as sub CALLBACK(win as GLFWmonitor ptr, event as integer)

    ' This describes a single video mode.
    type GLFWvidmode
      ' The width, in screen coordinates, of the video mode.
      as integer width
      ' The height, in screen coordinates, of the video mode.
      as integer  height
      ' The bit depth of the red channel of the video mode.
      as integer redBits
      ' The bit depth of the green channel of the video mode.
      as integer greenBits
      ' The bit depth of the blue channel of the video mode.
      as integer blueBits
      ' The refresh rate, in Hz, of the video mode.
      as integer refreshRate
    end type

    ' This describes the gamma ramp for a monitor.
    type GLFWgammaramp
      ' An array of value describing the response of the red channel.
      as ushort ptr red
      ' An array of value describing the response of the green channel.
      as ushort ptr green
      ' An array of value describing the response of the blue channel.
      as ushort ptr blue
      ' The number of elements in each array.
      as uinteger size
    end type

    /'************************************************************************
     * GLFW API functions
     ************************************************************************'/
    #if defined(__FB_WIN32__)
      extern "Windows-MS"
      declare function glfwGetWin32Window(win as GLFWwindow ptr) as any ptr
      declare function glfwGetWGLContext(win as GLFWwindow ptr) as any ptr
    #elseif defined(__FB_LINUX__)
      extern "c"
      declare function glfwGetX11Display() as any ptr
      declare function glfwGetX11Window(win as GLFWwindow ptr) as any ptr
      declare function glfwGetGLXContext(win as GLFWwindow ptr) as any ptr
    #endif

    declare function glfwInit() as integer
    declare sub      glfwTerminate()

    declare sub      glfwGetVersion(byref major as integer,byref minor as integer,byref rev as integer)
    declare function glfwGetVersionString() as zstring ptr

    declare function glfwSetErrorCallback(cbfun as GLFWerrorfun) as GLFWerrorfun

    declare function glfwGetMonitors(byref count as integer) as GLFWmonitor ptr ptr
    declare function glfwGetPrimaryMonitor() as GLFWmonitor ptr
    declare sub      glfwGetMonitorPos(monitor as GLFWmonitor ptr, byref xpos as integer,byref ypos as integer)
    declare sub      glfwGetMonitorPhysicalSize(monitor as GLFWmonitor ptr,byref width as integer,byref height as integer)
    declare function glfwGetMonitorName(monitor as GLFWmonitor ptr) as zstring ptr
    declare function glfwSetMonitorCallback(cb as GLFWmonitorfun) as GLFWmonitorfun
    declare function glfwGetVideoModes(monitoe as GLFWmonitor ptr,byref count as integer) as const GLFWvidmode ptr
    declare function glfwGetVideoMode(monitor as GLFWmonitor ptr) as const GLFWvidmode ptr
    declare sub      glfwSetGamma(monitor as GLFWmonitor ptr, gamma as single)
    declare function glfwGetGammaRamp(monitor as GLFWmonitor ptr) as  const GLFWgammaramp ptr
    declare sub      glfwSetGammaRamp(monitor as GLFWmonitor ptr,ramp as const GLFWgammaramp ptr)

    declare sub      glfwDefaultWindowHints()
    declare sub      glfwWindowHint(target as integer, hint as integer)

    declare function glfwCreateWindow(width as integer, height as integer, title as const zstring ptr, monitor as GLFWmonitor ptr, share as GLFWwindow ptr) as GLFWwindow ptr
    declare sub      glfwDestroyWindow(win as GLFWwindow ptr)

    declare function glfwWindowShouldClose(win as GLFWwindow ptr) as integer
    declare sub      glfwSetWindowShouldClose(win as GLFWwindow ptr,value as integer)

    declare sub      glfwSetWindowTitle(win as GLFWwindow ptr,title as const zstring ptr)

    declare sub      glfwGetWindowPos(win as GLFWwindow ptr,byref xpos as integer,byref ypos as integer)
    declare sub      glfwSetWindowPos(win as GLFWwindow ptr, xpos as integer, ypos as integer)

    declare sub      glfwGetWindowSize(win as GLFWwindow ptr,byref width as integer,byref height as integer)
    declare sub      glfwSetWindowSize(win as GLFWwindow ptr, width as integer, height as integer)

    declare sub      glfwGetFramebufferSize(win as GLFWwindow ptr,byref width as integer,byref height as integer)

    declare sub      glfwIconifyWindow(win as GLFWwindow ptr)

    declare sub      glfwRestoreWindow(win as GLFWwindow ptr)

    declare sub      glfwShowWindow(win as GLFWwindow ptr)
    declare sub      glfwHideWindow(win as GLFWwindow ptr)

    declare function glfwGetWindowMonitor(win as GLFWwindow ptr) as GLFWmonitor ptr

    declare function glfwGetWindowAttrib(win as GLFWwindow ptr, attrib as integer) as integer
    ' user data
    declare sub      glfwSetWindowUserPointer(win as GLFWwindow ptr, pUser as any ptr)
    declare function glfwGetWindowUserPointer(win as GLFWwindow ptr) as any ptr

    ' window callback's
    declare function glfwSetWindowPosCallback      (win as GLFWwindow ptr, cbfun as GLFWwindowposfun)       as GLFWwindowposfun
    declare function glfwSetWindowSizeCallback     (win as GLFWwindow ptr, cbfun as GLFWwindowsizefun)      as GLFWwindowsizefun
    declare function glfwSetWindowCloseCallback    (win as GLFWwindow ptr, cbfun as GLFWwindowclosefun)     as GLFWwindowclosefun
    declare function glfwSetWindowRefreshCallback  (win as GLFWwindow ptr, cbfun as GLFWwindowrefreshfun)   as GLFWwindowrefreshfun
    declare function glfwSetWindowFocusCallback    (win as GLFWwindow ptr, cbfun as GLFWwindowfocusfun)     as GLFWwindowfocusfun
    declare function glfwSetWindowIconifyCallback  (win as GLFWwindow ptr, cbfun as GLFWwindowiconifyfun)   as GLFWwindowiconifyfun
    declare function glfwSetFramebufferSizeCallback(win as GLFWwindow ptr, cbfun as GLFWframebuffersizefun) as GLFWframebuffersizefun

    ' event
    declare sub      glfwPollEvents()
    declare sub      glfwWaitEvents()

    declare function glfwGetInputMode(win as GLFWwindow ptr, mode as integer) as integer

    declare sub      glfwSetInputMode(win as GLFWwindow ptr, mode as integer, value as integer)

    declare function glfwGetKey(win as GLFWwindow ptr, key as integer) as integer

    declare function glfwGetMouseButton(win as GLFWwindow ptr, button as integer) as integer

    declare sub      glfwGetCursorPos(win as GLFWwindow ptr, byref xpos as double, byref ypos as double)

    declare sub      glfwSetCursorPos(win as GLFWwindow ptr, xpos as double, ypos as double)

    declare function glfwSetKeyCallback(win as GLFWwindow ptr, cbfunb as GLFWkeyfun) as GLFWkeyfun

    declare function glfwSetCharCallback(win as GLFWwindow ptr, cbfun as GLFWcharfun) as GLFWcharfun

    declare function glfwSetMouseButtonCallback(win as GLFWwindow ptr, cbfun as GLFWmousebuttonfun) as GLFWmousebuttonfun

    declare function glfwSetCursorPosCallback(win as GLFWwindow ptr, cbfun as GLFWcursorposfun) as GLFWcursorposfun

    declare function glfwSetCursorEnterCallback(win as GLFWwindow ptr, cbfun as GLFWcursorenterfun) as GLFWcursorenterfun

    declare function glfwSetScrollCallback(win as GLFWwindow ptr,cbfun as GLFWscrollfun) as GLFWscrollfun

    declare function glfwJoystickPresent(joy as integer) as integer
    declare function glfwGetJoystickAxes(joy as integer, byref count as integer) as const single ptr
    declare function glfwGetJoystickButtons(joy as integer, byref count as integer) as const ubyte ptr
    declare function glfwGetJoystickName(joy as integer) as const zstring ptr

    declare sub      glfwSetClipboardString(win as GLFWwindow ptr, string_ as const zstring ptr)
    declare function glfwGetClipboardString(win as GLFWwindow ptr) as const zstring ptr

    declare function glfwGetTime() as double
    declare sub      glfwSetTime(time_ as double)

    declare sub      glfwMakeContextCurrent(win as GLFWwindow ptr)

    declare function glfwGetCurrentContext() as GLFWwindow ptr

    declare sub      glfwSwapBuffers(win as GLFWwindow ptr)

    declare sub      glfwSwapInterval(interval as integer)

    declare function glfwExtensionSupported(extension as const zstring ptr) as integer

    declare function glfwGetProcAddress(procname as const zstring ptr) as any ptr

    end extern

    #endif /' _glfw3_bi_ '/