Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | 9x 9x 9x 8x 7x 6x 6x 6x 2x 4x 2x 2x 2x 1x 1x 1x 1x 1x 1x 2x 2x 2x | import Check from "../Core/Check.js";
import Frozen from "../Core/Frozen.js";
import defined from "../Core/defined.js";
import destroyObject from "../Core/destroyObject.js";
import DeveloperError from "../Core/DeveloperError.js";
import Framebuffer from "./Framebuffer.js";
/**
* Creates a multisampling wrapper around two framebuffers with optional initial
* color and depth-stencil attachments. The first framebuffer has multisampled
* renderbuffer attachments and is bound to READ_FRAMEBUFFER during the blit. The
* second is bound to DRAW_FRAMEBUFFER during the blit, and has texture attachments
* to store the copied pixels.
*
* @param {object} options Object with the following properties:
* @param {Context} options.context
* @param {number} options.width
* @param {number} options.height
* @param {Texture[]} [options.colorTextures]
* @param {Renderbuffer[]} [options.colorRenderbuffers]
* @param {Texture} [options.depthStencilTexture]
* @param {Renderbuffer} [options.depthStencilRenderbuffer]
* @param {boolean} [options.destroyAttachments]
*
* @exception {DeveloperError} Both color renderbuffer and texture attachments must be provided.
* @exception {DeveloperError} Both depth-stencil renderbuffer and texture attachments must be provided.
*
* @private
* @constructor
*/
function MultisampleFramebuffer(options) {
options = options ?? Frozen.EMPTY_OBJECT;
const {
context,
width,
height,
colorRenderbuffers,
colorTextures,
depthStencilRenderbuffer,
depthStencilTexture,
destroyAttachments,
} = options;
//>>includeStart('debug', pragmas.debug);
Check.defined("options.context", context);
Check.defined("options.width", width);
Check.defined("options.height", height);
//>>includeEnd('debug');
this._width = width;
this._height = height;
if (defined(colorRenderbuffers) !== defined(colorTextures)) {
throw new DeveloperError(
"Both color renderbuffer and texture attachments must be provided.",
);
}
if (defined(depthStencilRenderbuffer) !== defined(depthStencilTexture)) {
throw new DeveloperError(
"Both depth-stencil renderbuffer and texture attachments must be provided.",
);
}
this._renderFramebuffer = new Framebuffer({
context: context,
colorRenderbuffers: colorRenderbuffers,
depthStencilRenderbuffer: depthStencilRenderbuffer,
destroyAttachments: destroyAttachments,
});
this._colorFramebuffer = new Framebuffer({
context: context,
colorTextures: colorTextures,
depthStencilTexture: depthStencilTexture,
destroyAttachments: destroyAttachments,
});
}
MultisampleFramebuffer.prototype.getRenderFramebuffer = function () {
return this._renderFramebuffer;
};
MultisampleFramebuffer.prototype.getColorFramebuffer = function () {
return this._colorFramebuffer;
};
/**
* Copy from the render framebuffer to the color framebuffer, resolving the stencil.
*
* @param {Context} context
* @param {boolean} blitStencil <code>true</code> if the stencil mask should be applied.
*
* @private
*/
MultisampleFramebuffer.prototype.blitFramebuffers = function (
context,
blitStencil,
) {
this._renderFramebuffer.bindRead();
this._colorFramebuffer.bindDraw();
const gl = context._gl;
let mask = 0;
if (this._colorFramebuffer._colorTextures.length > 0) {
mask |= gl.COLOR_BUFFER_BIT;
}
if (defined(this._colorFramebuffer.depthStencilTexture)) {
mask |= gl.DEPTH_BUFFER_BIT | (blitStencil ? gl.STENCIL_BUFFER_BIT : 0);
}
gl.blitFramebuffer(
0,
0,
this._width,
this._height,
0,
0,
this._width,
this._height,
mask,
gl.NEAREST,
);
gl.bindFramebuffer(gl.READ_FRAMEBUFFER, null);
gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, null);
};
MultisampleFramebuffer.prototype.isDestroyed = function () {
return false;
};
MultisampleFramebuffer.prototype.destroy = function () {
this._renderFramebuffer.destroy();
this._colorFramebuffer.destroy();
return destroyObject(this);
};
export default MultisampleFramebuffer;
|