1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
| #ifndef CCASSERT #if COCOS2D_DEBUG > 0 #if CC_ENABLE_SCRIPT_BINDING extern bool CC_DLL cc_assert_script_compatible(const char *msg); #define CCASSERT(cond, msg) do { \ if (!(cond)) { \ if (!cc_assert_script_compatible(msg) && strlen(msg)) \ cocos2d::log("Assert failed: %s", msg); \ CC_ASSERT(cond); \ } \ } while (0) #else #define CCASSERT(cond, msg) CC_ASSERT(cond) #endif #else #define CCASSERT(cond, msg) #endif
#define CCAssert CCASSERT #endif
#include "ccConfig.h"
#define CC_SWAP(x, y, type) \ { type temp = (x); \ x = y; y = temp; \ }
#define CCRANDOM_MINUS1_1() ((2.0f*((float)rand()/RAND_MAX))-1.0f)
#define CCRANDOM_0_1() ((float)rand()/RAND_MAX)
#define CC_DEGREES_TO_RADIANS(__ANGLE__) ((__ANGLE__) * 0.01745329252f)
#define CC_RADIANS_TO_DEGREES(__ANGLE__) ((__ANGLE__) * 57.29577951f)
#define kRepeatForever (UINT_MAX -1)
#define CC_BLEND_SRC GL_ONE #define CC_BLEND_DST GL_ONE_MINUS_SRC_ALPHA
#define CC_NODE_DRAW_SETUP() \ do { \ CCASSERT(getShaderProgram(), "No shader program set for this node"); \ { \ getShaderProgram()->use(); \ getShaderProgram()->setUniformsForBuiltins(_modelViewTransform); \ } \ } while(0)
#define CC_DIRECTOR_END() \ do { \ Director *__director = Director::getInstance(); \ __director->end(); \ } while(0)
#define CC_CONTENT_SCALE_FACTOR() Director::getInstance()->getContentScaleFactor()
* RETINA 显示屏 * *****************/
#define CC_RECT_PIXELS_TO_POINTS(__rect_in_pixels__) \ Rect( (__rect_in_pixels__).origin.x / CC_CONTENT_SCALE_FACTOR(), (__rect_in_pixels__).origin.y / CC_CONTENT_SCALE_FACTOR(), \ (__rect_in_pixels__).size.width / CC_CONTENT_SCALE_FACTOR(), (__rect_in_pixels__).size.height / CC_CONTENT_SCALE_FACTOR() )
#define CC_RECT_POINTS_TO_PIXELS(__rect_in_points_points__) \ Rect( (__rect_in_points_points__).origin.x * CC_CONTENT_SCALE_FACTOR(), (__rect_in_points_points__).origin.y * CC_CONTENT_SCALE_FACTOR(), \ (__rect_in_points_points__).size.width * CC_CONTENT_SCALE_FACTOR(), (__rect_in_points_points__).size.height * CC_CONTENT_SCALE_FACTOR() )
#define CC_POINT_PIXELS_TO_POINTS(__pixels__) \ Point( (__pixels__).x / CC_CONTENT_SCALE_FACTOR(), (__pixels__).y / CC_CONTENT_SCALE_FACTOR())
#define CC_POINT_POINTS_TO_PIXELS(__points__) \ Point( (__points__).x * CC_CONTENT_SCALE_FACTOR(), (__points__).y * CC_CONTENT_SCALE_FACTOR())
#define CC_SIZE_PIXELS_TO_POINTS(__size_in_pixels__) \ Size( (__size_in_pixels__).width / CC_CONTENT_SCALE_FACTOR(), (__size_in_pixels__).height / CC_CONTENT_SCALE_FACTOR())
#define CC_SIZE_POINTS_TO_PIXELS(__size_in_points__) \ Size( (__size_in_points__).width * CC_CONTENT_SCALE_FACTOR(), (__size_in_points__).height * CC_CONTENT_SCALE_FACTOR())
#ifndef FLT_EPSILON #define FLT_EPSILON 1.192092896e-07F #endif
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ TypeName(const TypeName&);\ void operator=(const TypeName&)
#define CC_HOST_IS_BIG_ENDIAN (bool)(*(unsigned short *)"\0\xff" < 0x100)
#define CC_SWAP32(i) ((i & 0x000000ff) << 24 | (i & 0x0000ff00) << 8 | (i & 0x00ff0000) >> 8 | (i & 0xff000000) >> 24)
#define CC_SWAP16(i) ((i & 0x00ff) << 8 | (i &0xff00) >> 8)
#define CC_SWAP_INT32_LITTLE_TO_HOST(i) ((CC_HOST_IS_BIG_ENDIAN == true)? CC_SWAP32(i) : (i) ) #define CC_SWAP_INT16_LITTLE_TO_HOST(i) ((CC_HOST_IS_BIG_ENDIAN == true)? CC_SWAP16(i) : (i) ) #define CC_SWAP_INT32_BIG_TO_HOST(i) ((CC_HOST_IS_BIG_ENDIAN == true)? (i) : CC_SWAP32(i) ) #define CC_SWAP_INT16_BIG_TO_HOST(i) ((CC_HOST_IS_BIG_ENDIAN == true)? (i): CC_SWAP16(i) )
#if CC_ENABLE_PROFILERS
#define CC_PROFILER_DISPLAY_TIMERS() Profiler::getInstance()->displayTimers() #define CC_PROFILER_PURGE_ALL() Profiler::getInstance()->releaseAllTimers()
#define CC_PROFILER_START(__name__) ProfilingBeginTimingBlock(__name__) #define CC_PROFILER_STOP(__name__) ProfilingEndTimingBlock(__name__) #define CC_PROFILER_RESET(__name__) ProfilingResetTimingBlock(__name__)
#define CC_PROFILER_START_CATEGORY(__cat__, __name__) do{ if(__cat__) ProfilingBeginTimingBlock(__name__); } while(0) #define CC_PROFILER_STOP_CATEGORY(__cat__, __name__) do{ if(__cat__) ProfilingEndTimingBlock(__name__); } while(0) #define CC_PROFILER_RESET_CATEGORY(__cat__, __name__) do{ if(__cat__) ProfilingResetTimingBlock(__name__); } while(0)
#define CC_PROFILER_START_INSTANCE(__id__, __name__) do{ ProfilingBeginTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) #define CC_PROFILER_STOP_INSTANCE(__id__, __name__) do{ ProfilingEndTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0) #define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do{ ProfilingResetTimingBlock( String::createWithFormat("%08X - %s", __id__, __name__)->getCString() ); } while(0)
#else
#define CC_PROFILER_DISPLAY_TIMERS() do {} while (0) #define CC_PROFILER_PURGE_ALL() do {} while (0)
#define CC_PROFILER_START(__name__) do {} while (0) #define CC_PROFILER_STOP(__name__) do {} while (0) #define CC_PROFILER_RESET(__name__) do {} while (0)
#define CC_PROFILER_START_CATEGORY(__cat__, __name__) do {} while(0) #define CC_PROFILER_STOP_CATEGORY(__cat__, __name__) do {} while(0) #define CC_PROFILER_RESET_CATEGORY(__cat__, __name__) do {} while(0)
#define CC_PROFILER_START_INSTANCE(__id__, __name__) do {} while(0) #define CC_PROFILER_STOP_INSTANCE(__id__, __name__) do {} while(0) #define CC_PROFILER_RESET_INSTANCE(__id__, __name__) do {} while(0)
#endif
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 #define CHECK_GL_ERROR_DEBUG() #else #define CHECK_GL_ERROR_DEBUG() \ do { \ GLenum __error = glGetError(); \ if(__error) { \ cocos2d::log("OpenGL error 0x%04X in %s %s %d\n", __error, __FILE__, __FUNCTION__, __LINE__); \ } \ } while (false) #endif
#define CC_INCREMENT_GL_DRAWS(__n__) Director::getInstance()->getRenderer()->addDrawnBatches(__n__) #define CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(__drawcalls__, __vertices__) \ do { \ auto __renderer__ = Director::getInstance()->getRenderer(); \ __renderer__->addDrawnBatches(__drawcalls__); \ __renderer__->addDrawnVertices(__vertices__); \ } while(0)
#define AnimationFrameDisplayedNotification "CCAnimationFrameDisplayedNotification"
#define CC_CALLBACK_0(__selector__,__target__, ...) std::bind(&__selector__,__target__, ##__VA_ARGS__) #define CC_CALLBACK_1(__selector__,__target__, ...) std::bind(&__selector__,__target__, std::placeholders::_1, ##__VA_ARGS__) #define CC_CALLBACK_2(__selector__,__target__, ...) std::bind(&__selector__,__target__, std::placeholders::_1, std::placeholders::_2, ##__VA_ARGS__) #define CC_CALLBACK_3(__selector__,__target__, ...) std::bind(&__selector__,__target__, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, ##__VA_ARGS__)
|