ccConfig.h 14 KB

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