2019-04-11 14:40:54 +08:00
|
|
|
// Copyright (c) 2016-2018 Kiwano - Nomango
|
2020-01-21 10:09:55 +08:00
|
|
|
//
|
2019-03-31 01:37:06 +08:00
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
// furnished to do so, subject to the following conditions:
|
2020-01-21 10:09:55 +08:00
|
|
|
//
|
2019-03-31 01:37:06 +08:00
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
// all copies or substantial portions of the Software.
|
2020-01-21 10:09:55 +08:00
|
|
|
//
|
2019-03-31 01:37:06 +08:00
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#ifndef __cplusplus
|
2020-02-10 17:32:04 +08:00
|
|
|
# error Kiwano only supports C++
|
2019-03-31 01:37:06 +08:00
|
|
|
#endif
|
|
|
|
|
|
2020-01-13 09:32:41 +08:00
|
|
|
#ifdef _WIN32
|
2020-02-15 17:32:32 +08:00
|
|
|
# define KGE_PLATFORM_WINDOWS
|
2020-01-13 09:32:41 +08:00
|
|
|
#elif __ANDROID__
|
2020-02-15 17:32:32 +08:00
|
|
|
# define KGE_PLATFORM_ANDROID
|
2020-01-13 09:32:41 +08:00
|
|
|
#elif __linux__
|
2020-02-15 17:32:32 +08:00
|
|
|
# define KGE_PLATFORM_LINUX
|
2020-01-13 09:32:41 +08:00
|
|
|
#elif __APPLE__
|
2020-02-10 17:32:04 +08:00
|
|
|
# if TARGET_OS_IPHONE
|
2020-02-15 17:32:32 +08:00
|
|
|
# define KGE_PLATFORM_IPHONE
|
2020-02-10 17:32:04 +08:00
|
|
|
# elif TARGET_OS_MAC
|
2020-02-15 17:32:32 +08:00
|
|
|
# define KGE_PLATFORM_MACOS
|
2020-02-10 17:32:04 +08:00
|
|
|
# else
|
|
|
|
|
# error "Unsupported Apple platform"
|
|
|
|
|
# endif
|
2020-01-21 10:09:55 +08:00
|
|
|
#else
|
2020-02-10 17:32:04 +08:00
|
|
|
# error "Unsupported compiler"
|
2019-03-31 01:37:06 +08:00
|
|
|
#endif
|
|
|
|
|
|
2020-01-13 09:32:41 +08:00
|
|
|
// C++ RunTime Header Files
|
|
|
|
|
#include <cassert>
|
2019-03-31 01:37:06 +08:00
|
|
|
|
2020-01-13 09:32:41 +08:00
|
|
|
// Compile-time Config Header File
|
|
|
|
|
#include <kiwano/config.h>
|
2019-03-31 01:37:06 +08:00
|
|
|
|
2020-02-17 13:23:46 +08:00
|
|
|
#define KGE_MAJOR_VERSION 1
|
|
|
|
|
#define KGE_MINOR_VERSION 0
|
|
|
|
|
#define KGE_VERSION ((KGE_MAJOR_VERSION << 4) + KGE_MINOR_VERSION)
|
|
|
|
|
|
|
|
|
|
#define KGE_GET_MAJOR_VERSION(VERSION) ((VERSION & 0x00F0) >> 4)
|
|
|
|
|
#define KGE_GET_MINOR_VERSION(VERSION) (VERSION & 0x000F)
|
|
|
|
|
|
2020-02-17 23:11:17 +08:00
|
|
|
#if defined(DEBUG) || defined(_DEBUG)
|
|
|
|
|
# define KGE_DEBUG
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef KGE_ASSERT
|
|
|
|
|
# define KGE_ASSERT(COND) assert(COND)
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-02-14 22:59:29 +08:00
|
|
|
#define KGE_NOT_USED(VAR) ((void)VAR)
|
2020-01-21 10:09:55 +08:00
|
|
|
|
2020-02-14 22:59:29 +08:00
|
|
|
#define KGE_RENDER_ENGINE_NONE 0
|
|
|
|
|
#define KGE_RENDER_ENGINE_OPENGL 1
|
|
|
|
|
#define KGE_RENDER_ENGINE_OPENGLES 2
|
|
|
|
|
#define KGE_RENDER_ENGINE_DIRECTX 3
|
|
|
|
|
#define KGE_RENDER_ENGINE KGE_RENDER_ENGINE_NONE
|
2020-01-21 10:09:55 +08:00
|
|
|
|
2020-02-14 22:59:29 +08:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Windows platform
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////
|
2020-01-21 10:09:55 +08:00
|
|
|
|
2020-04-30 14:41:41 +08:00
|
|
|
#if defined(KGE_PLATFORM_WINDOWS)
|
2020-01-21 10:09:55 +08:00
|
|
|
|
2020-02-14 22:59:29 +08:00
|
|
|
#if KGE_RENDER_ENGINE == KGE_RENDER_ENGINE_NONE
|
|
|
|
|
# undef KGE_RENDER_ENGINE
|
|
|
|
|
# define KGE_RENDER_ENGINE KGE_RENDER_ENGINE_DIRECTX
|
2020-01-21 10:09:55 +08:00
|
|
|
#endif
|
|
|
|
|
|
2020-02-14 22:59:29 +08:00
|
|
|
#define KGE_DEPRECATED(...) __declspec(deprecated(__VA_ARGS__))
|
|
|
|
|
|
|
|
|
|
#define KGE_SUPPRESS_WARNING_PUSH __pragma(warning(push))
|
|
|
|
|
#define KGE_SUPPRESS_WARNING(CODE) __pragma(warning(disable : CODE))
|
|
|
|
|
#define KGE_SUPPRESS_WARNING_POP __pragma(warning(pop))
|
|
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
#ifndef KGE_API
|
2020-02-10 17:32:04 +08:00
|
|
|
# if defined(KGE_USE_DLL)
|
|
|
|
|
# define KGE_API __declspec(dllimport)
|
|
|
|
|
# elif defined(KGE_EXPORT_DLL)
|
|
|
|
|
# define KGE_API __declspec(dllexport)
|
|
|
|
|
# endif
|
2020-01-21 10:09:55 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef KGE_API
|
|
|
|
|
/* Building or calling Kiwano as a static library */
|
2020-02-10 17:32:04 +08:00
|
|
|
# define KGE_API
|
2020-01-21 10:09:55 +08:00
|
|
|
#else
|
|
|
|
|
/*
|
|
|
|
|
* C4251 can be ignored if you are deriving from a type in the
|
|
|
|
|
* C++ Standard Library, compiling a debug release (/MTd) and
|
|
|
|
|
* where the compiler error message refers to _Container_base.
|
|
|
|
|
*/
|
2020-02-03 11:11:43 +08:00
|
|
|
KGE_SUPPRESS_WARNING(4251)
|
2020-01-21 10:09:55 +08:00
|
|
|
#endif
|
|
|
|
|
|
2020-02-17 23:11:17 +08:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
# ifndef KGE_VS_VER
|
|
|
|
|
# define KGE_VS_VER _MSC_VER
|
|
|
|
|
# define KGE_VS_2013 1800
|
|
|
|
|
# define KGE_VS_2015 1900
|
|
|
|
|
# define KGE_VS_2017 1900
|
|
|
|
|
# define KGE_VS_2019 1920
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
# if KGE_VS_VER < KGE_VS_2015
|
|
|
|
|
# error Kiwano only supports Visual Studio 2015 and above
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
# if defined(KGE_VS_VER) && KGE_VS_VER > KGE_VS_2013
|
|
|
|
|
# define KGE_HAS_LITERALS
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
2020-02-14 22:59:29 +08:00
|
|
|
|
|
|
|
|
#ifndef WINVER
|
|
|
|
|
# define WINVER 0x0700 // Allow use of features specific to Windows 7 or later
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef _WIN32_WINNT
|
|
|
|
|
# define _WIN32_WINNT 0x0700 // Allow use of features specific to Windows 7 or later
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef NTDDI_VERSION
|
|
|
|
|
# define NTDDI_VERSION NTDDI_WIN7
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef UNICODE
|
|
|
|
|
# define UNICODE
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Exclude rarely-used items from Windows headers
|
|
|
|
|
#ifndef WIN32_LEAN_AND_MEAN
|
|
|
|
|
# define WIN32_LEAN_AND_MEAN
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef NOMINMAX
|
|
|
|
|
# define NOMINMAX
|
|
|
|
|
#endif
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
// Windows Header Files
|
|
|
|
|
#include <wincodec.h>
|
|
|
|
|
#include <windows.h>
|
2019-03-31 01:37:06 +08:00
|
|
|
|
2020-04-30 14:41:41 +08:00
|
|
|
#elif defined(KGE_PLATFORM_MACOS)
|
|
|
|
|
|
|
|
|
|
#if KGE_RENDER_ENGINE == KGE_RENDER_ENGINE_NONE
|
|
|
|
|
# undef KGE_RENDER_ENGINE
|
|
|
|
|
# define KGE_RENDER_ENGINE KGE_RENDER_ENGINE_OPENGL
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define KGE_DEPRECATED(...)
|
|
|
|
|
|
|
|
|
|
#define KGE_SUPPRESS_WARNING_PUSH
|
|
|
|
|
#define KGE_SUPPRESS_WARNING(CODE)
|
|
|
|
|
#define KGE_SUPPRESS_WARNING_POP
|
|
|
|
|
|
|
|
|
|
#ifndef KGE_API
|
|
|
|
|
# if defined(KGE_USE_DLL)
|
|
|
|
|
# define KGE_API
|
|
|
|
|
# elif defined(KGE_EXPORT_DLL)
|
|
|
|
|
# define KGE_API
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef KGE_API
|
|
|
|
|
/* Building or calling Kiwano as a static library */
|
|
|
|
|
# define KGE_API
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-02-15 17:32:32 +08:00
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
#if KGE_RENDER_ENGINE == KGE_RENDER_ENGINE_DIRECTX
|
|
|
|
|
# error "DirectX render engine is not supported on current platform"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif // KGE_PLATFORM_WINDOWS
|