#pragma once
#define MX_PLATFORM_UNKNOWN            0
#define MX_PLATFORM_ANDROID            2
#define MX_PLATFORM_WINDOWS            3
#define MX_PLATFORM_LINUX				  4
#define MX_PLATFORM_CHROME             10
#define _MX_FORBIDDEN_IDINDEX

#ifdef _MX_WINDOWS
#define MX_TARGET_PLATFORM             MX_PLATFORM_WINDOWS
#define _MX_64
#define  MXWINDOWS
#ifndef _WINDOWS
#define _WINDOWS
#endif
#elif defined(_MX_BULIDLINUX_)
#define  MX_TARGET_PLATFORM             MX_PLATFORM_LINUX
#define  _MX_UNIX_KERNEL
#define  _MX_64
#define  MXLINUX
#elif defined(_MX_ANDROID)
#define MX_TARGET_PLATFORM         MX_PLATFORM_ANDROID
#define _MX_UNIX_KERNEL
#define  MXANDROID
#if defined (__arm64__) || defined (__aarch64__) || defined (__arm64) || defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__)
#define _MX_64
#else
#define _MX_32
#endif

#elif defined(_MX_BUILD_HM)
	#define MX_TARGET_PLATFORM         MX_PLATFORM_HM
	#define _MX_UNIX_KERNEL
	#define  MXHM
	#if defined (__arm64__) || defined (__aarch64__) || defined (__arm64) || defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__)
		#define _MX_64
	#else
		#define _MX_32
	#endif
#else
#error  "error targeting an unsupported platform"
#endif

#pragma warning(disable:4251)
#if (MX_TARGET_PLATFORM == MX_PLATFORM_WINDOWS)
// windows
#include <windows.h>
#include <assert.h>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <limits.h>   
#include <stdlib.h>
#include <math.h>
#include <memory>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <mutex>
#include <algorithm>

#include <stdio.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmath>
#elif (MX_TARGET_PLATFORM == MX_PLATFORM_LINUX)
#include <string.h>
#include <assert.h>
#include <float.h>
#include <math.h>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <list>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
#include <stdint.h>
#include <limits.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <sys/syscall.h>
#elif (MX_TARGET_PLATFORM == MX_PLATFORM_ANDROID)
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
#include <ctype.h>
#include <string>
#include <dlfcn.h>
#include <math.h>
#include <memory>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <mutex>
#include <thread>
#include <algorithm>
#include <sys/types.h>
#include <errno.h>
#include <dirent.h>
#include <ftw.h>

#include <stdio.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmath>
#include <android/log.h>

#define MX_SUPPORTED_OPENGL

#define	glClearDepth				glClearDepthf
#include <GLES3/gl3platform.h>

#ifndef GL_GLEXT_PROTOTYPES
#define GL_GLEXT_PROTOTYPES 1
#include <GLES3/gl31.h>
#include <GLES3/gl3ext.h>
#endif

typedef char GLchar;
#ifndef GL_BGRA
#define GL_BGRA  0x80E1
#endif


#define MX_NO_USE_GLAD

#elif (MX_TARGET_PLATFORM == MX_PLATFORM_HM)
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
#include <ctype.h>
#include <string>
#include <dlfcn.h>
#include <math.h>
#include <memory>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <mutex>
#include <thread>
#include <algorithm>
#include <sys/types.h>
#include <errno.h>
#include <dirent.h>
#include <ftw.h>

#include <stdio.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmath>


#define MX_SUPPORTED_OPENGL

#define	glClearDepth				glClearDepthf
#include <GLES3/gl3platform.h>

#ifndef GL_GLEXT_PROTOTYPES
#define GL_GLEXT_PROTOTYPES 1
#include <GLES3/gl31.h>
#endif

typedef char GLchar;
#ifndef GL_BGRA
#define GL_BGRA  0x80E1
#endif


#define MX_NO_USE_GLAD

#endif

typedef double         mxreal;
typedef float mxreal_p;
typedef unsigned char   byte;
typedef char            mxchar;
typedef bool            mxbool;

#if (MX_TARGET_PLATFORM == MX_PLATFORM_WINDOWS)

typedef signed int		mxint32;
typedef unsigned int	mxuint;
typedef unsigned int	mxuint32;
typedef INT16			mxint16;
typedef unsigned  short mxuint16;
typedef INT8			mxint8;
typedef UINT8			mxuint8;
typedef int				mxint;

typedef __int64			mxint64;

typedef unsigned long long  mxuint64;

typedef float			mxfloat;
typedef double         mxdouble;
typedef long           mxlong;

typedef void           mxvoid;
typedef unsigned int    mxsize;
typedef unsigned char  mxbyte;
typedef unsigned long       DWORD;

typedef  __int64       mxid;
typedef  __int64       MxObjectId;

#if defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__) || defined(LINUX_X64) || defined(_MX_64) 
typedef __int64       MxObjectIdDynSize;
#else
typedef mxint32       MxObjectIdDynSize;
#endif

#ifdef _MX_FORBIDDEN_IDINDEX
typedef  __int64       MxIdIndex;
#else
typedef  long       MxIdIndex;
#endif

#elif  (MX_TARGET_PLATFORM == MX_PLATFORM_ANDROID)
typedef signed int				mxint32;
typedef unsigned int			mxuint;
typedef unsigned int			mxuint32;
typedef signed short 			mxint16;
typedef unsigned  short 		mxuint16;
typedef signed char				mxint8;
typedef unsigned char			mxuint8;

typedef int						mxint;

typedef long long				mxint64;

typedef unsigned long long		mxuint64;

typedef long					mxlong;

typedef void					mxvoid;

typedef unsigned int			mxsize;


typedef float					mxfloat;
typedef double					mxdouble;
typedef unsigned char			mxbyte;


typedef unsigned int			COLORREF;

typedef long					LONG;


typedef int						INT;
typedef void*					HWND;
typedef unsigned int			UINT;
typedef long					WPARAM;
typedef long					LPARAM;
typedef unsigned int			DWORD;
typedef unsigned char			BYTE;
typedef BYTE*					LPBYTE;

typedef byte					BOOL;

typedef wchar_t					WCHAR;
typedef const WCHAR	*			LPCWSTR;
typedef char					CHAR;
typedef const CHAR *			LPCSTR;

typedef char					TCHAR;
typedef  const TCHAR *			LPCTSTR;
typedef  TCHAR *				LPTSTR;
typedef long long				LRESULT;

typedef size_t					SSIZE_T;

typedef long long  LONGLONG;
typedef unsigned long  ULONG;
typedef unsigned char  UCHAR;


#define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
typedef unsigned short WORD;

#define LOBYTE(w)           ((BYTE)(((DWORD)(w)) & 0xff))
#define HIBYTE(w)           ((BYTE)((((DWORD)(w)) >> 8) & 0xff))

#define GetRValue(rgb)      (LOBYTE(rgb))
#define GetGValue(rgb)      (LOBYTE(((WORD)(rgb)) >> 8))
#define GetBValue(rgb)      (LOBYTE((rgb)>>16))
#define FAILED(hr) (((long)(hr)) < 0)

#define IN
#define OUT

typedef void * HANDLE;

typedef  long long			mxid;
typedef  long long          MxObjectId;

#ifdef _MX_64
typedef long long      MxObjectIdDynSize;
#else
typedef mxint32       MxObjectIdDynSize;
#endif


#ifdef _MX_FORBIDDEN_IDINDEX
typedef  long long        MxIdIndex;
#else
typedef  long       MxIdIndex;
#endif


#elif  (MX_TARGET_PLATFORM == MX_PLATFORM_HM)
		typedef signed int				mxint32;
		typedef unsigned int			mxuint;
		typedef unsigned int			mxuint32;
		typedef signed short 			mxint16;
		typedef unsigned  short 		mxuint16;
		typedef signed char				mxint8;
		typedef unsigned char			mxuint8;

		typedef int						mxint;

		typedef long long				mxint64;

		typedef unsigned long long		mxuint64;

		typedef long					mxlong;

		typedef void					mxvoid;

		typedef unsigned int			mxsize;


		typedef float					mxfloat;
		typedef double					mxdouble;
		typedef unsigned char			mxbyte;


		typedef unsigned int			COLORREF;

		typedef long					LONG;


		typedef int						INT;
		typedef void*					HWND;
		typedef unsigned int			UINT;
		typedef long					WPARAM;
		typedef long					LPARAM;
		typedef unsigned int			DWORD;
		typedef unsigned char			BYTE;
		typedef BYTE*					LPBYTE;

		typedef byte					BOOL;

		typedef wchar_t					WCHAR;
		typedef const WCHAR	*			LPCWSTR;
		typedef char					CHAR;
		typedef const CHAR *			LPCSTR;

		typedef char					TCHAR;
		typedef  const TCHAR *			LPCTSTR;
		typedef  TCHAR *				LPTSTR;
		typedef long long				LRESULT;

		typedef size_t					SSIZE_T;

		typedef long long  LONGLONG;
		typedef unsigned long  ULONG;
		typedef unsigned char  UCHAR;


		#define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
		typedef unsigned short WORD;

		#define LOBYTE(w)           ((BYTE)(((DWORD)(w)) & 0xff))
		#define HIBYTE(w)           ((BYTE)((((DWORD)(w)) >> 8) & 0xff))

		#define GetRValue(rgb)      (LOBYTE(rgb))
		#define GetGValue(rgb)      (LOBYTE(((WORD)(rgb)) >> 8))
		#define GetBValue(rgb)      (LOBYTE((rgb)>>16))
		#define FAILED(hr) (((long)(hr)) < 0)

		#define IN
		#define OUT

		typedef void * HANDLE;

		typedef  long long			mxid;
		typedef  long long          MxObjectId;

		#ifdef _MX_64
		typedef long long      MxObjectIdDynSize;
		#else
		typedef mxint32       MxObjectIdDynSize;
		#endif


		#ifdef _MX_FORBIDDEN_IDINDEX
		typedef  long long        MxIdIndex;
		#else
		typedef  long       MxIdIndex;
		#endif

#elif  (MX_TARGET_PLATFORM == MX_PLATFORM_LINUX)

typedef signed int				mxint32;
typedef unsigned int			mxuint;
typedef unsigned int			mxuint32;
typedef signed short 			mxint16;
typedef unsigned  short 		mxuint16;
typedef signed char				mxint8;
typedef unsigned char			mxuint8;

typedef int						mxint;

typedef long long				mxint64;

typedef unsigned long long		mxuint64;

typedef long					mxlong;

typedef void					mxvoid;

typedef unsigned int			mxsize;


typedef float					mxfloat;
typedef double					mxdouble;
typedef unsigned char			mxbyte;

typedef unsigned int			COLORREF;

typedef long					LONG;


typedef int						INT;
typedef void* HWND;
typedef unsigned int			UINT;
typedef long					WPARAM;
typedef long					LPARAM;
typedef unsigned int			DWORD;
typedef unsigned char			BYTE;
typedef BYTE* LPBYTE;

typedef byte					BOOL;


#define _THROW0()

typedef wchar_t					WCHAR;
typedef const WCHAR* LPCWSTR;
typedef char					CHAR;
typedef const CHAR* LPCSTR;

typedef char					TCHAR;
typedef  const TCHAR* LPCTSTR;
typedef  TCHAR* LPTSTR;
typedef long long				LRESULT;

typedef size_t					SSIZE_T;

typedef long long  LONGLONG;
typedef unsigned long  ULONG;
typedef unsigned char  UCHAR;


#define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
typedef unsigned short WORD;

#define LOBYTE(w)           ((BYTE)(((DWORD)(w)) & 0xff))
#define HIBYTE(w)           ((BYTE)((((DWORD)(w)) >> 8) & 0xff))

#define GetRValue(rgb)      (LOBYTE(rgb))
#define GetGValue(rgb)      (LOBYTE(((WORD)(rgb)) >> 8))
#define GetBValue(rgb)      (LOBYTE((rgb)>>16))
#define FAILED(hr) (((long)(hr)) < 0)

#define IN
#define OUT

typedef void* HANDLE;

typedef struct tagRECT
{
	LONG    left;
	LONG    top;
	LONG    right;
	LONG    bottom;
} RECT;

typedef  long long			mxid;
typedef  long long          MxObjectId;

#if defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__) || defined(LINUX_X64) || defined(_MX_64) 
typedef long long       MxObjectIdDynSize;
#else
typedef mxint32       MxObjectIdDynSize;
#endif

#ifdef _MX_FORBIDDEN_IDINDEX
typedef  long long        MxIdIndex;
#else
typedef  long       MxIdIndex;
#endif

#endif

typedef  char					MCHAR;
typedef  const MCHAR *			LPCMSTR;

typedef  MCHAR *				LPMSTR;
#define _MXT(x)      x

typedef mxuint32 MxColor;

typedef long LONG;

#ifndef _T
#define _T(x)      x
#endif

#define  MX_BUILD_APP_FUCTION

#ifndef MXASSERT
	#define MXASSERT(cond)       ((void)0)
#endif

#ifndef MXVERIFY
	#define MXVERIFY(f)          ((void)(f))
#endif MXVERIFY

#define mxmax(a,b)  (((a) > (b)) ? (a) : (b))
#define mxmin(a,b)  (((a) < (b)) ? (a) : (b))