cocos2d-x  2.2.3-gd2.113-rev1ec524e
Loading...
Searching...
No Matches
ccMacros.h File Reference
#include "platform/CCCommon.h"
#include "CCStdC.h"
#include "ccConfig.h"
Include dependency graph for ccMacros.h:
This graph shows which files directly or indirectly include this file:

Macros

#define _USE_MATH_DEFINES
 
#define CCAssert(cond, msg)   ((void)(cond))
 
#define CC_SWAP(x, y, type)
 simple macro that swaps 2 variables More...
 
#define CCRANDOM_MINUS1_1()   ((2.0f*((float)rand()/RAND_MAX))-1.0f)
 returns a random float between -1 and 1 More...
 
#define CCRANDOM_0_1()   ((float)rand()/RAND_MAX)
 returns a random float between 0 and 1 More...
 
#define CC_DEGREES_TO_RADIANS(__ANGLE__)   ((__ANGLE__) * 0.01745329252f)
 converts degrees to radians More...
 
#define CC_RADIANS_TO_DEGREES(__ANGLE__)   ((__ANGLE__) * 57.29577951f)
 converts radians to degrees More...
 
#define kCCRepeatForever   (UINT_MAX -1)
 
#define CC_BLEND_SRC   GL_ONE
 default gl blend src function. More...
 
#define CC_BLEND_DST   GL_ONE_MINUS_SRC_ALPHA
 
#define CC_NODE_DRAW_SETUP()
 Helpful macro that setups the GL server state, the correct GL program and sets the Model View Projection matrix. More...
 
#define CC_DIRECTOR_END()
 Stops and removes the director from memory. More...
 
#define CC_CONTENT_SCALE_FACTOR()   CCDirector::sharedDirector()->getContentScaleFactor()
 On Mac it returns 1; On iPhone it returns 2 if RetinaDisplay is On. More...
 
#define CC_RECT_PIXELS_TO_POINTS(__rect_in_pixels__)
 RETINA DISPLAY ENABLED. More...
 
#define CC_RECT_POINTS_TO_PIXELS(__rect_in_points_points__)
 Converts a rect in points to pixels. More...
 
#define CC_POINT_PIXELS_TO_POINTS(__pixels__)   CCPointMake( (__pixels__).x / CC_CONTENT_SCALE_FACTOR(), (__pixels__).y / CC_CONTENT_SCALE_FACTOR())
 Converts a rect in pixels to points. More...
 
#define CC_POINT_POINTS_TO_PIXELS(__points__)   CCPointMake( (__points__).x * CC_CONTENT_SCALE_FACTOR(), (__points__).y * CC_CONTENT_SCALE_FACTOR())
 Converts a rect in points to pixels. More...
 
#define CC_SIZE_PIXELS_TO_POINTS(__size_in_pixels__)   CCSizeMake( (__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__)   CCSizeMake( (__size_in_points__).width * CC_CONTENT_SCALE_FACTOR(), (__size_in_points__).height * CC_CONTENT_SCALE_FACTOR())
 
#define FLT_EPSILON   1.192092896e-07F
 
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
 
#define CC_HOST_IS_BIG_ENDIAN   (bool)(*(unsigned short *)"\0\xff" < 0x100)
 Helper macros which converts 4-byte little/big endian integral number to the machine native number representation. More...
 
#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) )
 
#define CC_PROFILER_DISPLAY_TIMERS()   do {} while (0)
 Profiling Macros. More...
 
#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)
 
#define CHECK_GL_ERROR_DEBUG()
 
#define CC_INCREMENT_GL_DRAWS(__n__)   g_uNumberOfDraws += __n__
 
#define CCAnimationFrameDisplayedNotification   "CCAnimationFrameDisplayedNotification"
 Notifications. More...
 
#define __AS_STR__(str)   #str
 Modding-specific. More...
 
#define __STR_CAT___(str1, str2)   str1##str2
 STR_CAT(str) Concatenate 2 tokens. More...
 
#define __STR_CAT__(str1, str2)   __STR_CAT___(str1, str2)
 
#define RT_ADD(...)   __VA_ARGS__
 RobTop added this function / field. More...
 
#define RT_REMOVE(name)
 RobTop removed this function / field. More...
 
#define HJ_ADD(...)   __VA_ARGS__
 This function / field might not actually exist in GD itself. More...
 
#define PAD(size)   char __STR_CAT__(pad, __LINE__)[size] = {};
 Add padding to a class / struct. More...
 
#define STUB(className)   [[deprecated(__STR_CAT__("incompletely reversed class ", __AS_STR__(className)))]] className
 Stub class. More...
 

Variables

unsigned int CC_DLL g_uNumberOfDraws
 

Macro Definition Documentation

◆ __AS_STR__

#define __AS_STR__ (   str)    #str

Modding-specific.

AS_STR(str) Use token as a C string. Useful for multi-layer macros. Don't use this.

◆ __STR_CAT__

#define __STR_CAT__ (   str1,
  str2 
)    __STR_CAT___(str1, str2)

◆ __STR_CAT___

#define __STR_CAT___ (   str1,
  str2 
)    str1##str2

STR_CAT(str) Concatenate 2 tokens.

Don't use this.

◆ _USE_MATH_DEFINES

#define _USE_MATH_DEFINES

◆ CC_BLEND_DST

#define CC_BLEND_DST   GL_ONE_MINUS_SRC_ALPHA

◆ CC_BLEND_SRC

#define CC_BLEND_SRC   GL_ONE

default gl blend src function.

Compatible with premultiplied alpha images.

◆ CC_CONTENT_SCALE_FACTOR

#define CC_CONTENT_SCALE_FACTOR ( )    CCDirector::sharedDirector()->getContentScaleFactor()

On Mac it returns 1; On iPhone it returns 2 if RetinaDisplay is On.

Otherwise it returns 1

◆ CC_DEGREES_TO_RADIANS

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

converts degrees to radians

◆ CC_DIRECTOR_END

#define CC_DIRECTOR_END ( )
Value:
do { \
CCDirector *__director = CCDirector::sharedDirector(); \
__director->end(); \
} while(0)

Stops and removes the director from memory.

Removes the CCGLView from its parent

Since
v0.99.4

◆ CC_HOST_IS_BIG_ENDIAN

#define CC_HOST_IS_BIG_ENDIAN   (bool)(*(unsigned short *)"\0\xff" < 0x100)

Helper macros which converts 4-byte little/big endian integral number to the machine native number representation.

It should work same as apples CFSwapInt32LittleToHost(..) when define returns true it means that our architecture uses big endian

◆ CC_INCREMENT_GL_DRAWS

#define CC_INCREMENT_GL_DRAWS (   __n__)    g_uNumberOfDraws += __n__

◆ CC_NODE_DRAW_SETUP

#define CC_NODE_DRAW_SETUP ( )
Value:
do { \
ccGLEnable(m_eGLServerState); \
CCAssert(getShaderProgram(), "No shader program set for this node"); \
{ \
getShaderProgram()->use(); \
getShaderProgram()->setUniformsForBuiltins(); \
} \
} while(0)

Helpful macro that setups the GL server state, the correct GL program and sets the Model View Projection matrix.

Since
v2.0

◆ CC_POINT_PIXELS_TO_POINTS

#define CC_POINT_PIXELS_TO_POINTS (   __pixels__)    CCPointMake( (__pixels__).x / CC_CONTENT_SCALE_FACTOR(), (__pixels__).y / CC_CONTENT_SCALE_FACTOR())

Converts a rect in pixels to points.

◆ CC_POINT_POINTS_TO_PIXELS

#define CC_POINT_POINTS_TO_PIXELS (   __points__)    CCPointMake( (__points__).x * CC_CONTENT_SCALE_FACTOR(), (__points__).y * CC_CONTENT_SCALE_FACTOR())

Converts a rect in points to pixels.

◆ CC_PROFILER_DISPLAY_TIMERS

#define CC_PROFILER_DISPLAY_TIMERS ( )    do {} while (0)

Profiling Macros.

◆ CC_PROFILER_PURGE_ALL

#define CC_PROFILER_PURGE_ALL ( )    do {} while (0)

◆ CC_PROFILER_RESET

#define CC_PROFILER_RESET (   __name__)    do {} while (0)

◆ CC_PROFILER_RESET_CATEGORY

#define CC_PROFILER_RESET_CATEGORY (   __cat__,
  __name__ 
)    do {} while(0)

◆ CC_PROFILER_RESET_INSTANCE

#define CC_PROFILER_RESET_INSTANCE (   __id__,
  __name__ 
)    do {} while(0)

◆ CC_PROFILER_START

#define CC_PROFILER_START (   __name__)    do {} while (0)

◆ CC_PROFILER_START_CATEGORY

#define CC_PROFILER_START_CATEGORY (   __cat__,
  __name__ 
)    do {} while(0)

◆ CC_PROFILER_START_INSTANCE

#define CC_PROFILER_START_INSTANCE (   __id__,
  __name__ 
)    do {} while(0)

◆ CC_PROFILER_STOP

#define CC_PROFILER_STOP (   __name__)    do {} while (0)

◆ CC_PROFILER_STOP_CATEGORY

#define CC_PROFILER_STOP_CATEGORY (   __cat__,
  __name__ 
)    do {} while(0)

◆ CC_PROFILER_STOP_INSTANCE

#define CC_PROFILER_STOP_INSTANCE (   __id__,
  __name__ 
)    do {} while(0)

◆ CC_RADIANS_TO_DEGREES

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

converts radians to degrees

◆ CC_RECT_PIXELS_TO_POINTS

#define CC_RECT_PIXELS_TO_POINTS (   __rect_in_pixels__)
Value:
CCRectMake( (__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_CONTENT_SCALE_FACTOR()
On Mac it returns 1; On iPhone it returns 2 if RetinaDisplay is On.
Definition: ccMacros.h:123
#define CCRectMake(x, y, width, height)
Definition: CCGeometry.h:336

RETINA DISPLAY ENABLED.

Converts a rect in pixels to points

◆ CC_RECT_POINTS_TO_PIXELS

#define CC_RECT_POINTS_TO_PIXELS (   __rect_in_points_points__)
Value:
CCRectMake( (__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() )

Converts a rect in points to pixels.

◆ CC_SIZE_PIXELS_TO_POINTS

#define CC_SIZE_PIXELS_TO_POINTS (   __size_in_pixels__)    CCSizeMake( (__size_in_pixels__).width / CC_CONTENT_SCALE_FACTOR(), (__size_in_pixels__).height / CC_CONTENT_SCALE_FACTOR())

◆ CC_SIZE_POINTS_TO_PIXELS

#define CC_SIZE_POINTS_TO_PIXELS (   __size_in_points__)    CCSizeMake( (__size_in_points__).width * CC_CONTENT_SCALE_FACTOR(), (__size_in_points__).height * CC_CONTENT_SCALE_FACTOR())

◆ CC_SWAP

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

simple macro that swaps 2 variables

◆ CC_SWAP16

#define CC_SWAP16 (   i)    ((i & 0x00ff) << 8 | (i &0xff00) >> 8)

◆ CC_SWAP32

#define CC_SWAP32 (   i)    ((i & 0x000000ff) << 24 | (i & 0x0000ff00) << 8 | (i & 0x00ff0000) >> 8 | (i & 0xff000000) >> 24)

◆ CC_SWAP_INT16_BIG_TO_HOST

#define CC_SWAP_INT16_BIG_TO_HOST (   i)    ((CC_HOST_IS_BIG_ENDIAN == true)? (i): CC_SWAP16(i) )

◆ CC_SWAP_INT16_LITTLE_TO_HOST

#define CC_SWAP_INT16_LITTLE_TO_HOST (   i)    ((CC_HOST_IS_BIG_ENDIAN == true)? CC_SWAP16(i) : (i) )

◆ CC_SWAP_INT32_BIG_TO_HOST

#define CC_SWAP_INT32_BIG_TO_HOST (   i)    ((CC_HOST_IS_BIG_ENDIAN == true)? (i) : CC_SWAP32(i) )

◆ CC_SWAP_INT32_LITTLE_TO_HOST

#define CC_SWAP_INT32_LITTLE_TO_HOST (   i)    ((CC_HOST_IS_BIG_ENDIAN == true)? CC_SWAP32(i) : (i) )

◆ CCAnimationFrameDisplayedNotification

#define CCAnimationFrameDisplayedNotification   "CCAnimationFrameDisplayedNotification"

Notifications.

Notification name when a CCSpriteFrame is displayed

◆ CCAssert

#define CCAssert (   cond,
  msg 
)    ((void)(cond))

◆ CCRANDOM_0_1

#define CCRANDOM_0_1 ( )    ((float)rand()/RAND_MAX)

returns a random float between 0 and 1

◆ CCRANDOM_MINUS1_1

#define CCRANDOM_MINUS1_1 ( )    ((2.0f*((float)rand()/RAND_MAX))-1.0f)

returns a random float between -1 and 1

◆ CHECK_GL_ERROR_DEBUG

#define CHECK_GL_ERROR_DEBUG ( )

◆ DISALLOW_COPY_AND_ASSIGN

#define DISALLOW_COPY_AND_ASSIGN (   TypeName)
Value:
TypeName(const TypeName&);\
void operator=(const TypeName&)

◆ FLT_EPSILON

#define FLT_EPSILON   1.192092896e-07F

◆ HJ_ADD

#define HJ_ADD (   ...)    __VA_ARGS__

This function / field might not actually exist in GD itself.

However, it has been added in these headers for ease-of-use or other equivalent reasons. It should not conflict with GD itself.

◆ kCCRepeatForever

#define kCCRepeatForever   (UINT_MAX -1)

◆ PAD

#define PAD (   size)    char __STR_CAT__(pad, __LINE__)[size] = {};

Add padding to a class / struct.

For shifting classes / structs to be aligned, if too lazy to fully reverse.

Based on line number, to be standard C / C++ compatible.

◆ RT_ADD

#define RT_ADD (   ...)    __VA_ARGS__

RobTop added this function / field.

It is proprietary, and the modding library will not compile properly if this function / field is not found in the Cocos2d headers.

Variadic arguments used due to enums using commas, which will not expand correctly otherwise.

◆ RT_REMOVE

#define RT_REMOVE (   name)

RobTop removed this function / field.

It is not found in libcocos2d.dll, and can't be called / used.

◆ STUB

#define STUB (   className)    [[deprecated(__STR_CAT__("incompletely reversed class ", __AS_STR__(className)))]] className

Stub class.

Not complete: use with caution.

Variable Documentation

◆ g_uNumberOfDraws

unsigned int CC_DLL g_uNumberOfDraws
extern