Defines

/Users/ricardoquesada/progs/cocos2d-iphone/cocos2d/ccMacros.h File Reference

#import <math.h>
Include dependency graph for ccMacros.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define CC_SWAP(x, y)
#define CCRANDOM_MINUS1_1()   ((random() / (float)0x3fffffff )-1.0f)
#define CCRANDOM_0_1()   ((random() / (float)0x7fffffff ))
#define CC_DEGREES_TO_RADIANS(__ANGLE__)   ((__ANGLE__) * 0.01745329252f)
#define CC_RADIANS_TO_DEGREES(__ANGLE__)   ((__ANGLE__) * 57.29577951f)
#define CC_BLEND_SRC   GL_ONE
#define CC_BLEND_DST   GL_ONE_MINUS_SRC_ALPHA
#define CC_ENABLE_DEFAULT_GL_STATES()
#define CC_DISABLE_DEFAULT_GL_STATES()
#define CC_DIRECTOR_INIT()
#define CC_DIRECTOR_END()

Detailed Description

cocos2d helper macros

Definition in file ccMacros.h.


Define Documentation

#define CC_BLEND_DST   GL_ONE_MINUS_SRC_ALPHA

default gl blend dst function. Compatible with premultiplied alpha images.

Definition at line 100 of file ccMacros.h.

#define CC_BLEND_SRC   GL_ONE

default gl blend src function. Compatible with premultiplied alpha images.

Definition at line 95 of file ccMacros.h.

#define CC_DEGREES_TO_RADIANS (   __ANGLE__  )     ((__ANGLE__) * 0.01745329252f)

converts degrees to radians

Definition at line 85 of file ccMacros.h.

#define CC_DIRECTOR_END (  ) 
Value:
do {                                                                                                                    \
        CCDirector *__director = [CCDirector sharedDirector];           \
        EAGLView *__view = [__director openGLView];                                     \
        [__view removeFromSuperview];                                                           \
        [__director end];                                                                                       \
} while(0)

Stops and removes the director from memory. Removes the EAGLView from its parent

Since:
v0.99.4

Definition at line 171 of file ccMacros.h.

#define CC_DIRECTOR_INIT (  ) 
Value:
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];                                                                                        \
        [__director setOpenGLView:__glView];                                                                                                            \
        [window addSubview:__glView];                                                                                                                           \
        [window makeKeyAndVisible];                                                                                                                                     \
} while(0)
  • Initializes an EAGLView with 0-bit depth format, and RGB565 render buffer.
  • The EAGLView view will have multiple touches disabled.
  • It will create a UIWindow and it will assign it the 'window' variable. 'window' must be declared before calling this marcro.
  • It will parent the EAGLView to the created window
  • If the firmware >= 3.1 it will create a Display Link Director. Else it will create an NSTimer director.
  • It will try to run at 60 FPS.
  • The FPS won't be displayed.
  • The orientation will be portrait.
  • It will connect the director with the EAGLView.

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.

Since:
v0.99.4

Definition at line 147 of file ccMacros.h.

#define CC_DISABLE_DEFAULT_GL_STATES (  ) 
Value:
{                       \
        glDisable(GL_TEXTURE_2D);                                               \
        glDisableClientState(GL_COLOR_ARRAY);                   \
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);   \
        glDisableClientState(GL_VERTEX_ARRAY);                  \
}

Disable default GL states:

  • GL_TEXTURE_2D
  • GL_VERTEX_ARRAY
  • GL_TEXTURE_COORD_ARRAY
  • GL_COLOR_ARRAY

Definition at line 123 of file ccMacros.h.

#define CC_ENABLE_DEFAULT_GL_STATES (  ) 
Value:
{                               \
        glEnableClientState(GL_VERTEX_ARRAY);                   \
        glEnableClientState(GL_COLOR_ARRAY);                    \
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);    \
        glEnable(GL_TEXTURE_2D);                                                \
}

GL states that are enabled:

  • GL_TEXTURE_2D
  • GL_VERTEX_ARRAY
  • GL_TEXTURE_COORD_ARRAY
  • GL_COLOR_ARRAY

Definition at line 109 of file ccMacros.h.

#define CC_RADIANS_TO_DEGREES (   __ANGLE__  )     ((__ANGLE__) * 57.29577951f)

converts radians to degrees

Definition at line 90 of file ccMacros.h.

#define CC_SWAP (   x,
  y 
)
Value:
({ __typeof__(x) temp  = (x);           \
                x = y; y = temp;                \
})

simple macro that swaps 2 variables

Definition at line 66 of file ccMacros.h.

#define CCRANDOM_0_1 (  )     ((random() / (float)0x7fffffff ))

returns a random float between 0 and 1

Definition at line 80 of file ccMacros.h.

#define CCRANDOM_MINUS1_1 (  )     ((random() / (float)0x3fffffff )-1.0f)

returns a random float between -1 and 1

Definition at line 75 of file ccMacros.h.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

cocos2d for iPhone 0.99.4 API Reference - Generated using Doxygen 1.7.1