diff --git a/cocos2d/core/CCGame.js b/cocos2d/core/CCGame.js index 4310d0e497..33293f1059 100644 --- a/cocos2d/core/CCGame.js +++ b/cocos2d/core/CCGame.js @@ -720,9 +720,8 @@ var game = { if (cc._renderType === game.RENDER_TYPE_WEBGL) { var opts = { 'stencil': true, - // MSAA is causing serious performance dropdown on some browsers, - // it's temporarily desactivated until we found correct way to let user customize it. - 'antialias': false, + // MSAA is causing serious performance dropdown on some browsers. + 'antialias': cc.macro.ENABLE_WEBGL_ANTIALIAS, 'alpha': cc.macro.ENABLE_TRANSPARENT_CANVAS }; if (isWeChatGame) { diff --git a/cocos2d/core/platform/CCMacro.js b/cocos2d/core/platform/CCMacro.js index cec60923da..d91c3e1129 100644 --- a/cocos2d/core/platform/CCMacro.js +++ b/cocos2d/core/platform/CCMacro.js @@ -1915,6 +1915,28 @@ cc.macro = { * @default false */ ENABLE_TRANSPARENT_CANVAS: false, + + /** + * !#en + * Boolean that indicates if the WebGL context is created with `antialias` option turned on, default value is false. + * Set it to true could make your game graphics slightly smoother, like texture hard edges when rotated. + * Whether to use this really depend on your game design and targeted platform, + * device with retina display usually have good detail on graphics with or without this option, + * you probably don't want antialias if your game style is pixel art based. + * Also, it could have great performance impact with some browser / device using software MSAA. + * You can set it to true before `cc.game.run`. + * Web only. + * !#zh + * 用于设置在创建 WebGL Context 时是否开启 `antialias` 选项,默认值是 false。 + * 将这个选项设置为 true 会让你的游戏画面稍稍平滑一些,比如旋转硬边贴图时的锯齿。是否开启这个选项很大程度上取决于你的游戏和面向的平台。 + * 在大多数拥有 retina 级别屏幕的设备上用户往往无法区分这个选项带来的变化;如果你的游戏选择像素艺术风格,你也多半不会想开启这个选项。 + * 同时,在少部分使用软件级别抗锯齿算法的设备或浏览器上,这个选项会对性能产生比较大的影响。 + * 你可以在 `cc.game.run` 之前设置这个值,否则它不会生效。 + * 仅支持 Web + * @property {Boolean} ENABLE_WEBGL_ANTIALIAS + * @default false + */ + ENABLE_WEBGL_ANTIALIAS: false, }; /** @@ -1930,7 +1952,7 @@ cc.macro = { * @default true */ var ENABLE_CULLING = true; -cc.defineGetterSetter(cc.macro, 'ENABLE_CULLING', +cc.defineGetterSetter(cc.macro, 'ENABLE_CULLING', function () { return ENABLE_CULLING; },