Files | |
| file | ccMacros.h |
Defines | |
| #define | CC_BLEND_SRC GL_ONE |
| #define | CC_CONTENT_SCALE_FACTOR() __ccContentScaleFactor |
| #define | CC_DEGREES_TO_RADIANS(__ANGLE__) ((__ANGLE__) * 0.01745329252f) |
| #define | CC_DIRECTOR_END() |
| #define | CC_DIRECTOR_INIT() |
| #define | CC_DISABLE_DEFAULT_GL_STATES() |
| #define | CC_ENABLE_DEFAULT_GL_STATES() |
| #define | CC_RADIANS_TO_DEGREES(__ANGLE__) ((__ANGLE__) * 57.29577951f) |
| #define | CC_RECT_PIXELS_TO_POINTS(__pixels__) |
| #define | CC_RECT_POINTS_TO_PIXELS(__points__) |
| #define | CC_SWAP(x, y) |
| #define | CCLOG(...) do {} while (0) |
| #define | CCRANDOM_0_1() ((random() / (float)0x7fffffff )) |
| #define | CCRANDOM_MINUS1_1() ((random() / (float)0x3fffffff )-1.0f) |
| #define CC_BLEND_SRC GL_ONE |
default gl blend src function. Compatible with premultiplied alpha images.
| #define CC_CONTENT_SCALE_FACTOR | ( | ) | __ccContentScaleFactor |
RETINA DISPLAY ENABLED On Mac it returns 1; On iPhone it returns 2 if RetinaDisplay is On. Otherwise it returns 1
| #define CC_DEGREES_TO_RADIANS | ( | __ANGLE__ | ) | ((__ANGLE__) * 0.01745329252f) |
converts degrees to radians
| #define CC_DIRECTOR_END | ( | ) |
do { \ CCDirector *__director = [CCDirector sharedDirector]; \ CC_GLVIEW *__view = [__director openGLView]; \ [__view removeFromSuperview]; \ [__director end]; \ } while(0)
Stops and removes the director from memory. Removes the EAGLView from its parent
| #define CC_DIRECTOR_INIT | ( | ) |
do { \ window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; \ if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] ) \ [CCDirector setDirectorType:kCCDirectorTypeNSTimer]; \ CCDirector *__director = [CCDirector sharedDirector]; \ [__director setDeviceOrientation:kCCDeviceOrientationPortrait]; \ [__director setDisplayFPS:NO]; \ [__director setAnimationInterval:1.0/60]; \ EAGLView *__glView = [EAGLView viewWithFrame:[window bounds] \ pixelFormat:kEAGLColorFormatRGB565 \ depthFormat:0 /* GL_DEPTH_COMPONENT24_OES */ \ preserveBackbuffer:NO \ sharegroup:nil \ multiSampling:NO \ numberOfSamples:0 \ ]; \ [__director setOpenGLView:__glView]; \ [window addSubview:__glView]; \ [window makeKeyAndVisible]; \ } while(0)
IMPORTANT: If you want to use another type of render buffer (eg: RGBA8) or if you want to use a 16-bit or 24-bit depth buffer, you should NOT use this macro. Instead, you should create the EAGLView manually.
| #define CC_DISABLE_DEFAULT_GL_STATES | ( | ) |
{ \
glDisable(GL_TEXTURE_2D); \
glDisableClientState(GL_COLOR_ARRAY); \
glDisableClientState(GL_TEXTURE_COORD_ARRAY); \
glDisableClientState(GL_VERTEX_ARRAY); \
}
Disable default GL states:
| #define CC_ENABLE_DEFAULT_GL_STATES | ( | ) |
{ \
glEnableClientState(GL_VERTEX_ARRAY); \
glEnableClientState(GL_COLOR_ARRAY); \
glEnableClientState(GL_TEXTURE_COORD_ARRAY); \
glEnable(GL_TEXTURE_2D); \
}
GL states that are enabled:
| #define CC_RADIANS_TO_DEGREES | ( | __ANGLE__ | ) | ((__ANGLE__) * 57.29577951f) |
converts radians to degrees
| #define CC_RECT_PIXELS_TO_POINTS | ( | __pixels__ | ) |
CGRectMake( (__pixels__).origin.x / CC_CONTENT_SCALE_FACTOR(), (__pixels__).origin.y / CC_CONTENT_SCALE_FACTOR(), \ (__pixels__).size.width / CC_CONTENT_SCALE_FACTOR(), (__pixels__).size.height / CC_CONTENT_SCALE_FACTOR() )
Converts a rect in pixels to points
| #define CC_RECT_POINTS_TO_PIXELS | ( | __points__ | ) |
CGRectMake( (__points__).origin.x * CC_CONTENT_SCALE_FACTOR(), (__points__).origin.y * CC_CONTENT_SCALE_FACTOR(), \ (__points__).size.width * CC_CONTENT_SCALE_FACTOR(), (__points__).size.height * CC_CONTENT_SCALE_FACTOR() )
Converts a rect in points to pixels
| #define CC_SWAP | ( | x, | ||
| y | ||||
| ) |
({ __typeof__(x) temp = (x); \
x = y; y = temp; \
})
simple macro that swaps 2 variables
| #define CCLOG | ( | ... | ) | do {} while (0) |
if COCOS2D_DEBUG is not defined, or if it is 0 then all CCLOGXXX macros will be disabled
if COCOS2D_DEBUG==1 then: CCLOG() will be enabled CCLOGERROR() will be enabled CCLOGINFO() will be disabled
if COCOS2D_DEBUG==2 or higher then: CCLOG() will be enabled CCLOGERROR() will be enabled CCLOGINFO() will be enabled
| #define CCRANDOM_0_1 | ( | ) | ((random() / (float)0x7fffffff )) |
returns a random float between 0 and 1
| #define CCRANDOM_MINUS1_1 | ( | ) | ((random() / (float)0x3fffffff )-1.0f) |
returns a random float between -1 and 1
1.7.1