Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #import <math.h>
00027
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
00048 #define CCLOG(...) do {} while (0)
00049 #define CCLOGINFO(...) do {} while (0)
00050 #define CCLOGERROR(...) do {} while (0)
00051
00052 #elif COCOS2D_DEBUG == 1
00053 #define CCLOG(...) NSLog(__VA_ARGS__)
00054 #define CCLOGERROR(...) NSLog(__VA_ARGS__)
00055 #define CCLOGINFO(...) do {} while (0)
00056
00057 #elif COCOS2D_DEBUG > 1
00058 #define CCLOG(...) NSLog(__VA_ARGS__)
00059 #define CCLOGERROR(...) NSLog(__VA_ARGS__)
00060 #define CCLOGINFO(...) NSLog(__VA_ARGS__)
00061 #endif // COCOS2D_DEBUG
00062
00066 #define CC_SWAP( x, y ) \
00067 ({ __typeof__(x) temp = (x); \
00068 x = y; y = temp; \
00069 })
00070
00071
00075 #define CCRANDOM_MINUS1_1() ((random() / (float)0x3fffffff )-1.0f)
00076
00080 #define CCRANDOM_0_1() ((random() / (float)0x7fffffff ))
00081
00085 #define CC_DEGREES_TO_RADIANS(__ANGLE__) ((__ANGLE__) * 0.01745329252f) // PI / 180
00086
00090 #define CC_RADIANS_TO_DEGREES(__ANGLE__) ((__ANGLE__) * 57.29577951f) // PI * 180
00091
00095 #define CC_BLEND_SRC GL_ONE
00096
00100 #define CC_BLEND_DST GL_ONE_MINUS_SRC_ALPHA
00101
00109 #define CC_ENABLE_DEFAULT_GL_STATES() { \
00110 glEnableClientState(GL_VERTEX_ARRAY); \
00111 glEnableClientState(GL_COLOR_ARRAY); \
00112 glEnableClientState(GL_TEXTURE_COORD_ARRAY); \
00113 glEnable(GL_TEXTURE_2D); \
00114 }
00115
00123 #define CC_DISABLE_DEFAULT_GL_STATES() { \
00124 glDisable(GL_TEXTURE_2D); \
00125 glDisableClientState(GL_COLOR_ARRAY); \
00126 glDisableClientState(GL_TEXTURE_COORD_ARRAY); \
00127 glDisableClientState(GL_VERTEX_ARRAY); \
00128 }
00129
00147 #define CC_DIRECTOR_INIT() \
00148 do { \
00149 window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; \
00150 if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] ) \
00151 [CCDirector setDirectorType:kCCDirectorTypeNSTimer]; \
00152 CCDirector *__director = [CCDirector sharedDirector]; \
00153 [__director setDeviceOrientation:kCCDeviceOrientationPortrait]; \
00154 [__director setDisplayFPS:NO]; \
00155 [__director setAnimationInterval:1.0/60]; \
00156 EAGLView *__glView = [EAGLView viewWithFrame:[window bounds] \
00157 pixelFormat:kEAGLColorFormatRGB565 \
00158 depthFormat:0 \
00159 preserveBackbuffer:NO]; \
00160 [__director setOpenGLView:__glView]; \
00161 [window addSubview:__glView]; \
00162 [window makeKeyAndVisible]; \
00163 } while(0)
00164
00171 #define CC_DIRECTOR_END() \
00172 do { \
00173 CCDirector *__director = [CCDirector sharedDirector]; \
00174 EAGLView *__view = [__director openGLView]; \
00175 [__view removeFromSuperview]; \
00176 [__director end]; \
00177 } while(0)