Skip to content

Commit

Permalink
Merge pull request cocos#2457 from jareguo/v1.9
Browse files Browse the repository at this point in the history
Add antialias macro, cherry pick from next.
  • Loading branch information
pandamicro authored Mar 21, 2018
2 parents cd8f4d3 + 8cf3e31 commit de515f6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
5 changes: 2 additions & 3 deletions cocos2d/core/CCGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
24 changes: 23 additions & 1 deletion cocos2d/core/platform/CCMacro.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

/**
Expand All @@ -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;
},
Expand Down

0 comments on commit de515f6

Please sign in to comment.