    #ifndef TW_INCLUDED
    #define TW_INCLUDED

    #inclib "AntTweakBar"

    '  ----------------------------------------------------------------------------
    '
    '   @file       AntTweakBar.h
    '
    '   @brief      AntTweakBar is a light and intuitive graphical user interface
    '               that can be readily integrated into OpenGL and DirectX
    '               applications in order to interactively tweak parameters.
    '
    '   @author     Philippe Decaudin
    '
    '   @doc        http:' anttweakbar.sourceforge.net/doc
    '
    '   @license    This file is part of the AntTweakBar library.
    '               AntTweakBar is a free software released under the zlib license.
    '               For conditions of distribution and use, see License.txt
    '
    '  ----------------------------------------------------------------------------
    #define TW_VERSION  116 '  Version Mmm : M=Major mm=minor (e.g., 102 is version 1.02)
    '  ----------------------------------------------------------------------------
    '   OS specific definitions
    '  ----------------------------------------------------------------------------
    #define TW_CALL stdcall
    #define TW_CDECL_CALL cdecl
    #define TW_EXPORT_API
    #define TW_IMPORT_API
    #define TW_GLUT_CALL TW_CDECL_CALL

    type TwSetVarCallback       as sub TW_CALL (value as const any ptr, clientData as any ptr)
    type TwGetVarCallback       as sub TW_CALL (value as any ptr, clientData as any ptr)
    type TwButtonCallback       as sub TW_CALL (clientData as any ptr)
    type TwSummaryCallback      as sub TW_CALL (summaryString as zstring ptr, summaryMaxLength as integer,value as const any ptr, clientData as any ptr)
    type TwCopyCDStringToClient as sub TW_CALL (destinationClientStringPtr as zstring ptr ptr, sourceString as const zstring ptr)

    type TwErrorHandler         as sub TW_CALL (errorMessage as const zstring ptr)

    type GLUTmousebuttonfun     as sub TW_GLUT_CALL (glutButton as integer, glutState as integer, mouseX as integer, mouseY as integer)
    type GLUTmousemotionfun     as sub TW_GLUT_CALL (mouseX as integer, mouseY as integer)
    type GLUTkeyboardfun        as sub TW_GLUT_CALL (glutKey as ubyte, mouseX as integer, mouseY as integer)
    type GLUTspecialfun         as sub TW_GLUT_CALL (glutKey as integer, mouseX as integer, mouseY as integer)
    type GLUTGetModifiersFunc   as function TW_CALL () as integer

    '  ----------------------------------------------------------------------------
    '   Var functions and definitions
    '  ----------------------------------------------------------------------------
    enum TwType
        TW_TYPE_UNDEF   = 0
        TW_TYPE_BOOL8   = 2
        TW_TYPE_BOOL16
        TW_TYPE_BOOL32
        TW_TYPE_CHAR
        TW_TYPE_INT8
        TW_TYPE_UINT8
        TW_TYPE_INT16
        TW_TYPE_UINT16
        TW_TYPE_INT32
        TW_TYPE_UINT32
        TW_TYPE_FLOAT
        TW_TYPE_DOUBLE
        TW_TYPE_COLOR32    '  32 bits color. Order is RGBA if API is OpenGL or Direct3D10, and inversed if API is Direct3D9 (can be modified by defining 'colorOrder=...', see doc)
        TW_TYPE_COLOR3F    '  3 floats color. Order is RGB.
        TW_TYPE_COLOR4F    '  4 floats color. Order is RGBA.
        TW_TYPE_CDSTRING   '  Null-terminated C Dynamic String (pointer to an array of char dynamically allocated with malloc/realloc/strdup)
        TW_TYPE_PLACEHOLDER1
        TW_TYPE_PLACEHOLDER2
        TW_TYPE_QUAT4F     '  4 floats encoding a quaternion {qx,qy,qz,qs}
        TW_TYPE_QUAT4D     '  4 doubles encoding a quaternion {qx,qy,qz,qs}
        TW_TYPE_DIR3F      '  direction vector represented by 3 floats
        TW_TYPE_DIR3D      '  direction vector represented by 3 doubles
    end enum

    #define TW_TYPE_CSSTRING(n) cast(as TwType,(&H30000000 +((n) and &Hfffffff))) '  Null-terminated C Static String of size n (defined as char[n], with n<2^28)

    type TwEnumVal
      as integer Value
      as const zstring ptr  Label
    end type

    type TwStructMember
      as const zstring ptr Name
      as TwType            Type
      as integer           Offset
      as const zstring ptr DefString
    end type

    enum TwParamValueType
      TW_PARAM_INT32
      TW_PARAM_FLOAT
      TW_PARAM_DOUBLE
      TW_PARAM_CSTRING '  Null-terminated array of char (ie, c-string)
    end enum
    '  ----------------------------------------------------------------------------
    '   Management functions and definitions
    '  ----------------------------------------------------------------------------
    enum TwGraphAPI
      TW_OPENGL = 1
      TW_DIRECT3D9
      TW_DIRECT3D10
      TW_DIRECT3D11
      TW_OPENGL_CORE
    end enum

    enum TwKeyModifier
      TW_KMOD_NONE        = &H0000  '  same codes as SDL keysym.mod
      TW_KMOD_SHIFT       = &H0003
      TW_KMOD_CTRL        = &H00c0
      TW_KMOD_ALT         = &H0100
      TW_KMOD_META        = &H0c00
    end enum

    enum TwKeySpecial
      TW_KEY_BACKSPACE    = asc(!"\b")
      TW_KEY_TAB          = asc(!"\t")
      TW_KEY_CLEAR        = &H0c
      TW_KEY_RETURN       = asc(!"\r")
      TW_KEY_PAUSE        = &H13
      TW_KEY_ESCAPE       = &H1b
      TW_KEY_SPACE        = asc(" ")
      TW_KEY_DELETE       = &H7f
      TW_KEY_UP           = 273 ' same codes and order as SDL 1.2 keysym.sym
      TW_KEY_DOWN         = 274
      TW_KEY_RIGHT        = 275
      TW_KEY_LEFT         = 276
      TW_KEY_INSERT       = 277
      TW_KEY_HOME         = 278
      TW_KEY_END          = 279
      TW_KEY_PAGE_UP      = 280
      TW_KEY_PAGE_DOWN    = 281
      TW_KEY_F1           = 282
      TW_KEY_F2
      TW_KEY_F3
      TW_KEY_F4
      TW_KEY_F5
      TW_KEY_F6
      TW_KEY_F7
      TW_KEY_F8
      TW_KEY_F9
      TW_KEY_F10
      TW_KEY_F11
      TW_KEY_F12
      TW_KEY_F13
      TW_KEY_F14
      TW_KEY_F15
      TW_KEY_LAST
    end enum

    enum TwMouseAction
      TW_MOUSE_RELEASED = 0
      TW_MOUSE_PRESSED
    end enum

    enum TwMouseButtonID
      TW_MOUSE_LEFT       = 1 '  same code as SDL_BUTTON_LEFT
      TW_MOUSE_MIDDLE     = 2 '  same code as SDL_BUTTON_MIDDLE
      TW_MOUSE_RIGHT      = 3 '  same code as SDL_BUTTON_RIGHT
    end enum

    type TwBar as any

    '  ----------------------------------------------------------------------------
    '   Bar functions and definitions
    '  ----------------------------------------------------------------------------
    declare function TwNewBar                   alias "_TwNewBar" (barName as const zstring ptr) as TwBar ptr
    declare function TwDeleteBar                alias "_TwDeleteBar" (bar as TwBar ptr) as integer
    declare function TwDeleteAllBars            alias "_TwDeleteAllBars" () as integer
    declare function TwSetTopBar                alias "_TwSetTopBar" (bar as const TwBar ptr) as integer
    declare function TwGetTopBar                alias "_TwGetTopBar" () as TwBar ptr
    declare function TwSetBottomBar             alias "_TwSetBottomBar" (bar as const TwBar ptr) as integer
    declare function TwGetBottomBar             alias "_TwGetBottomBar" () as TwBar ptr
    declare function TwGetBarName               alias "_TwGetBarName" (bar as const TwBar ptr) as const zstring ptr
    declare function TwGetBarCount              alias "_TwGetBarCount" () as integer
    declare function TwGetBarByIndex            alias "_TwGetBarByIndex" (barIndex as integer) as TwBar ptr
    declare function TwGetBarByName             alias "_TwGetBarByName" (barName as const zstring ptr) as TwBar ptr
    declare function TwRefreshBar               alias "_TwRefreshBar" (bar as TwBar ptr) as integer

    declare function TwAddVarRW                 alias "_TwAddVarRW" ( _
      bar as TwBar ptr, name as const zstring ptr, type as TwType, var as any ptr, def as const zstring ptr) as integer
    declare function TwAddVarRO                 alias "_TwAddVarRO" ( _
      bar as TwBar ptr, name as const zstring ptr, type as TwType, var as const any ptr, def as const zstring ptr) as integer
    declare function TwAddVarCB                 alias "_TwAddVarCB" ( _
      bar as TwBar ptr, name as const zstring ptr, type as TwType, _
      setCallback as TwSetVarCallback, getCallback as TwGetVarCallback, _
      clientData as any ptr, def as const zstring ptr) as integer
    declare function TwAddButton                alias "_TwAddButton" ( _
      bar as TwBar ptr, name as const zstring ptr, _
      callback as TwButtonCallback , clientData as any ptr, def as const zstring ptr) as integer
    declare function TwAddSeparator             alias "_TwAddSeparator" ( _
      bar as TwBar ptr, name as const zstring ptr, def as const zstring ptr) as integer
    declare function TwRemoveVar                alias "_TwRemoveVar" ( _
      bar as TwBar ptr, name as const zstring ptr) as integer
    declare function TwRemoveAllVars            alias "_TwRemoveAllVars" ( _
      bar as TwBar ptr) as integer

    declare function TwDefine                   alias "_TwDefine" (def as const zstring ptr) as integer
    declare function TwDefineEnum               alias "_TwDefineEnum" (name as const zstring ptr, enumValues as const TwEnumVal ptr, nbValues as uinteger) as TwType
    declare function TwDefineEnumFromString     alias "_TwDefineEnumFromString" (name as const zstring ptr, enumString as const zstring ptr) as TwType
    declare function TwDefineStruct             alias "_TwDefineStruct" (name as const zstring ptr, structMembers as const TwStructMember ptr, nbMembers as uinteger, structSize as integer, summaryCallback as TwSummaryCallback , summaryClientData as any ptr) as TwType

    declare sub      TwCopyCDStringToClientFunc alias "_TwCopyCDStringToClientFunc" (copyCDStringFunc as TwCopyCDStringToClient)
    declare sub      TwCopyCDStringToLibrary    alias "_TwCopyCDStringToLibrary"  (destinationLibraryStringPtr as zstring ptr ptr, sourceClientString as const zstring ptr)

    declare function TwGetParam                 alias "_TwGetParam"(bar as TwBar ptr, varName as const zstring ptr, paramName as const zstring ptr, paramValueType as TwParamValueType, outValueMaxCount as uinteger, outValues as any ptr) as integer
    declare function TwSetParam                 alias "_TwSetParam"(bar as TwBar ptr, varName as const zstring ptr, paramName as const zstring ptr, paramValueType as TwParamValueType, inValueCount as uinteger, inValues as const any ptr) as integer

    declare function TwInit                     alias "_TwInit" (graphAPI as TwGraphAPI, device as any ptr) as integer
    declare function TwTerminate                alias "_TwTerminate" () as integer

    declare function TwDraw                     alias "_TwDraw" () as integer
    declare function TwWindowSize               alias "_TwWindowSize"  (width as integer, height as integer) as integer

    declare function TwSetCurrentWindow         alias "_TwSetCurrentWindow" (windowID as integer) as integer '  multi-windows support
    declare function TwGetCurrentWindow         alias "_TwGetCurrentWindow" () as integer
    declare function TwWindowExists             alias "_TwWindowExists" (windowID as integer) as integer

    declare function TwKeyPressed               alias "_TwKeyPressed" (key as integer, modifiers as integer) as integer
    declare function TwKeyTest                  alias "_TwKeyTest"    (key as integer, modifiers as integer) as integer

    declare function TwMouseButton              alias "_TwMouseButton" (action as TwMouseAction, button as TwMouseButtonID) as integer
    declare function TwMouseMotion              alias "_TwMouseMotion" (mouseX as integer, mouseY as integer) as integer
    declare function TwMouseWheel               alias "_TwMouseWheel" (pos as integer) as integer

    declare function TwGetLastError             alias "_TwGetLastError" () as const zstring ptr
    declare sub      TwHandleErrors             alias "_TwHandleErrors" (errorHandler as TwErrorHandler)


    '  ----------------------------------------------------------------------------
    '   Helper functions to translate events from some common window management
    '   frameworks to AntTweakBar.
    '   They call TwKeyPressed, TwMouse* and TwWindowSize for you (implemented in
    '   files TwEventWin.c TwEventSDL*.c TwEventGLFW.c TwEventGLUT.c)
    '  ----------------------------------------------------------------------------

    '  For Windows message proc
    declare function TwEventWin alias "_TwEventWin" (wnd as any ptr, msg as uinteger, wParam as uinteger, lParam as integer) as integer

    '  For libSDL event loop
    declare function TwEventSDL alias "_TwEventSDL" (sdlEvent as const any ptr, sdlMajorVersion as ubyte, sdlMinorVersion as ubyte) as integer

    '  For GLFW event callbacks
    '  You should define GLFW_CDECL before including AntTweakBar.h if your version of GLFW uses cdecl calling convensions
    #ifdef GLFW_CDECL
    declare function TwEventMouseButtonGLFWcdecl TW_CDECL_CALL (glfwButton as integer, glfwAction as integer) as integer
    declare function TwEventKeyGLFWcdecl         TW_CDECL_CALL (glfwKey as integer, glfwAction as integer) as integer
    declare function TwEventCharGLFWcdecl        TW_CDECL_CALL (glfwChar as integer, glfwAction as integer) as integer
    declare function TwEventMousePosGLFWcdecl    TW_CDECL_CALL (mouseX as integer, mouseY as integer) as integer
    declare function TwEventMouseWheelGLFWcdecl  TW_CDECL_CALL (wheelPos as integer) as integer
    #define TwEventMouseButtonGLFW TwEventMouseButtonGLFWcdecl
    #define TwEventKeyGLFW         TwEventKeyGLFWcdecl
    #define TwEventCharGLFW        TwEventCharGLFWcdecl
    #define TwEventMousePosGLFW    TwEventMousePosGLFWcdecl
    #define TwEventMouseWheelGLFW  TwEventMouseWheelGLFWcdecl
    #else
    declare function TwEventMouseButtonGLFW alias "_TwEventMouseButtonGLFW" (glfwButton as integer, glfwAction as integer) as integer
    declare function TwEventKeyGLFW alias "_TwEventKeyGLFW" (glfwKey as integer, glfwAction as integer) as integer
    declare function TwEventCharGLFW alias "_TwEventCharGLFW" (glfwChar as integer, glfwAction as integer) as integer
    #define TwEventMousePosGLFW     TwMouseMotion
    #define TwEventMouseWheelGLFW   TwMouseWheel
    #endif

    declare function TwEventMouseButtonGLUT TW_GLUT_CALL  alias "TwEventMouseButtonGLUT"(glutButton as integer, glutState as integer, mouseX as integer, mouseY as integer) as integer
    declare function TwEventMouseMotionGLUT TW_GLUT_CALL  alias "TwEventMouseMotionGLUT"(mouseX as integer, mouseY as integer) as integer
    declare function TwEventKeyboardGLUT    TW_GLUT_CALL  alias "TwEventKeyboardGLUT"(glutKey as ubyte, mouseX as integer, mouseY as integer) as integer
    declare function TwEventSpecialGLUT     TW_GLUT_CALL  alias "TwEventSpecialGLUT"(glutKey as integer, mouseX as integer, mouseY as integer) as integer

    declare function TwGLUTModifiersFunc alias "_TwGLUTModifiersFunc" (cb as glutGetModifiersFunc) as integer

    '  For SFML event loop
    declare function TwEventSFML alias "_TwEventSFML" (sfmlEvent as any ptr, sfmlMajorVersion as ubyte, sfmlMinorVersion as ubyte) as integer

    #endif  '  !defined TW_INCLUDED