ccConfig.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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. // disable module if you didn't need it, this will reduce package size
  32. #ifndef USE_GFX_RENDERER
  33. #define USE_GFX_RENDERER 1
  34. #endif
  35. #ifndef USE_VIDEO
  36. #define USE_VIDEO 1
  37. #endif
  38. #ifndef USE_WEB_VIEW
  39. #define USE_WEB_VIEW 1
  40. #endif
  41. #ifndef USE_AUDIO
  42. #define USE_AUDIO 1
  43. #endif
  44. #ifndef USE_SOCKET
  45. #define USE_SOCKET 1
  46. #endif
  47. #ifndef USE_WEBSOCKET_SERVER
  48. #define USE_WEBSOCKET_SERVER 0
  49. #endif
  50. #ifndef USE_MIDDLEWARE
  51. #define USE_MIDDLEWARE 1
  52. #endif
  53. #if USE_GFX_RENDERER > 0 && USE_MIDDLEWARE > 0
  54. #ifndef USE_SPINE
  55. #define USE_SPINE 1
  56. #endif
  57. #ifndef USE_DRAGONBONES
  58. #define USE_DRAGONBONES 1
  59. #endif
  60. #ifndef USE_PARTICLE
  61. #define USE_PARTICLE 1
  62. #endif
  63. #endif // endif middleware
  64. /** @def CC_ENABLE_STACKABLE_ACTIONS
  65. * If enabled, actions that alter the position property (eg: MoveBy, JumpBy, BezierBy, etc..) will be stacked.
  66. * 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.
  67. * If disabled, only the last run action will take effect.
  68. * Enabled by default. Disable to be compatible with v2.0 and older versions.
  69. * @since v2.1
  70. */
  71. #ifndef CC_ENABLE_STACKABLE_ACTIONS
  72. #define CC_ENABLE_STACKABLE_ACTIONS 1
  73. #endif
  74. /** @def CC_ENABLE_GL_STATE_CACHE
  75. * If enabled, cocos2d will maintain an OpenGL state cache internally to avoid unnecessary switches.
  76. * In order to use them, you have to use the following functions, instead of the GL ones:
  77. * - ccGLUseProgram() instead of glUseProgram().
  78. * - GL::deleteProgram() instead of glDeleteProgram().
  79. * - GL::blendFunc() instead of glBlendFunc().
  80. * If this functionality is disabled, then ccGLUseProgram(), GL::deleteProgram(), GL::blendFunc() will call the GL ones, without using the cache.
  81. * It is recommended to enable whenever possible to improve speed.
  82. * 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.
  83. * Default value: Enabled by default
  84. * @since v2.0.0
  85. */
  86. #ifndef CC_ENABLE_GL_STATE_CACHE
  87. #define CC_ENABLE_GL_STATE_CACHE 1
  88. #endif
  89. /** @def CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
  90. * If enabled, the texture coordinates will be calculated by using this formula:
  91. * - texCoord.left = (rect.origin.x*2+1) / (texture.wide*2);
  92. * - texCoord.right = texCoord.left + (rect.size.width*2-2)/(texture.wide*2);
  93. * The same for bottom and top.
  94. * This formula prevents artifacts by using 99% of the texture.
  95. * The "correct" way to prevent artifacts is by using the spritesheet-artifact-fixer.py or a similar tool.
  96. * Affected nodes:
  97. * - Sprite / SpriteBatchNode and subclasses: LabelBMFont.
  98. * - LabelAtlas.
  99. * - QuadParticleSystem.
  100. * To enabled set it to 1. Disabled by default.
  101. * @since v0.99.5
  102. */
  103. #ifndef CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
  104. #define CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL 0
  105. #endif
  106. /** @def CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX
  107. * If enabled, the texture coordinates will be calculated by using this formula:
  108. * - texCoord.left = (rect.origin.x*2+1) / (texture.wide*2);
  109. * - texCoord.right = texCoord.left + (rect.size.width*2-2)/(texture.wide*2);
  110. * The same for bottom and top.
  111. * This formula prevents artifacts by using 99% of the texture.
  112. * The "correct" way to prevent artifacts is by using the spritesheet-artifact-fixer.py or a similar tool.
  113. * Affected nodes:
  114. * - TMXLayer
  115. * To enabled set it to 1. Enabled by default.
  116. * @since Cocos Creator v1.7
  117. */
  118. #ifndef CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX
  119. #define CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL_TMX 1
  120. #endif
  121. /** @def CC_DIRECTOR_STATS_INTERVAL
  122. * Seconds between FPS updates.
  123. * 0.5 seconds, means that the FPS number will be updated every 0.5 seconds.
  124. * Having a bigger number means a more reliable FPS.
  125. * Default value: 0.1f
  126. */
  127. #ifndef CC_DIRECTOR_STATS_INTERVAL
  128. #define CC_DIRECTOR_STATS_INTERVAL (0.1f)
  129. #endif
  130. /** @def CC_DIRECTOR_FPS_POSITION
  131. * Position of the FPS.
  132. * Default: 0,0 (bottom-left corner).
  133. */
  134. #ifndef CC_DIRECTOR_FPS_POSITION
  135. #define CC_DIRECTOR_FPS_POSITION Vec2(0,0)
  136. #endif
  137. /** @def CC_DIRECTOR_DISPATCH_FAST_EVENTS
  138. * If enabled, and only when it is used with FastDirector, the main loop will wait 0.04 seconds to
  139. * dispatch all the events, even if there are not events to dispatch.
  140. * If your game uses lot's of events (eg: touches) it might be a good idea to enable this feature.
  141. * Otherwise, it is safe to leave it disabled.
  142. * To enable set it to 1. Disabled by default.
  143. * @warning This feature is experimental.
  144. */
  145. #ifndef CC_DIRECTOR_DISPATCH_FAST_EVENTS
  146. #define CC_DIRECTOR_DISPATCH_FAST_EVENTS 0
  147. #endif
  148. /** @def CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
  149. * If enabled, cocos2d-mac will run on the Display Link thread. If disabled cocos2d-mac will run in its own thread.
  150. * If enabled, the images will be drawn at the "correct" time, but the events might not be very responsive.
  151. * If disabled, some frames might be skipped, but the events will be dispatched as they arrived.
  152. * To enable set it to a 1, to disable it set to 0. Enabled by default.
  153. * Only valid for cocos2d-mac. Not supported on cocos2d-ios.
  154. */
  155. #ifndef CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD
  156. #define CC_DIRECTOR_MAC_USE_DISPLAY_LINK_THREAD 1
  157. #endif
  158. /** @def CC_NODE_RENDER_SUBPIXEL
  159. * If enabled, the Node objects (Sprite, Label,etc) will be able to render in subpixels.
  160. * If disabled, integer pixels will be used.
  161. * To enable set it to 1. Enabled by default.
  162. */
  163. #ifndef CC_NODE_RENDER_SUBPIXEL
  164. #define CC_NODE_RENDER_SUBPIXEL 1
  165. #endif
  166. /** @def CC_SPRITEBATCHNODE_RENDER_SUBPIXEL
  167. * If enabled, the Sprite objects rendered with SpriteBatchNode will be able to render in subpixels.
  168. * If disabled, integer pixels will be used.
  169. * To enable set it to 1. Enabled by default.
  170. */
  171. #ifndef CC_SPRITEBATCHNODE_RENDER_SUBPIXEL
  172. #define CC_SPRITEBATCHNODE_RENDER_SUBPIXEL 1
  173. #endif
  174. /** @def CC_TEXTURE_ATLAS_USE_VAO
  175. * By default, TextureAtlas (used by many cocos2d classes) will use VAO (Vertex Array Objects).
  176. * Apple recommends its usage but they might consume a lot of memory, specially if you use many of them.
  177. * So for certain cases, where you might need hundreds of VAO objects, it might be a good idea to disable it.
  178. * To disable it set it to 0. Enabled by default.
  179. */
  180. #ifndef CC_TEXTURE_ATLAS_USE_VAO
  181. #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
  182. #define CC_TEXTURE_ATLAS_USE_VAO 1
  183. #else
  184. /* Some Windows display adapter driver cannot support VAO.
  185. * Some android devices cannot support VAO very well, so we disable it by default for android platform.
  186. * Blackberry also doesn't support this feature.
  187. */
  188. #define CC_TEXTURE_ATLAS_USE_VAO 0
  189. #endif
  190. #endif
  191. /** @def CC_USE_LA88_LABELS
  192. * If enabled, it will use LA88 (Luminance Alpha 16-bit textures) for LabelTTF objects.
  193. * If it is disabled, it will use A8 (Alpha 8-bit textures).
  194. * LA88 textures are 6% faster than A8 textures, but they will consume 2x memory.
  195. * This feature is enabled by default.
  196. * @since v0.99.5
  197. */
  198. #ifndef CC_USE_LA88_LABELS
  199. #define CC_USE_LA88_LABELS 1
  200. #endif
  201. /** @def CC_SPRITE_DEBUG_DRAW
  202. * If enabled, all subclasses of Sprite will draw a bounding box.
  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. * 0 -- disabled
  206. * 1 -- draw bounding box
  207. * 2 -- draw texture box
  208. */
  209. #ifndef CC_SPRITE_DEBUG_DRAW
  210. #define CC_SPRITE_DEBUG_DRAW 0
  211. #endif
  212. /** @def CC_LABEL_DEBUG_DRAW
  213. * If enabled, all subclasses of Label will draw a bounding box.
  214. * Useful for debugging purposes only. It is recommended to leave it disabled.
  215. * To enable set it to a value different than 0. Disabled by default:
  216. * 0 -- disabled
  217. * 1 -- draw bounding box
  218. */
  219. #ifndef CC_LABEL_DEBUG_DRAW
  220. #define CC_LABEL_DEBUG_DRAW 0
  221. #endif
  222. /** @def CC_SPRITEBATCHNODE_DEBUG_DRAW
  223. * If enabled, all subclasses of Sprite that are rendered using an SpriteBatchNode draw a bounding box.
  224. * Useful for debugging purposes only. It is recommended to leave it disabled.
  225. * To enable set it to a value different than 0. Disabled by default.
  226. */
  227. #ifndef CC_SPRITEBATCHNODE_DEBUG_DRAW
  228. #define CC_SPRITEBATCHNODE_DEBUG_DRAW 0
  229. #endif
  230. /** @def CC_LABELBMFONT_DEBUG_DRAW
  231. * If enabled, all subclasses of LabelBMFont will draw a bounding box.
  232. * Useful for debugging purposes only. It is recommended to leave it disabled.
  233. * To enable set it to a value different than 0. Disabled by default.
  234. */
  235. #ifndef CC_LABELBMFONT_DEBUG_DRAW
  236. #define CC_LABELBMFONT_DEBUG_DRAW 0
  237. #endif
  238. /** @def CC_LABELATLAS_DEBUG_DRAW
  239. * If enabled, all subclasses of LabeltAtlas will draw a bounding box
  240. * Useful for debugging purposes only. It is recommended to leave it disabled.
  241. * To enable set it to a value different than 0. Disabled by default.
  242. */
  243. #ifndef CC_LABELATLAS_DEBUG_DRAW
  244. #define CC_LABELATLAS_DEBUG_DRAW 0
  245. #endif
  246. /** @def CC_NODE_DEBUG_VERIFY_EVENT_LISTENERS
  247. * If enabled (in conjunction with assertion macros) will verify on Node destruction that the node being destroyed has no event
  248. * listeners still associated with it in the event dispatcher. This can be used to track down problems where the event dispatch
  249. * system has dangling pointers to destroyed nodes.
  250. * Note: event listener verification will always be disabled in builds where assertions are disabled regardless of this setting.
  251. */
  252. #ifndef CC_NODE_DEBUG_VERIFY_EVENT_LISTENERS
  253. #define CC_NODE_DEBUG_VERIFY_EVENT_LISTENERS 0
  254. #endif
  255. /** @def CC_ENABLE_PROFILERS
  256. * If enabled, will activate various profilers within cocos2d. This statistical data will be output to the console
  257. * once per second showing average time (in milliseconds) required to execute the specific routine(s).
  258. * Useful for debugging purposes only. It is recommended to leave it disabled.
  259. * To enable set it to a value different than 0. Disabled by default.
  260. */
  261. #ifndef CC_ENABLE_PROFILERS
  262. #define CC_ENABLE_PROFILERS 0
  263. #endif
  264. /** Enable Lua engine debug log. */
  265. #ifndef CC_LUA_ENGINE_DEBUG
  266. #define CC_LUA_ENGINE_DEBUG 0
  267. #endif
  268. /** Support PNG or not. If your application don't use png format picture, you can undefine this macro to save package size.
  269. */
  270. #ifndef CC_USE_PNG
  271. #define CC_USE_PNG 1
  272. #endif // CC_USE_PNG
  273. /** Support JPEG or not. If your application don't use jpeg format picture, you can undefine this macro to save package size.
  274. */
  275. #ifndef CC_USE_JPEG
  276. #define CC_USE_JPEG 1
  277. #endif // CC_USE_JPEG
  278. /** Support TIFF or not. If your application don't use TIFF format picture, you can undefine this macro to save package size.
  279. */
  280. #ifndef CC_USE_TIFF
  281. #define CC_USE_TIFF 1
  282. #endif // CC_USE_TIFF
  283. /** Support webp or not. If your application don't use webp format picture, you can undefine this macro to save package size.
  284. */
  285. #ifndef CC_USE_WEBP
  286. #if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
  287. #define CC_USE_WEBP 1
  288. #endif
  289. #endif // CC_USE_WEBP
  290. /** Support webp or not. If your application don't use webp format picture, you can undefine this macro to save package size.
  291. */
  292. //#ifndef CC_USE_WEBP
  293. //#if (CC_TARGET_PLATFORM != CC_PLATFORM_WINRT)
  294. //#define CC_USE_WEBP 1
  295. //#endif
  296. //#endif // CC_USE_WEBP
  297. /** Support WIC (Windows Image Component) or not. Replaces PNG, TIFF and JPEG
  298. */
  299. #ifndef CC_USE_WIC
  300. #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
  301. #define CC_USE_WIC 1
  302. #undef CC_USE_TIFF
  303. #undef CC_USE_JPEG
  304. #undef CC_USE_PNG
  305. #endif
  306. #endif // CC_USE_WIC
  307. /** Enable Script binding. */
  308. #ifndef CC_ENABLE_SCRIPT_BINDING
  309. #define CC_ENABLE_SCRIPT_BINDING 1
  310. #endif
  311. /** When CC_ENABLE_SCRIPT_BINDING and CC_ENABLE_GC_FOR_NATIVE_OBJECTS are both 1
  312. then the Garbage collector will release the native objects, only when the JS/Lua objets
  313. are collected.
  314. The benefit is that users don't need to retain/release the JS/Lua objects manually.
  315. By default this behavior is disabled by default
  316. */
  317. #ifdef CC_ENABLE_SCRIPT_BINDING
  318. #ifndef CC_ENABLE_GC_FOR_NATIVE_OBJECTS
  319. #define CC_ENABLE_GC_FOR_NATIVE_OBJECTS 1
  320. #endif
  321. #endif
  322. /** @def CC_CONSTRUCTOR_ACCESS
  323. * Indicate the init functions access modifier. If value equals to protected, then these functions are protected.
  324. * If value equals to public, these functions are public,
  325. * protected by default.
  326. */
  327. #ifndef CC_CONSTRUCTOR_ACCESS
  328. #ifdef CC_ENABLE_SCRIPT_BINDING
  329. #define CC_CONSTRUCTOR_ACCESS public
  330. #else
  331. #define CC_CONSTRUCTOR_ACCESS protected
  332. #endif
  333. #endif
  334. #ifndef CC_FILEUTILS_APPLE_ENABLE_OBJC
  335. #define CC_FILEUTILS_APPLE_ENABLE_OBJC 1
  336. #endif
  337. /** @def CC_ENABLE_PREMULTIPLIED_ALPHA
  338. * If enabled, all textures will be preprocessed to multiply its rgb components
  339. * by its alpha component.
  340. */
  341. #ifndef CC_ENABLE_PREMULTIPLIED_ALPHA
  342. # define CC_ENABLE_PREMULTIPLIED_ALPHA 1
  343. #endif
  344. #ifndef CC_ENABLE_TTF_LABEL_RENDERER
  345. # define CC_ENABLE_TTF_LABEL_RENDERER 1
  346. #endif
  347. #ifndef CC_ENABLE_CACHE_TTF_FONT_TEXTURE
  348. # define CC_ENABLE_CACHE_TTF_FONT_TEXTURE 1
  349. #endif
  350. #endif // __CCCONFIG_H__