Kiwano Engine v1.2.x
macros.h
1// Copyright (c) 2016-2018 Kiwano - Nomango
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#pragma once
22
23#ifndef __cplusplus
24# error Kiwano only supports C++
25#endif
26
27#ifdef _WIN32
28# define KGE_PLATFORM_WINDOWS
29#elif __ANDROID__
30# define KGE_PLATFORM_ANDROID
31#elif __linux__
32# define KGE_PLATFORM_LINUX
33#elif __APPLE__
34# if TARGET_OS_IPHONE
35# define KGE_PLATFORM_IPHONE
36# elif TARGET_OS_MAC
37# define KGE_PLATFORM_MACOS
38# else
39# error "Unsupported Apple platform"
40# endif
41#else
42# error "Unsupported compiler"
43#endif
44
45// C++ RunTime Header Files
46#include <cassert>
47
48// Compile-time Config Header File
49#include <kiwano/config.h>
50
51#define KGE_MAJOR_VERSION 1
52#define KGE_MINOR_VERSION 0
53#define KGE_VERSION ((KGE_MAJOR_VERSION << 4) + KGE_MINOR_VERSION)
54
55#define KGE_GET_MAJOR_VERSION(VERSION) ((VERSION & 0x00F0) >> 4)
56#define KGE_GET_MINOR_VERSION(VERSION) (VERSION & 0x000F)
57
58#if defined(DEBUG) || defined(_DEBUG)
59# define KGE_DEBUG
60#endif
61
62#ifndef KGE_ASSERT
63# define KGE_ASSERT(COND) assert(COND)
64#endif
65
66#define KGE_NOT_USED(VAR) ((void)VAR)
67
68#define KGE_RENDER_ENGINE_NONE 0
69#define KGE_RENDER_ENGINE_OPENGL 1
70#define KGE_RENDER_ENGINE_OPENGLES 2
71#define KGE_RENDER_ENGINE_DIRECTX 3
72#define KGE_RENDER_ENGINE KGE_RENDER_ENGINE_NONE
73
75//
76// Windows platform
77//
79
80#if defined(KGE_PLATFORM_WINDOWS)
81
82#if KGE_RENDER_ENGINE == KGE_RENDER_ENGINE_NONE
83# undef KGE_RENDER_ENGINE
84# define KGE_RENDER_ENGINE KGE_RENDER_ENGINE_DIRECTX
85#endif
86
87#define KGE_DEPRECATED(...) __declspec(deprecated(__VA_ARGS__))
88
89#define KGE_SUPPRESS_WARNING_PUSH __pragma(warning(push))
90#define KGE_SUPPRESS_WARNING(CODE) __pragma(warning(disable : CODE))
91#define KGE_SUPPRESS_WARNING_POP __pragma(warning(pop))
92
93#ifndef KGE_API
94# if defined(KGE_USE_DLL)
95# define KGE_API __declspec(dllimport)
96# elif defined(KGE_EXPORT_DLL)
97# define KGE_API __declspec(dllexport)
98# endif
99#endif
100
101#ifndef KGE_API
102/* Building or calling Kiwano as a static library */
103# define KGE_API
104#else
105/*
106 * C4251 can be ignored if you are deriving from a type in the
107 * C++ Standard Library, compiling a debug release (/MTd) and
108 * where the compiler error message refers to _Container_base.
109 */
110KGE_SUPPRESS_WARNING(4251)
111#endif
112
113#ifdef _MSC_VER
114# ifndef KGE_VS_VER
115# define KGE_VS_VER _MSC_VER
116# define KGE_VS_2013 1800
117# define KGE_VS_2015 1900
118# define KGE_VS_2017 1900
119# define KGE_VS_2019 1920
120# endif
121
122# if KGE_VS_VER < KGE_VS_2015
123# error Kiwano only supports Visual Studio 2015 and above
124# endif
125
126# if defined(KGE_VS_VER) && KGE_VS_VER > KGE_VS_2013
127# define KGE_HAS_LITERALS
128# endif
129#endif
130
131#ifndef WINVER
132# define WINVER 0x0700 // Allow use of features specific to Windows 7 or later
133#endif
134
135#ifndef _WIN32_WINNT
136# define _WIN32_WINNT 0x0700 // Allow use of features specific to Windows 7 or later
137#endif
138
139#ifndef NTDDI_VERSION
140# define NTDDI_VERSION NTDDI_WIN7
141#endif
142
143#ifndef UNICODE
144# define UNICODE
145#endif
146
147// Exclude rarely-used items from Windows headers
148#ifndef WIN32_LEAN_AND_MEAN
149# define WIN32_LEAN_AND_MEAN
150#endif
151
152#ifndef NOMINMAX
153# define NOMINMAX
154#endif
155
156// Windows Header Files
157#include <wincodec.h>
158#include <windows.h>
159
160#elif defined(KGE_PLATFORM_MACOS)
161
162#if KGE_RENDER_ENGINE == KGE_RENDER_ENGINE_NONE
163# undef KGE_RENDER_ENGINE
164# define KGE_RENDER_ENGINE KGE_RENDER_ENGINE_OPENGL
165#endif
166
167#define KGE_DEPRECATED(...)
168
169#define KGE_SUPPRESS_WARNING_PUSH
170#define KGE_SUPPRESS_WARNING(CODE)
171#define KGE_SUPPRESS_WARNING_POP
172
173#ifndef KGE_API
174# if defined(KGE_USE_DLL)
175# define KGE_API
176# elif defined(KGE_EXPORT_DLL)
177# define KGE_API
178# endif
179#endif
180
181#ifndef KGE_API
182/* Building or calling Kiwano as a static library */
183# define KGE_API
184#endif
185
186#else
187
188#if KGE_RENDER_ENGINE == KGE_RENDER_ENGINE_DIRECTX
189# error "DirectX render engine is not supported on current platform"
190#endif
191
192#endif // KGE_PLATFORM_WINDOWS