axmol/cocos/platform/CCPlatformConfig.h

149 lines
4.6 KiB
C
Raw Normal View History

2019-11-23 20:27:39 +08:00
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
Copyright (c) 2013-2017 Chukong Technologies
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
2021-11-16 16:28:31 +08:00
Copyright (c) 2021 Bytedance Inc.
2019-11-23 20:27:39 +08:00
2021-11-16 16:28:31 +08:00
https://adxe.org
2019-11-23 20:27:39 +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:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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.
****************************************************************************/
#ifndef __BASE_CC_PLATFORM_CONFIG_H__
#define __BASE_CC_PLATFORM_CONFIG_H__
/// @cond DO_NOT_SHOW
/**
Config of cocos2d-x project, per target platform.
THIS FILE MUST NOT INCLUDE ANY OTHER FILE
*/
//////////////////////////////////////////////////////////////////////////
// pre configure
//////////////////////////////////////////////////////////////////////////
// define supported target platform macro which CC uses.
2021-12-25 10:04:45 +08:00
#define CC_PLATFORM_UNKNOWN 0
#define CC_PLATFORM_IOS 1
#define CC_PLATFORM_ANDROID 2
#define CC_PLATFORM_WIN32 3
2019-11-23 20:27:39 +08:00
// #define CC_PLATFORM_MARMALADE 4
2021-12-25 10:04:45 +08:00
#define CC_PLATFORM_LINUX 5
2019-11-23 20:27:39 +08:00
// #define CC_PLATFORM_BADA 6
// #define CC_PLATFORM_BLACKBERRY 7
2021-12-25 10:04:45 +08:00
#define CC_PLATFORM_MAC 8
2019-11-23 20:27:39 +08:00
// #define CC_PLATFORM_NACL 9
// #define CC_PLATFORM_EMSCRIPTEN 10
// #define CC_PLATFORM_TIZEN 11
// #define CC_PLATFORM_QT5 12
// #define CC_PLATFORM_WINRT 13
// Determine target platform by compile environment macro.
2021-12-25 10:04:45 +08:00
#define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN
2019-11-23 20:27:39 +08:00
// Apple: Mac and iOS
2021-12-25 10:04:45 +08:00
#if defined(__APPLE__) && !defined(__ANDROID__) // exclude android for binding generator.
# include <TargetConditionals.h>
# if TARGET_OS_IPHONE // TARGET_OS_IPHONE includes TARGET_OS_IOS TARGET_OS_TV and TARGET_OS_WATCH. see
// TargetConditionals.h
# undef CC_TARGET_PLATFORM
# define CC_TARGET_PLATFORM CC_PLATFORM_IOS
# elif TARGET_OS_MAC
# undef CC_TARGET_PLATFORM
# define CC_TARGET_PLATFORM CC_PLATFORM_MAC
# endif
2019-11-23 20:27:39 +08:00
#endif
// android
#if defined(__ANDROID__)
2021-12-25 10:04:45 +08:00
# undef CC_TARGET_PLATFORM
# define CC_TARGET_PLATFORM CC_PLATFORM_ANDROID
2019-11-23 20:27:39 +08:00
#endif
// win32
#if defined(_WIN32) && defined(_WINDOWS)
2021-12-25 10:04:45 +08:00
# undef CC_TARGET_PLATFORM
# define CC_TARGET_PLATFORM CC_PLATFORM_WIN32
2019-11-23 20:27:39 +08:00
#endif
// linux
#if defined(LINUX) && !defined(__APPLE__)
2021-12-25 10:04:45 +08:00
# undef CC_TARGET_PLATFORM
# define CC_TARGET_PLATFORM CC_PLATFORM_LINUX
2019-11-23 20:27:39 +08:00
#endif
//////////////////////////////////////////////////////////////////////////
// post configure
//////////////////////////////////////////////////////////////////////////
// check user set platform
2021-12-25 10:04:45 +08:00
#if !CC_TARGET_PLATFORM
# error "Cannot recognize the target platform; are you targeting an unsupported platform?"
2019-11-23 20:27:39 +08:00
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
2021-12-25 10:04:45 +08:00
# ifndef __MINGW32__
# pragma warning(disable : 4127)
# endif
2019-11-23 20:27:39 +08:00
#endif // CC_PLATFORM_WIN32
2021-12-25 10:04:45 +08:00
/*
windows: https://github.com/google/angle
mac: GL
iOS: GLES
other: GL
*/
#ifndef CC_COMPAT_GL
2021-12-25 10:04:45 +08:00
# define CC_COMPAT_GL 0
#endif
2019-11-23 20:27:39 +08:00
#if ((CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS))
2021-12-25 10:04:45 +08:00
# define CC_PLATFORM_MOBILE
2019-11-23 20:27:39 +08:00
#else
2021-12-25 10:04:45 +08:00
# define CC_PLATFORM_PC
2019-11-23 20:27:39 +08:00
#endif
2021-12-25 10:04:45 +08:00
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
# if !CC_COMPAT_GL
# define CC_USE_METAL
# else
# define CC_USE_GL
# endif
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
2021-12-25 10:04:45 +08:00
# if !CC_COMPAT_GL
# define CC_USE_METAL
# else
# define CC_USE_GLES
# endif
2019-11-23 20:27:39 +08:00
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
2021-12-25 10:04:45 +08:00
# define CC_USE_GLES
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
2021-12-25 10:04:45 +08:00
# if !CC_COMPAT_GL
# define CC_USE_GL
# else
# define CC_USE_GLES
# endif
#else
2021-12-25 10:04:45 +08:00
# define CC_USE_GL
#endif
2019-11-23 20:27:39 +08:00
/// @endcond
#endif // __BASE_CC_PLATFORM_CONFIG_H__