ccConfig.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. /****************************************************************************
  2. Copyright (c) 2008-2010 Ricardo Quesada
  3. Copyright (c) 2010-2012 cocos2d-x.org
  4. Copyright (c) 2011 Zynga Inc.
  5. Copyright (c) 2013-2016 Chukong Technologies Inc.
  6. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  7. http://www.cocos2d-x.org
  8. Permission is hereby granted, free of charge, to any person obtaining a copy
  9. of this software and associated documentation files (the "Software"), to deal
  10. in the Software without restriction, including without limitation the rights
  11. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. copies of the Software, and to permit persons to whom the Software is
  13. furnished to do so, subject to the following conditions:
  14. The above copyright notice and this permission notice shall be included in
  15. all copies or substantial portions of the Software.
  16. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. THE SOFTWARE.
  23. ****************************************************************************/
  24. #ifndef __CCCONFIG_H__
  25. #define __CCCONFIG_H__
  26. #include "platform/CCPlatformConfig.h"
  27. /**
  28. * @file
  29. * cocos2d (cc) configuration file.
  30. */
  31. /** @def CC_ENABLE_STACKABLE_ACTIONS
  32. * If enabled, actions that alter the position property (eg: MoveBy, JumpBy, BezierBy, etc..) will be stacked.
  33. * If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions.
  34. * If disabled, only the last run action will take effect.
  35. * Enabled by default. Disable to be compatible with v2.0 and older versions.
  36. * @since v2.1
  37. */
  38. #ifndef CC_ENABLE_STACKABLE_ACTIONS
  39. #define CC_ENABLE_STACKABLE_ACTIONS 1
  40. #endif
  41. /** @def CC_ENABLE_GL_STATE_CACHE
  42. * If enabled, cocos2d will maintain an OpenGL state cache internally to avoid unnecessary switches.
  43. * In order to use them, you have to use the following functions, instead of the GL ones:
  44. * - ccGLUseProgram() instead of glUseProgram().
  45. * - GL::deleteProgram() instead of glDeleteProgram().
  46. * - GL::blendFunc() instead of glBlendFunc().
  47. * If this functionality is disabled, then ccGLUseProgram(), GL::deleteProgram(), GL::blendFunc() will call the GL ones, without using the cache.
  48. * It is recommended to enable whenever possible to improve speed.
  49. * If you are migrating your code from GL ES 1.1, then keep it disabled. Once all your code works as expected, turn it on.
  50. * Enabled by default.
  51. * @since v2.0.0
  52. */
  53. #ifndef CC_ENABLE_GL_STATE_CACHE
  54. #define CC_ENABLE_GL_STATE_CACHE 1
  55. #endif
  56. /** @def CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
  57. * If enabled, the texture coordinates will be calculated by using this formula:
  58. * - texCoord.left = (rect.origin.x*2+1) / (texture.wide*2);
  59. * - texCoord.right = texCoord.left + (rect.size.width*2-2)/(texture.wide*2);
  60. * The same for bottom and top.
  61. * This formula prevents artifacts by using 99% of the texture.
  62. * The "correct" way to prevent artifacts is by using the spritesheet-artifact-fixer.py or a similar tool.
  63. * Affected nodes:
  64. * - Sprite / SpriteBatchNode and subclasses: LabelBMFont, TMXTiledMap.
  65. * - LabelAtlas.
  66. * - QuadParticleSystem.
  67. * - TileMap.
  68. * To enabled set it to 1. Disabled by default.
  69. * @since v0.99.5
  70. */
  71. #ifndef CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
  72. #define CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL 0
  73. #endif
  74. /** @def CC_DIRECTOR_STATS_INTERVAL
  75. * Seconds between FPS updates.
  76. * 0.5 seconds, means that the FPS number will be updated every 0.5 seconds.
  77. * Having a bigger number means a more reliable FPS.
  78. * Default value: 0.5f
  79. */
  80. #ifndef CC_DIRECTOR_STATS_INTERVAL
  81. #define CC_DIRECTOR_STATS_INTERVAL (0.5f)
  82. #endif
  83. /** @def CC_DIRECTOR_FPS_POSITION
  84. * Position of the FPS.
  85. * Default: 0,0 (bottom-left corner).
  86. */
  87. #ifndef CC_DIRECTOR_FPS_POSITION
  88. #define CC_DIRECTOR_FPS_POSITION Vec2(0,0)
  89. #endif
  90. /** @def CC_DIRECTOR_DISPATCH_FAST_EVENTS
  91. * If enabled, and only when it is used with FastDirector, the main loop will wait 0.04 seconds to
  92. * dispatch all the events, even if there are not events to dispatch.
  93. * If your game uses lot's of events (eg: touches) it might be a good idea to enable this feature.
  94. * Otherwise, it is safe to leave it disabled.
  95. * To enable set it to 1. Disabled by default.
  96. * @warning This feature is experimental.
  97. */
  98. #ifndef CC_DIRECTOR_DISPATCH_FAST_EVENTS
  99. #define CC_DIRECTOR_DISPATCH_FAST_EVENTS 0
  100. #endif
  101. /** @def CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
  102. * If enabled, cocos2d-mac will run on the Display Link thread. If disabled cocos2d-mac will run in its own thread.
  103. * If enabled, the images will be drawn at the "correct" time, but the events might not be very responsive.
  104. * If disabled, some frames might be skipped, but the events will be dispatched as they arrived.
  105. * To enable set it to a 1, to disable it set to 0. Enabled by default.
  106. * Only valid for cocos2d-mac. Not supported on cocos2d-ios.
  107. */
  108. #ifndef CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
  109. #define CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD 1
  110. #endif
  111. /** @def CC_NODE_RENDER_SUBPIXEL
  112. * If enabled, the Node objects (Sprite, Label,etc) will be able to render in subpixels.
  113. * If disabled, integer pixels will be used.
  114. * To enable set it to 1. Enabled by default.
  115. */
  116. #ifndef CC_NODE_RENDER_SUBPIXEL
  117. #define CC_NODE_RENDER_SUBPIXEL 1
  118. #endif
  119. /** @def CC_SPRITEBATCHNODE_RENDER_SUBPIXEL
  120. * If enabled, the Sprite objects rendered with SpriteBatchNode will be able to render in subpixels.
  121. * If disabled, integer pixels will be used.
  122. * To enable set it to 1. Enabled by default.
  123. */
  124. #ifndef CC_SPRITEBATCHNODE_RENDER_SUBPIXEL
  125. #define CC_SPRITEBATCHNODE_RENDER_SUBPIXEL 1
  126. #endif
  127. /** @def CC_TEXTURE_ATLAS_USE_VAO
  128. * By default, TextureAtlas (used by many cocos2d classes) will use VAO (Vertex Array Objects).
  129. * Apple recommends its usage but they might consume a lot of memory, specially if you use many of them.
  130. * So for certain cases, where you might need hundreds of VAO objects, it might be a good idea to disable it.
  131. * To disable it set it to 0. Enabled by default.
  132. * If a device doesn't support VAO though it claims to support should add exceptions list here.
  133. */
  134. #ifndef CC_TEXTURE_ATLAS_USE_VAO
  135. #define CC_TEXTURE_ATLAS_USE_VAO 1
  136. #endif
  137. /** @def CC_USE_LA88_LABELS
  138. * If enabled, it will use LA88 (Luminance Alpha 16-bit textures) for LabelTTF objects.
  139. * If it is disabled, it will use A8 (Alpha 8-bit textures).
  140. * LA88 textures are 6% faster than A8 textures, but they will consume 2x memory.
  141. * This feature is enabled by default.
  142. * @since v0.99.5
  143. */
  144. #ifndef CC_USE_LA88_LABELS
  145. #define CC_USE_LA88_LABELS 1
  146. #endif
  147. /** @def CC_SPRITE_DEBUG_DRAW
  148. * If enabled, all subclasses of Sprite will draw a bounding box.
  149. * Useful for debugging purposes only. It is recommended to leave it disabled.
  150. * To enable set it to a value different than 0. Disabled by default:
  151. * 0 -- disabled
  152. * 1 -- draw bounding box
  153. * 2 -- draw texture box
  154. */
  155. #ifndef CC_SPRITE_DEBUG_DRAW
  156. #define CC_SPRITE_DEBUG_DRAW 0
  157. #endif
  158. /** @def CC_LABEL_DEBUG_DRAW
  159. * If enabled, all subclasses of Label will draw a bounding box.
  160. * Useful for debugging purposes only. It is recommended to leave it disabled.
  161. * To enable set it to a value different than 0. Disabled by default:
  162. * 0 -- disabled
  163. * 1 -- draw bounding box
  164. */
  165. #ifndef CC_LABEL_DEBUG_DRAW
  166. #define CC_LABEL_DEBUG_DRAW 0
  167. #endif
  168. /** @def CC_SPRITEBATCHNODE_DEBUG_DRAW
  169. * If enabled, all subclasses of Sprite that are rendered using an SpriteBatchNode draw a bounding box.
  170. * Useful for debugging purposes only. It is recommended to leave it disabled.
  171. * To enable set it to a value different than 0. Disabled by default.
  172. */
  173. #ifndef CC_SPRITEBATCHNODE_DEBUG_DRAW
  174. #define CC_SPRITEBATCHNODE_DEBUG_DRAW 0
  175. #endif
  176. /** @def CC_LABELBMFONT_DEBUG_DRAW
  177. * If enabled, all subclasses of LabelBMFont will draw a bounding box.
  178. * Useful for debugging purposes only. It is recommended to leave it disabled.
  179. * To enable set it to a value different than 0. Disabled by default.
  180. */
  181. #ifndef CC_LABELBMFONT_DEBUG_DRAW
  182. #define CC_LABELBMFONT_DEBUG_DRAW 0
  183. #endif
  184. /** @def CC_LABELATLAS_DEBUG_DRAW
  185. * If enabled, all subclasses of LabeltAtlas will draw a bounding box
  186. * Useful for debugging purposes only. It is recommended to leave it disabled.
  187. * To enable set it to a value different than 0. Disabled by default.
  188. */
  189. #ifndef CC_LABELATLAS_DEBUG_DRAW
  190. #define CC_LABELATLAS_DEBUG_DRAW 0
  191. #endif
  192. /** @def CC_NODE_DEBUG_VERIFY_EVENT_LISTENERS
  193. * If enabled (in conjunction with assertion macros) will verify on Node destruction that the node being destroyed has no event
  194. * listeners still associated with it in the event dispatcher. This can be used to track down problems where the event dispatch
  195. * system has dangling pointers to destroyed nodes.
  196. * Note: event listener verification will always be disabled in builds where assertions are disabled regardless of this setting.
  197. */
  198. #ifndef CC_NODE_DEBUG_VERIFY_EVENT_LISTENERS
  199. #define CC_NODE_DEBUG_VERIFY_EVENT_LISTENERS 0
  200. #endif
  201. /** @def CC_ENABLE_PROFILERS
  202. * If enabled, will activate various profilers within cocos2d. This statistical data will be output to the console
  203. * once per second showing average time (in milliseconds) required to execute the specific routine(s).
  204. * Useful for debugging purposes only. It is recommended to leave it disabled.
  205. * To enable set it to a value different than 0. Disabled by default.
  206. */
  207. #ifndef CC_ENABLE_PROFILERS
  208. #define CC_ENABLE_PROFILERS 0
  209. #endif
  210. /** Enable Lua engine debug log. */
  211. #ifndef CC_LUA_ENGINE_DEBUG
  212. #define CC_LUA_ENGINE_DEBUG 0
  213. #endif
  214. /** Use physics integration API. */
  215. #ifndef CC_USE_PHYSICS
  216. #define CC_USE_PHYSICS 1
  217. #endif
  218. /** Use 3d physics integration API. */
  219. #ifndef CC_USE_3D_PHYSICS
  220. #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX /*|| CC_TARGET_PLATFORM == CC_PLATFORM_WINRT*/)
  221. #define CC_USE_3D_PHYSICS 1
  222. #endif
  223. #endif
  224. #if (CC_USE_3D_PHYSICS)
  225. /** Use bullet physics engine. */
  226. #ifndef CC_ENABLE_BULLET_INTEGRATION
  227. #define CC_ENABLE_BULLET_INTEGRATION 1
  228. #endif
  229. #endif
  230. /** Use 3D navigation API */
  231. #ifndef CC_USE_NAVMESH
  232. #define CC_USE_NAVMESH 1
  233. #endif
  234. /** Use culling or not. */
  235. #ifndef CC_USE_CULLING
  236. #define CC_USE_CULLING 1
  237. #endif
  238. /** Support PNG or not. If your application don't use png format picture, you can undefine this macro to save package size.
  239. */
  240. #ifndef CC_USE_PNG
  241. #define CC_USE_PNG 1
  242. #endif // CC_USE_PNG
  243. /** Support JPEG or not. If your application don't use jpeg format picture, you can undefine this macro to save package size.
  244. */
  245. #ifndef CC_USE_JPEG
  246. #define CC_USE_JPEG 1
  247. #endif // CC_USE_JPEG
  248. /** Support TIFF or not. If your application don't use TIFF format picture, you can undefine this macro to save package size.
  249. */
  250. #ifndef CC_USE_TIFF
  251. #define CC_USE_TIFF 1
  252. #endif // CC_USE_TIFF
  253. /** Support webp or not. If your application don't use webp format picture, you can undefine this macro to save package size.
  254. */
  255. #ifndef CC_USE_WEBP
  256. #if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
  257. #define CC_USE_WEBP 1
  258. #endif
  259. #endif // CC_USE_WEBP
  260. /** Support WIC (Windows Image Component) or not. Replaces PNG, TIFF and JPEG
  261. */
  262. #ifndef CC_USE_WIC
  263. #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
  264. #define CC_USE_WIC 1
  265. #undef CC_USE_TIFF
  266. #undef CC_USE_JPEG
  267. #undef CC_USE_PNG
  268. #endif
  269. #endif // CC_USE_WIC
  270. /** Enable Script binding. */
  271. #ifndef CC_ENABLE_SCRIPT_BINDING
  272. #define CC_ENABLE_SCRIPT_BINDING 1
  273. #endif
  274. /** When CC_ENABLE_SCRIPT_BINDING and CC_ENABLE_GC_FOR_NATIVE_OBJECTS are both 1
  275. * then the Garbage collector will release the native objects, only when the JS/Lua objects
  276. * are collected.
  277. * The benefit is that users don't need to retain/release the JS/Lua objects manually.
  278. * Disabled by default.
  279. */
  280. #ifdef CC_ENABLE_SCRIPT_BINDING
  281. #ifndef CC_ENABLE_GC_FOR_NATIVE_OBJECTS
  282. #define CC_ENABLE_GC_FOR_NATIVE_OBJECTS 0
  283. #endif
  284. #endif
  285. /** @def CC_CONSTRUCTOR_ACCESS
  286. * Indicate the init functions access modifier. If value equals to protected, then these functions are protected.
  287. * If value equals to public, these functions are public,
  288. * protected by default.
  289. */
  290. #ifndef CC_CONSTRUCTOR_ACCESS
  291. #ifdef CC_ENABLE_SCRIPT_BINDING
  292. #define CC_CONSTRUCTOR_ACCESS public
  293. #else
  294. #define CC_CONSTRUCTOR_ACCESS protected
  295. #endif
  296. #endif
  297. /** @def CC_ENABLE_ALLOCATOR
  298. * Turn on creation of global allocator and pool allocators
  299. * as specified by CC_ALLOCATOR_GLOBAL below.
  300. */
  301. #ifndef CC_ENABLE_ALLOCATOR
  302. # define CC_ENABLE_ALLOCATOR 0
  303. #endif
  304. /** @def CC_ENABLE_ALLOCATOR_DIAGNOSTICS
  305. * Turn on debugging of allocators. This is slower, uses
  306. * more memory, and should not be used for production builds.
  307. */
  308. #ifndef CC_ENABLE_ALLOCATOR_DIAGNOSTICS
  309. # define CC_ENABLE_ALLOCATOR_DIAGNOSTICS CC_ENABLE_ALLOCATOR
  310. #endif
  311. /** @def CC_ENABLE_ALLOCATOR_GLOBAL_NEW_DELETE
  312. * Turn on override of global new and delete
  313. * as specified by CC_ALLOCATOR_GLOBAL_NEW_DELETE below.
  314. */
  315. #ifndef CC_ENABLE_ALLOCATOR_GLOBAL_NEW_DELETE
  316. # define CC_ENABLE_ALLOCATOR_GLOBAL_NEW_DELETE 0
  317. # endif//CC_ENABLE_ALLOCATOR_GLOBAL_NEW_DELETE
  318. /** @def CC_ALLOCATOR_GLOBAL
  319. * Specify allocator to use for global allocator.
  320. */
  321. #ifndef CC_ALLOCATOR_GLOBAL
  322. # define CC_ALLOCATOR_GLOBAL cocos2d::allocator::AllocatorStrategyDefault
  323. #endif
  324. /** @def CC_ALLOCATOR_GLOBAL_NEW_DELETE
  325. * Specify allocator to use when overriding of new and delete.
  326. */
  327. #ifndef CC_ALLOCATOR_GLOBAL_NEW_DELETE
  328. # define CC_ALLOCATOR_GLOBAL_NEW_DELETE cocos2d::allocator::AllocatorStrategyGlobalSmallBlock
  329. #endif
  330. #ifndef CC_FILEUTILS_APPLE_ENABLE_OBJC
  331. #define CC_FILEUTILS_APPLE_ENABLE_OBJC 1
  332. #endif
  333. /** @def CC_ENABLE_PREMULTIPLIED_ALPHA
  334. * If enabled, all textures will be preprocessed to multiply its rgb components
  335. * by its alpha component.
  336. */
  337. #ifndef CC_ENABLE_PREMULTIPLIED_ALPHA
  338. # define CC_ENABLE_PREMULTIPLIED_ALPHA 1
  339. #endif
  340. /** @def CC_STRIP_FPS
  341. * Whether to strip FPS related data and functions, such as cc_fps_images_png
  342. */
  343. #ifndef CC_STRIP_FPS
  344. #define CC_STRIP_FPS 0
  345. #endif
  346. #endif // __CCCONFIG_H__