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 | 136x 136x 135x 135x 135x 135x 135x 135x 135x 135x 1x 134x 133x 1x 132x 131x 1x 130x 130x 130x 130x 130x 130x 130x 130x 130x 1x 4x 4x 4x 1x 134x 1x 1x 1x 116x 116x | 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 ContextLimits from "./ContextLimits.js";
import RenderbufferFormat from "./RenderbufferFormat.js";
/**
* @private
*/
function Renderbuffer(options) {
options = options ?? Frozen.EMPTY_OBJECT;
//>>includeStart('debug', pragmas.debug);
Check.defined("options.context", options.context);
//>>includeEnd('debug');
const context = options.context;
const gl = context._gl;
const maximumRenderbufferSize = ContextLimits.maximumRenderbufferSize;
const format = options.format ?? RenderbufferFormat.RGBA4;
const width = defined(options.width)
? options.width
: context.drawingBufferWidth;
const height = defined(options.height)
? options.height
: context.drawingBufferHeight;
const numSamples = options.numSamples ?? 1;
//>>includeStart('debug', pragmas.debug);
if (!RenderbufferFormat.validate(format)) {
throw new DeveloperError("Invalid format.");
}
Check.typeOf.number.greaterThan("width", width, 0);
if (width > maximumRenderbufferSize) {
throw new DeveloperError(
`Width must be less than or equal to the maximum renderbuffer size (${maximumRenderbufferSize}). Check maximumRenderbufferSize.`,
);
}
Check.typeOf.number.greaterThan("height", height, 0);
if (height > maximumRenderbufferSize) {
throw new DeveloperError(
`Height must be less than or equal to the maximum renderbuffer size (${maximumRenderbufferSize}). Check maximumRenderbufferSize.`,
);
}
//>>includeEnd('debug');
this._gl = gl;
this._format = format;
this._width = width;
this._height = height;
this._renderbuffer = this._gl.createRenderbuffer();
gl.bindRenderbuffer(gl.RENDERBUFFER, this._renderbuffer);
Iif (numSamples > 1) {
gl.renderbufferStorageMultisample(
gl.RENDERBUFFER,
numSamples,
format,
width,
height,
);
} else {
gl.renderbufferStorage(gl.RENDERBUFFER, format, width, height);
}
gl.bindRenderbuffer(gl.RENDERBUFFER, null);
}
Object.defineProperties(Renderbuffer.prototype, {
format: {
get: function () {
return this._format;
},
},
width: {
get: function () {
return this._width;
},
},
height: {
get: function () {
return this._height;
},
},
});
Renderbuffer.prototype._getRenderbuffer = function () {
return this._renderbuffer;
};
Renderbuffer.prototype.isDestroyed = function () {
return false;
};
Renderbuffer.prototype.destroy = function () {
this._gl.deleteRenderbuffer(this._renderbuffer);
return destroyObject(this);
};
export default Renderbuffer;
|