//#pragma once

#include "version.h"

#define USE_VBO 1
#define USE_SAMPLER 1

#ifdef __APPLE__

    #include "TargetConditionals.h"
    #if TARGET_OS_IPHONE
        #define __IOS__ 1
        #include <CoreFoundation/CoreFoundation.h>
        #ifdef __OBJC__
            #import <Foundation/Foundation.h>
            #import <AVFoundation/AVFoundation.h>
            #import <UIKit/UIKit.h>
            #import <GLKit/GLKit.h>
        #endif
        #include <OpenGLES/ES3/gl.h>
        #include <OpenGLES/ES3/glext.h>
        #define SHADER_VERSION "#version 300 es\n"
        #define __GLES__ 1
        #define PP_OS "ios"
        #undef WITH_CURL
        #define WITH_CURL 0
    #else
        #define __OSX__ 1
        #ifdef __OBJC__
            #import <Foundation/Foundation.h>
            #import <AVFoundation/AVFoundation.h>
        #endif
        #include <OpenGL/gl3.h>
        #include <OpenGL/gl3ext.h>
        #define SHADER_VERSION "#version 150\n"
        #define __GL__ 1
        #define PP_OS "osx"
        #ifndef WITH_CURL
            #define WITH_CURL 1
        #endif
    #endif

    #include <sys/stat.h>
    #include <sys/types.h>
    #include <dirent.h>
    #include <dispatch/dispatch.h>
    #define BT_SetTerminate void

#elif __ANDROID__

    #include <EGL/egl.h>
    #include <EGL/eglext.h>
    #include <GLES3/gl3.h>
    #include <sys/stat.h>

    #include <android/sensor.h>
    #include <android/log.h>
    #if __has_include(<android_native_app_glue.h>)
        #include <android_native_app_glue.h>
    #endif

    #define SHADER_VERSION "#version 300 es\n"
    #define PP_OS "android"
    #define __GLES__ 1
    #define __block
    //#define STBI_NEON
    #define BT_SetTerminate void
    #ifndef WITH_CURL
        #define WITH_CURL 1
    #endif

#elif _WIN32

    #define _USE_MATH_DEFINES
    #ifndef _CRT_SECURE_NO_WARNINGS
    #define _CRT_SECURE_NO_WARNINGS
    #endif
    #ifndef _SCL_SECURE_NO_WARNINGS
    #define _SCL_SECURE_NO_WARNINGS
    #endif
    #include <windows.h>
    #include <windowsx.h>
    #include <tchar.h>
#ifdef _DEBUG
    #define GLAD_DEBUG
#endif
    #include <glad\glad.h>
    #include <glad\glad_wgl.h>
    #include <BugTrap.h>
    #include <shlobj.h>
    #include <shlwapi.h>
    #include <openvr.h>
    #include <ppl.h>

    #define __WIN__ 1
    #define __GL__ 1
    #define SHADER_VERSION "#version 150\n"
    #define PP_OS "win"
    #define __block
    #ifndef WITH_CURL
        #define WITH_CURL 1
    #endif

#elif __linux__

#ifdef _DEBUG
    #define GLAD_DEBUG
#endif
    #include <glad/glad.h>
    //#include <glad/glad_glx.h>
    
    #include <sys/stat.h>
    #include <sys/types.h>
    #include <dirent.h>

    #define __LINUX__ 1
    #define SHADER_VERSION "#version 150\n"
    #define PP_OS "linux"
    #define __GL__ 1
    #define __block
    #define BT_SetTerminate void
    #ifndef WITH_CURL
        #define WITH_CURL 1
    #endif

#elif defined(EMSCRIPTEN)

    #define GLFW_INCLUDE_ES3
    #include <GLFW/glfw3.h>
    #include <sys/stat.h>
    #include <sys/types.h>
    #include <dirent.h>

    #define __WEB__ 1
    #define SHADER_VERSION "#version 300 es\n"
    #define PP_OS "web"
    #define __GLES__ 1
    #define __WEBGL__ 1
    #define __block
    #define BT_SetTerminate void

    //#define GL_RGBA8 GL_RGBA

#endif

#define SIXPLETTE(I) {I, I, I, I, I, I}

#ifdef __cplusplus
#include <map>
#include <set>
#include <array>
#include <cmath>
#include <stack>
#include <regex>
#include <mutex>
#include <queue>
#include <chrono>
#include <memory>
#include <string>
#include <vector>
#include <random>
#include <thread>
#include <future>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <functional>
#include <condition_variable>

#define GLM_FORCE_RADIANS
//#define GLM_FORCE_SWIZZLE
//#define GLM_FORCE_MESSAGES
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/random.hpp>
#include <glm/gtx/rotate_vector.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <glm/gtx/vector_angle.hpp>
#include <glm/gtx/intersect.hpp>
#include <glm/gtx/component_wise.hpp>
#include <glm/gtx/normal.hpp>
#include <glm/gtx/matrix_transform_2d.hpp>

#include <tinyxml2.h>
#include <jpge.h>
#include <jpgd.h>
#include <base64.h>
#include <fmt/core.h>
#endif

#include <yoga/Yoga.h>
#include <stb/stb_truetype.h>
#include <stb/stb_image.h>
#include <stb/stb_image_write.h>
#include <sqlite3.h>

#if defined(WITH_CURL) && WITH_CURL && !defined(EMSCRIPTEN)
#include <curl/curl.h>
#endif
