--=========== Copyright © 2020, Planimeter, All rights reserved. ===========--
--
-- Purpose:
--
--==========================================================================--

local ffi = require( "ffi" )
io.input( framework.execdir .. "include/ilut.h" )
ffi.cdef( io.read( "*all" ) )

local IL = ffi.load( ffi.os == "Windows" and "DevIL" or "ILUT" )
local _M = {
	CLAMP_HALF		= 1,
	CLAMP_FLOATS	= 1,
	CLAMP_DOUBLES	= 1,
	IL_FALSE			= 0,
	IL_TRUE				= 1,
	IL_COLOUR_INDEX     = 0x1900,
	IL_COLOR_INDEX      = 0x1900,
	IL_ALPHA			= 0x1906,
	IL_RGB              = 0x1907,
	IL_RGBA             = 0x1908,
	IL_BGR              = 0x80E0,
	IL_BGRA             = 0x80E1,
	IL_LUMINANCE        = 0x1909,
	IL_LUMINANCE_ALPHA  = 0x190A,
	IL_BYTE           = 0x1400,
	IL_UNSIGNED_BYTE  = 0x1401,
	IL_SHORT          = 0x1402,
	IL_UNSIGNED_SHORT = 0x1403,
	IL_INT            = 0x1404,
	IL_UNSIGNED_INT   = 0x1405,
	IL_FLOAT          = 0x1406,
	IL_DOUBLE         = 0x140A,
	IL_HALF           = 0x140B,
	IL_VENDOR   = 0x1F00,
	IL_LOAD_EXT = 0x1F01,
	IL_SAVE_EXT = 0x1F02,
	-- IL-specific #define's
	IL_VERSION_1_8_0 = 1,
	IL_VERSION       = 180,
	IL_ORIGIN_BIT          = 0x00000001,
	IL_FILE_BIT            = 0x00000002,
	IL_PAL_BIT             = 0x00000004,
	IL_FORMAT_BIT          = 0x00000008,
	IL_TYPE_BIT            = 0x00000010,
	IL_COMPRESS_BIT        = 0x00000020,
	IL_LOADFAIL_BIT        = 0x00000040,
	IL_FORMAT_SPECIFIC_BIT = 0x00000080,
	IL_ALL_ATTRIB_BITS     = 0x000FFFFF,
	IL_PAL_NONE   = 0x0400,
	IL_PAL_RGB24  = 0x0401,
	IL_PAL_RGB32  = 0x0402,
	IL_PAL_RGBA32 = 0x0403,
	IL_PAL_BGR24  = 0x0404,
	IL_PAL_BGR32  = 0x0405,
	IL_PAL_BGRA32 = 0x0406,
	IL_TYPE_UNKNOWN = 0x0000,
	IL_BMP          = 0x0420,  --!< Microsoft Windows Bitmap - .bmp extension
	IL_CUT          = 0x0421,  --!< Dr. Halo - .cut extension
	IL_DOOM         = 0x0422,  --!< DooM walls - no specific extension
	IL_DOOM_FLAT    = 0x0423,  --!< DooM flats - no specific extension
	IL_ICO          = 0x0424,  --!< Microsoft Windows Icons and Cursors - .ico and .cur extensions
	IL_JPG          = 0x0425,  --!< JPEG - .jpg, .jpe and .jpeg extensions
	IL_JFIF         = 0x0425,  --!<
	IL_ILBM         = 0x0426,  --!< Amiga IFF (FORM ILBM) - .iff, .ilbm, .lbm extensions
	IL_PCD          = 0x0427,  --!< Kodak PhotoCD - .pcd extension
	IL_PCX          = 0x0428,  --!< ZSoft PCX - .pcx extension
	IL_PIC          = 0x0429,  --!< PIC - .pic extension
	IL_PNG          = 0x042A,  --!< Portable Network Graphics - .png extension
	IL_PNM          = 0x042B,  --!< Portable Any Map - .pbm, .pgm, .ppm and .pnm extensions
	IL_SGI          = 0x042C,  --!< Silicon Graphics - .sgi, .bw, .rgb and .rgba extensions
	IL_TGA          = 0x042D,  --!< TrueVision Targa File - .tga, .vda, .icb and .vst extensions
	IL_TIF          = 0x042E,  --!< Tagged Image File Format - .tif and .tiff extensions
	IL_CHEAD        = 0x042F,  --!< C-Style Header - .h extension
	IL_RAW          = 0x0430,  --!< Raw Image Data - any extension
	IL_MDL          = 0x0431,  --!< Half-Life Model Texture - .mdl extension
	IL_WAL          = 0x0432,  --!< Quake 2 Texture - .wal extension
	IL_LIF          = 0x0434,  --!< Homeworld Texture - .lif extension
	IL_MNG          = 0x0435,  --!< Multiple-image Network Graphics - .mng extension
	IL_JNG          = 0x0435,  --!<
	IL_GIF          = 0x0436,  --!< Graphics Interchange Format - .gif extension
	IL_DDS          = 0x0437,  --!< DirectDraw Surface - .dds extension
	IL_DCX          = 0x0438,  --!< ZSoft Multi-PCX - .dcx extension
	IL_PSD          = 0x0439,  --!< Adobe PhotoShop - .psd extension
	IL_EXIF         = 0x043A,  --!<
	IL_PSP          = 0x043B,  --!< PaintShop Pro - .psp extension
	IL_PIX          = 0x043C,  --!< PIX - .pix extension
	IL_PXR          = 0x043D,  --!< Pixar - .pxr extension
	IL_XPM          = 0x043E,  --!< X Pixel Map - .xpm extension
	IL_HDR          = 0x043F,  --!< Radiance High Dynamic Range - .hdr extension
	IL_ICNS			= 0x0440,  --!< Macintosh Icon - .icns extension
	IL_JP2			= 0x0441,  --!< Jpeg 2000 - .jp2 extension
	IL_EXR			= 0x0442,  --!< OpenEXR - .exr extension
	IL_WDP			= 0x0443,  --!< Microsoft HD Photo - .wdp and .hdp extension
	IL_VTF			= 0x0444,  --!< Valve Texture Format - .vtf extension
	IL_WBMP			= 0x0445,  --!< Wireless Bitmap - .wbmp extension
	IL_SUN			= 0x0446,  --!< Sun Raster - .sun, .ras, .rs, .im1, .im8, .im24 and .im32 extensions
	IL_IFF			= 0x0447,  --!< Interchange File Format - .iff extension
	IL_TPL			= 0x0448,  --!< Gamecube Texture - .tpl extension
	IL_FITS			= 0x0449,  --!< Flexible Image Transport System - .fit and .fits extensions
	IL_DICOM		= 0x044A,  --!< Digital Imaging and Communications in Medicine (DICOM) - .dcm and .dicom extensions
	IL_IWI			= 0x044B,  --!< Call of Duty Infinity Ward Image - .iwi extension
	IL_BLP			= 0x044C,  --!< Blizzard Texture Format - .blp extension
	IL_FTX			= 0x044D,  --!< Heavy Metal: FAKK2 Texture - .ftx extension
	IL_ROT			= 0x044E,  --!< Homeworld 2 - Relic Texture - .rot extension
	IL_TEXTURE		= 0x044F,  --!< Medieval II: Total War Texture - .texture extension
	IL_DPX			= 0x0450,  --!< Digital Picture Exchange - .dpx extension
	IL_UTX			= 0x0451,  --!< Unreal (and Unreal Tournament) Texture - .utx extension
	IL_MP3			= 0x0452,  --!< MPEG-1 Audio Layer 3 - .mp3 extension
	IL_KTX			= 0x0453,  --!< Khronos Texture - .ktx extension
	IL_JASC_PAL     = 0x0475,  --!< PaintShop Pro Palette
	IL_NO_ERROR             = 0x0000,
	IL_INVALID_ENUM         = 0x0501,
	IL_OUT_OF_MEMORY        = 0x0502,
	IL_FORMAT_NOT_SUPPORTED = 0x0503,
	IL_INTERNAL_ERROR       = 0x0504,
	IL_INVALID_VALUE        = 0x0505,
	IL_ILLEGAL_OPERATION    = 0x0506,
	IL_ILLEGAL_FILE_VALUE   = 0x0507,
	IL_INVALID_FILE_HEADER  = 0x0508,
	IL_INVALID_PARAM        = 0x0509,
	IL_COULD_NOT_OPEN_FILE  = 0x050A,
	IL_INVALID_EXTENSION    = 0x050B,
	IL_FILE_ALREADY_EXISTS  = 0x050C,
	IL_OUT_FORMAT_SAME      = 0x050D,
	IL_STACK_OVERFLOW       = 0x050E,
	IL_STACK_UNDERFLOW      = 0x050F,
	IL_INVALID_CONVERSION   = 0x0510,
	IL_BAD_DIMENSIONS       = 0x0511,
	IL_FILE_READ_ERROR      = 0x0512,  -- 05/12/2002: Addition by Sam.
	IL_FILE_WRITE_ERROR     = 0x0512,
	IL_LIB_GIF_ERROR  = 0x05E1,
	IL_LIB_JPEG_ERROR = 0x05E2,
	IL_LIB_PNG_ERROR  = 0x05E3,
	IL_LIB_TIFF_ERROR = 0x05E4,
	IL_LIB_MNG_ERROR  = 0x05E5,
	IL_LIB_JP2_ERROR  = 0x05E6,
	IL_LIB_EXR_ERROR  = 0x05E7,
	IL_UNKNOWN_ERROR  = 0x05FF,
	IL_ORIGIN_SET        = 0x0600,
	IL_ORIGIN_LOWER_LEFT = 0x0601,
	IL_ORIGIN_UPPER_LEFT = 0x0602,
	IL_ORIGIN_MODE       = 0x0603,
	IL_FORMAT_SET  = 0x0610,
	IL_FORMAT_MODE = 0x0611,
	IL_TYPE_SET    = 0x0612,
	IL_TYPE_MODE   = 0x0613,
	IL_FILE_OVERWRITE	= 0x0620,
	IL_FILE_MODE		= 0x0621,
	IL_CONV_PAL			= 0x0630,
	IL_DEFAULT_ON_FAIL	= 0x0632,
	IL_USE_KEY_COLOUR	= 0x0635,
	IL_USE_KEY_COLOR	= 0x0635,
	IL_BLIT_BLEND		= 0x0636,
	IL_SAVE_INTERLACED	= 0x0639,
	IL_INTERLACE_MODE	= 0x063A,
	IL_QUANTIZATION_MODE = 0x0640,
	IL_WU_QUANT          = 0x0641,
	IL_NEU_QUANT         = 0x0642,
	IL_NEU_QUANT_SAMPLE  = 0x0643,
	IL_MAX_QUANT_INDEXS  = 0x0644, --XIX : ILint : Maximum number of colors to reduce to, default of 256. and has a range of 2-256
	IL_MAX_QUANT_INDICES = 0x0644, -- Redefined, since the above #define is misspelled
	IL_FASTEST          = 0x0660,
	IL_LESS_MEM         = 0x0661,
	IL_DONT_CARE        = 0x0662,
	IL_MEM_SPEED_HINT   = 0x0665,
	IL_USE_COMPRESSION  = 0x0666,
	IL_NO_COMPRESSION   = 0x0667,
	IL_COMPRESSION_HINT = 0x0668,
	IL_NVIDIA_COMPRESS	= 0x0670,
	IL_SQUISH_COMPRESS	= 0x0671,
	IL_SUB_NEXT   = 0x0680,
	IL_SUB_MIPMAP = 0x0681,
	IL_SUB_LAYER  = 0x0682,
	IL_COMPRESS_MODE = 0x0700,
	IL_COMPRESS_NONE = 0x0701,
	IL_COMPRESS_RLE  = 0x0702,
	IL_COMPRESS_LZO  = 0x0703,
	IL_COMPRESS_ZLIB = 0x0704,
	IL_TGA_CREATE_STAMP        = 0x0710,
	IL_JPG_QUALITY             = 0x0711,
	IL_PNG_INTERLACE           = 0x0712,
	IL_TGA_RLE                 = 0x0713,
	IL_BMP_RLE                 = 0x0714,
	IL_SGI_RLE                 = 0x0715,
	IL_TGA_ID_STRING           = 0x0717,
	IL_TGA_AUTHNAME_STRING     = 0x0718,
	IL_TGA_AUTHCOMMENT_STRING  = 0x0719,
	IL_PNG_AUTHNAME_STRING     = 0x071A,
	IL_PNG_TITLE_STRING        = 0x071B,
	IL_PNG_DESCRIPTION_STRING  = 0x071C,
	IL_TIF_DESCRIPTION_STRING  = 0x071D,
	IL_TIF_HOSTCOMPUTER_STRING = 0x071E,
	IL_TIF_DOCUMENTNAME_STRING = 0x071F,
	IL_TIF_AUTHNAME_STRING     = 0x0720,
	IL_JPG_SAVE_FORMAT         = 0x0721,
	IL_CHEAD_HEADER_STRING     = 0x0722,
	IL_PCD_PICNUM              = 0x0723,
	IL_PNG_ALPHA_INDEX = 0x0724, -- currently has no effect!
	IL_JPG_PROGRESSIVE         = 0x0725,
	IL_VTF_COMP                = 0x0726,
	IL_DXTC_FORMAT      = 0x0705,
	IL_DXT1             = 0x0706,
	IL_DXT2             = 0x0707,
	IL_DXT3             = 0x0708,
	IL_DXT4             = 0x0709,
	IL_DXT5             = 0x070A,
	IL_DXT_NO_COMP      = 0x070B,
	IL_KEEP_DXTC_DATA   = 0x070C,
	IL_DXTC_DATA_FORMAT = 0x070D,
	IL_3DC              = 0x070E,
	IL_RXGB             = 0x070F,
	IL_ATI1N            = 0x0710,
	IL_DXT1A            = 0x0711,  -- Normally the same as IL_DXT1, except for nVidia Texture Tools.
	IL_CUBEMAP_POSITIVEX = 0x00000400,
	IL_CUBEMAP_NEGATIVEX = 0x00000800,
	IL_CUBEMAP_POSITIVEY = 0x00001000,
	IL_CUBEMAP_NEGATIVEY = 0x00002000,
	IL_CUBEMAP_POSITIVEZ = 0x00004000,
	IL_CUBEMAP_NEGATIVEZ = 0x00008000,
	IL_SPHEREMAP         = 0x00010000,
	IL_VERSION_NUM           = 0x0DE2,
	IL_IMAGE_WIDTH           = 0x0DE4,
	IL_IMAGE_HEIGHT          = 0x0DE5,
	IL_IMAGE_DEPTH           = 0x0DE6,
	IL_IMAGE_SIZE_OF_DATA    = 0x0DE7,
	IL_IMAGE_BPP             = 0x0DE8,
	IL_IMAGE_BYTES_PER_PIXEL = 0x0DE8,
	IL_IMAGE_BPP             = 0x0DE8,
	IL_IMAGE_BITS_PER_PIXEL  = 0x0DE9,
	IL_IMAGE_FORMAT          = 0x0DEA,
	IL_IMAGE_TYPE            = 0x0DEB,
	IL_PALETTE_TYPE          = 0x0DEC,
	IL_PALETTE_SIZE          = 0x0DED,
	IL_PALETTE_BPP           = 0x0DEE,
	IL_PALETTE_NUM_COLS      = 0x0DEF,
	IL_PALETTE_BASE_TYPE     = 0x0DF0,
	IL_NUM_FACES             = 0x0DE1,
	IL_NUM_IMAGES            = 0x0DF1,
	IL_NUM_MIPMAPS           = 0x0DF2,
	IL_NUM_LAYERS            = 0x0DF3,
	IL_ACTIVE_IMAGE          = 0x0DF4,
	IL_ACTIVE_MIPMAP         = 0x0DF5,
	IL_ACTIVE_LAYER          = 0x0DF6,
	IL_ACTIVE_FACE           = 0x0E00,
	IL_CUR_IMAGE             = 0x0DF7,
	IL_IMAGE_DURATION        = 0x0DF8,
	IL_IMAGE_PLANESIZE       = 0x0DF9,
	IL_IMAGE_BPC             = 0x0DFA,
	IL_IMAGE_OFFX            = 0x0DFB,
	IL_IMAGE_OFFY            = 0x0DFC,
	IL_IMAGE_CUBEFLAGS       = 0x0DFD,
	IL_IMAGE_ORIGIN          = 0x0DFE,
	IL_IMAGE_CHANNELS        = 0x0DFF,
	IL_SEEK_SET	= 0,
	IL_SEEK_CUR	= 1,
	IL_SEEK_END	= 2,
	IL_EOF		= -1,
	ILU_VERSION_1_8_0 = 1,
	ILU_VERSION       = 180,
	ILU_FILTER         = 0x2600,
	ILU_NEAREST        = 0x2601,
	ILU_LINEAR         = 0x2602,
	ILU_BILINEAR       = 0x2603,
	ILU_SCALE_BOX      = 0x2604,
	ILU_SCALE_TRIANGLE = 0x2605,
	ILU_SCALE_BELL     = 0x2606,
	ILU_SCALE_BSPLINE  = 0x2607,
	ILU_SCALE_LANCZOS3 = 0x2608,
	ILU_SCALE_MITCHELL = 0x2609,
	ILU_INVALID_ENUM      = 0x0501,
	ILU_OUT_OF_MEMORY     = 0x0502,
	ILU_INTERNAL_ERROR    = 0x0504,
	ILU_INVALID_VALUE     = 0x0505,
	ILU_ILLEGAL_OPERATION = 0x0506,
	ILU_INVALID_PARAM     = 0x0509,
	ILU_PLACEMENT          = 0x0700,
	ILU_LOWER_LEFT         = 0x0701,
	ILU_LOWER_RIGHT        = 0x0702,
	ILU_UPPER_LEFT         = 0x0703,
	ILU_UPPER_RIGHT        = 0x0704,
	ILU_CENTER             = 0x0705,
	ILU_CONVOLUTION_MATRIX = 0x0710,
	ILU_ENGLISH            = 0x0800,
	ILU_ARABIC             = 0x0801,
	ILU_DUTCH              = 0x0802,
	ILU_JAPANESE           = 0x0803,
	ILU_SPANISH            = 0x0804,
	ILU_GERMAN             = 0x0805,
	ILU_FRENCH             = 0x0806,
	ILU_ITALIAN            = 0x0807,
	ILU_FILTER_BLUR         = 0x0803,
	ILU_FILTER_GAUSSIAN_3x3 = 0x0804,
	ILU_FILTER_GAUSSIAN_5X5 = 0x0805,
	ILU_FILTER_EMBOSS1      = 0x0807,
	ILU_FILTER_EMBOSS2      = 0x0808,
	ILU_FILTER_LAPLACIAN1   = 0x080A,
	ILU_FILTER_LAPLACIAN2   = 0x080B,
	ILU_FILTER_LAPLACIAN3   = 0x080C,
	ILU_FILTER_LAPLACIAN4   = 0x080D,
	ILU_FILTER_SHARPEN1     = 0x080E,
	ILU_FILTER_SHARPEN2     = 0x080F,
	ILU_FILTER_SHARPEN3     = 0x0810,
	ILUT_VERSION_1_8_0 = 1,
	ILUT_VERSION       = 180,
	ILUT_OPENGL_BIT      = 0x00000001,
	ILUT_D3D_BIT         = 0x00000002,
	ILUT_ALL_ATTRIB_BITS = 0x000FFFFF,
	ILUT_INVALID_ENUM        = 0x0501,
	ILUT_OUT_OF_MEMORY       = 0x0502,
	ILUT_INVALID_VALUE       = 0x0505,
	ILUT_ILLEGAL_OPERATION   = 0x0506,
	ILUT_INVALID_PARAM       = 0x0509,
	ILUT_COULD_NOT_OPEN_FILE = 0x050A,
	ILUT_STACK_OVERFLOW      = 0x050E,
	ILUT_STACK_UNDERFLOW     = 0x050F,
	ILUT_BAD_DIMENSIONS      = 0x0511,
	ILUT_NOT_SUPPORTED       = 0x0550,
	ILUT_PALETTE_MODE         = 0x0600,
	ILUT_OPENGL_CONV          = 0x0610,
	ILUT_D3D_MIPLEVELS        = 0x0620,
	ILUT_MAXTEX_WIDTH         = 0x0630,
	ILUT_MAXTEX_HEIGHT        = 0x0631,
	ILUT_MAXTEX_DEPTH         = 0x0632,
	ILUT_GL_USE_S3TC          = 0x0634,
	ILUT_D3D_USE_DXTC         = 0x0634,
	ILUT_GL_GEN_S3TC          = 0x0635,
	ILUT_D3D_GEN_DXTC         = 0x0635,
	ILUT_S3TC_FORMAT          = 0x0705,
	ILUT_DXTC_FORMAT          = 0x0705,
	ILUT_D3D_POOL             = 0x0706,
	ILUT_D3D_ALPHA_KEY_COLOR  = 0x0707,
	ILUT_D3D_ALPHA_KEY_COLOUR = 0x0707,
	ILUT_FORCE_INTEGER_FORMAT = 0x0636,
	ILUT_GL_AUTODETECT_TEXTURE_TARGET = 0x0807,
	ILUT_OPENGL     = 0,
	ILUT_ALLEGRO    = 1,
	ILUT_WIN32      = 2,
	ILUT_DIRECT3D8  = 3,
	ILUT_DIRECT3D9  = 4,
	ILUT_X11        = 5,
	ILUT_DIRECT3D10 = 6
}
return setmetatable( _M, {
	__index = function( table, key )
		return IL[ key ]
	end
} )
