mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
Configurable alpha parameter for webgl construction
This commit is contained in:
@@ -672,7 +672,7 @@ var game = {
|
||||
this._renderContext = cc._renderContext = cc.webglContext
|
||||
= cc.create3DContext(localCanvas, {
|
||||
'stencil': true,
|
||||
'alpha': true,
|
||||
'alpha': cc.macro.ENABLE_TRANSPARENT_CANVAS,
|
||||
'antialias': cc.sys.isMobile
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1908,6 +1908,21 @@ cc.macro = {
|
||||
* @default 64
|
||||
*/
|
||||
DOWNLOAD_MAX_CONCURRENT: 64,
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Boolean that indicates if the canvas contains an alpha channel, default sets to false for better performance.
|
||||
* Though if you want to make your canvas background transparent and show other dom elements at the background,
|
||||
* you can set it to true before `cc.game.run`.
|
||||
* Web only.
|
||||
* !#zh
|
||||
* 用于设置 Canvas 背景是否支持 alpha 通道,默认为 false,这样可以有更高的性能表现。
|
||||
* 如果你希望 Canvas 背景是透明的,并显示背后的其他 DOM 元素,你可以在 `cc.game.run` 之前将这个值设为 true。
|
||||
* 仅支持 Web
|
||||
* @property {Boolean} ENABLE_TRANSPARENT_CANVAS
|
||||
* @default false
|
||||
*/
|
||||
ENABLE_TRANSPARENT_CANVAS: false,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -105,14 +105,14 @@ cc.gl.deleteProgram = function (program) {
|
||||
* @param {Number} dfactor
|
||||
*/
|
||||
cc.gl.setBlending = function (sfactor, dfactor) {
|
||||
var ctx = cc._renderContext;
|
||||
if ((sfactor === ctx.ONE) && (dfactor === ctx.ZERO)) {
|
||||
ctx.disable(ctx.BLEND);
|
||||
var gl = cc._renderContext;
|
||||
if ((sfactor === gl.ONE) && (dfactor === gl.ZERO)) {
|
||||
gl.disable(gl.BLEND);
|
||||
} else {
|
||||
ctx.enable(ctx.BLEND);
|
||||
cc._renderContext.blendFunc(sfactor,dfactor);
|
||||
gl.enable(gl.BLEND);
|
||||
gl.blendFunc(sfactor,dfactor);
|
||||
//TODO need fix for WebGL
|
||||
//ctx.blendFuncSeparate(ctx.SRC_ALPHA, dfactor, sfactor, dfactor);
|
||||
// gl.blendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user