Graphics
v0.0.0
A simple abstraction layer for the modern graphics APIs.
载入中...
搜索中...
未找到
Platform.h
1
// Copyright 2022 ShenMian
2
// License(Apache-2.0)
3
4
#pragma once
5
6
// OS
7
8
#define OS_UNKNOWN 0
9
#define OS_WIN 1
10
#define OS_LINUX 2
11
#define OS_MAC 3
12
#define OS_UNIX 4
13
#define OS_ANDROID 5
14
#define OS_IOS 6
15
16
#if defined(_WIN32)
17
#define TARGET_OS OS_WIN
18
#elif defined(__unix__) || defined(unix) || defined(__unix)
19
#define TARGET_OS OS_UNIX
20
#elif defined(__linux__) && !defined(__ANDROID__)
21
#define TARGET_OS OS_LINUX
22
#elif defined(__APPLE__)
23
#include <TargetConditionals.h>
24
#if TARGET_OS_IPHONE
// TARGET_OS_IPHONE includes TARGET_OS_IOS TARGET_OS_TV and TARGET_OS_WATCH. see
25
// TargetConditionals.h
26
#define TARGET_OS OS_IOS
27
#elif TARGET_OS_MAC
28
#define TARGET_OS OS_MAC
29
#endif
30
#elif defined(__ANDROID__)
31
#define TARGET_OS OS_ANDROID
32
#else
33
#define TARGET_OS OS_UNKNOWN
34
#endif
35
36
#if TARGET_OS == OS_UNKNOWN
37
#error "The target platform is not supported"
38
#endif
39
40
#if TARGET_OS == OS_WIN
41
#ifndef WIN32_LEAN_AND_MEAN
42
#define WIN32_LEAN_AND_MEAN
43
#endif
44
#ifndef NOMINMAX
45
#define NOMINMAX
46
#endif
47
48
#define _WIN32_WINDOWS 0x0A00
// Windows 10
49
#define _WINSOCK_DEPRECATED_NO_WARNINGS
50
#include <windows.h>
51
#endif
52
53
// Compiler
54
55
#define COMPILER_UNKNOWN 0
56
#define COMPILER_MSVC 1
57
#define COMPILER_CLANG 2
58
#define COMPILER_GCC 3
59
60
#if defined(_MSC_VER)
61
#define TARGET_COMPILER COMPILER_MSVC
62
#elif defined(__clang__)
63
#define TARGET_COMPILER COMPILER_CLANG
64
#elif defined(__GNUC__)
65
#define TARGET_COMPILER COMPILER_GCC
66
#else
67
#define TARGET_COMPILER COMPILER_UNKNOWN
68
#endif
69
70
#ifdef __GNUC__
71
#define GCC_VERSION_AT_LEAST(x, y) (__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y))
72
#else
73
#define GCC_VERSION_AT_LEAST(x, y) 0
74
#endif
75
76
#if GCC_VERSION_AT_LEAST(3, 1)
77
#define DEPRECATED __attribute__((deprecated))
78
#elif defined(_MSC_VER)
79
#define DEPRECATED __declspec(deprecated)
80
#else
81
#define DEPRECATED
82
#endif
83
84
#if defined(_MSC_VER)
85
#define DISABLE_WARNING_PUSH __pragma(warning(push))
86
#define DISABLE_WARNING_POP __pragma(warning(pop))
87
#define DISABLE_WARNING(warningNumber) __pragma(warning(disable : warningNumber))
88
#elif defined(__GNUC__) || defined(__clang__)
89
#define DO_PRAGMA(X) _Pragma(#X)
90
#define DISABLE_WARNING_PUSH DO_PRAGMA(GCC diagnostic push)
91
#define DISABLE_WARNING_POP DO_PRAGMA(GCC diagnostic pop)
92
#define DISABLE_WARNING(warningName) DO_PRAGMA(GCC diagnostic ignored #warningName)
93
#else
94
#define DISABLE_WARNING_PUSH
95
#define DISABLE_WARNING_POP
96
#define DISABLE_WARNING(warningName)
97
#endif
src
Core
Platform.h
制作者
1.9.5