@galacean/engine-rhi-webgl 2.0.0-alpha.2 → 2.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +220 -30
- package/dist/main.js.map +1 -1
- package/dist/module.js +220 -30
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/GLBuffer.d.ts +1 -1
- package/types/GLRenderTarget.d.ts +1 -0
- package/types/GLTransformFeedback.d.ts +1 -0
- package/types/GLTransformFeedbackPrimitive.d.ts +1 -0
- package/types/WebGLGraphicDevice.d.ts +16 -1
package/dist/main.js
CHANGED
|
@@ -290,6 +290,14 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
290
290
|
throw "Buffer is write-only on WebGL1.0 platforms.";
|
|
291
291
|
}
|
|
292
292
|
};
|
|
293
|
+
_proto.copyFromBuffer = function copyFromBuffer(srcBuffer, srcByteOffset, dstByteOffset, byteLength) {
|
|
294
|
+
var gl = this._gl;
|
|
295
|
+
gl.bindBuffer(gl.COPY_READ_BUFFER, srcBuffer._glBuffer);
|
|
296
|
+
gl.bindBuffer(gl.COPY_WRITE_BUFFER, this._glBuffer);
|
|
297
|
+
gl.copyBufferSubData(gl.COPY_READ_BUFFER, gl.COPY_WRITE_BUFFER, srcByteOffset, dstByteOffset, byteLength);
|
|
298
|
+
gl.bindBuffer(gl.COPY_READ_BUFFER, null);
|
|
299
|
+
gl.bindBuffer(gl.COPY_WRITE_BUFFER, null);
|
|
300
|
+
};
|
|
293
301
|
_proto.destroy = function destroy() {
|
|
294
302
|
this._gl.deleteBuffer(this._glBuffer);
|
|
295
303
|
this._gl = null;
|
|
@@ -906,7 +914,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
906
914
|
return {
|
|
907
915
|
internalFormat: isSRGBColorSpace ? gl.SRGB8 : isWebGL2 ? gl.RGB8 : gl.RGB,
|
|
908
916
|
baseFormat: isSRGBColorSpace ? isWebGL2 ? gl.RGB : gl.SRGB8 : gl.RGB,
|
|
909
|
-
readFormat: gl.RGB,
|
|
917
|
+
readFormat: isWebGL2 ? gl.RGBA : gl.RGB,
|
|
910
918
|
dataType: gl.UNSIGNED_BYTE,
|
|
911
919
|
isCompressed: false,
|
|
912
920
|
alignment: 1
|
|
@@ -981,6 +989,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
981
989
|
return {
|
|
982
990
|
internalFormat: gl.R11F_G11F_B10F,
|
|
983
991
|
baseFormat: gl.RGB,
|
|
992
|
+
readFormat: gl.RGBA,
|
|
984
993
|
dataType: gl.FLOAT,
|
|
985
994
|
isCompressed: false,
|
|
986
995
|
alignment: 4
|
|
@@ -1413,11 +1422,6 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1413
1422
|
})) {
|
|
1414
1423
|
throw new Error("MRT+Cube+[,MSAA] is not supported");
|
|
1415
1424
|
}
|
|
1416
|
-
var maxAntiAliasing = rhi.capability.maxAntiAliasing;
|
|
1417
|
-
if (target.antiAliasing > maxAntiAliasing) {
|
|
1418
|
-
engineCore.Logger.warn("MSAA antiAliasing exceeds the limit and is automatically downgraded to:" + maxAntiAliasing);
|
|
1419
|
-
/** @ts-ignore */ target._antiAliasing = maxAntiAliasing;
|
|
1420
|
-
}
|
|
1421
1425
|
this._frameBuffer = this._gl.createFramebuffer();
|
|
1422
1426
|
// bind main FBO
|
|
1423
1427
|
this._bindMainFBO();
|
|
@@ -1507,7 +1511,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1507
1511
|
_proto._bindMainFBO = function _bindMainFBO() {
|
|
1508
1512
|
var gl = this._gl;
|
|
1509
1513
|
var isWebGL2 = this._isWebGL2;
|
|
1510
|
-
/** @ts-ignore */ var _this__target = this._target, _depth = _this__target._depth, colorTextureCount = _this__target.colorTextureCount
|
|
1514
|
+
/** @ts-ignore */ var _this__target = this._target, _depth = _this__target._depth, colorTextureCount = _this__target.colorTextureCount; _this__target.width; _this__target.height;
|
|
1511
1515
|
var drawBuffers = new Array(colorTextureCount);
|
|
1512
1516
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this._frameBuffer);
|
|
1513
1517
|
/** color render buffer */ for(var i = 0; i < colorTextureCount; i++){
|
|
@@ -1529,11 +1533,7 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1529
1533
|
gl.framebufferTexture2D(gl.FRAMEBUFFER, platformTexture._formatDetail.attachment, gl.TEXTURE_2D, platformTexture._glTexture, 0);
|
|
1530
1534
|
} else if (this._target.antiAliasing <= 1) {
|
|
1531
1535
|
var _GLTexture__getRenderBufferDepthFormatDetail = GLTexture._getRenderBufferDepthFormatDetail(_depth, gl, isWebGL2), internalFormat = _GLTexture__getRenderBufferDepthFormatDetail.internalFormat, attachment1 = _GLTexture__getRenderBufferDepthFormatDetail.attachment;
|
|
1532
|
-
|
|
1533
|
-
this._depthRenderBuffer = depthRenderBuffer;
|
|
1534
|
-
gl.bindRenderbuffer(gl.RENDERBUFFER, depthRenderBuffer);
|
|
1535
|
-
gl.renderbufferStorage(gl.RENDERBUFFER, internalFormat, width, height);
|
|
1536
|
-
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment1, gl.RENDERBUFFER, depthRenderBuffer);
|
|
1536
|
+
this._depthRenderBuffer = this._createRenderBuffer(internalFormat, attachment1);
|
|
1537
1537
|
}
|
|
1538
1538
|
}
|
|
1539
1539
|
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
@@ -1542,32 +1542,38 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1542
1542
|
_proto._bindMSAAFBO = function _bindMSAAFBO() {
|
|
1543
1543
|
var gl = this._gl;
|
|
1544
1544
|
var isWebGL2 = this._isWebGL2;
|
|
1545
|
-
var
|
|
1546
|
-
/** @ts-ignore */ var _this__target = this._target, _depth = _this__target._depth, colorTextureCount = _this__target.colorTextureCount, antiAliasing = _this__target.antiAliasing, width = _this__target.width, height = _this__target.height;
|
|
1545
|
+
/** @ts-ignore */ var _this__target = this._target, _depth = _this__target._depth, colorTextureCount = _this__target.colorTextureCount;
|
|
1547
1546
|
this._blitDrawBuffers = new Array(colorTextureCount);
|
|
1548
|
-
this._MSAADepthRenderBuffer = MSAADepthRenderBuffer;
|
|
1549
1547
|
gl.bindFramebuffer(gl.FRAMEBUFFER, this._MSAAFrameBuffer);
|
|
1550
1548
|
// prepare MRT+MSAA color RBOs
|
|
1551
1549
|
for(var i = 0; i < colorTextureCount; i++){
|
|
1552
|
-
var MSAAColorRenderBuffer = gl.createRenderbuffer();
|
|
1553
|
-
this._MSAAColorRenderBuffers[i] = MSAAColorRenderBuffer;
|
|
1554
1550
|
this._blitDrawBuffers[i] = gl.NONE;
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.RENDERBUFFER, MSAAColorRenderBuffer);
|
|
1551
|
+
var internalFormat = /** @ts-ignore */ this._target.getColorTexture(i)._platformTexture._formatDetail.internalFormat;
|
|
1552
|
+
this._MSAAColorRenderBuffers[i] = this._createRenderBuffer(internalFormat, gl.COLOR_ATTACHMENT0 + i);
|
|
1558
1553
|
}
|
|
1559
1554
|
gl.drawBuffers(this._oriDrawBuffers);
|
|
1560
1555
|
// prepare MSAA depth RBO
|
|
1561
1556
|
if (_depth !== null) {
|
|
1562
|
-
var _ref = _instanceof(_depth, engineCore.Texture) ? /** @ts-ignore */ _depth._platformTexture._formatDetail : GLTexture._getRenderBufferDepthFormatDetail(_depth, gl, isWebGL2),
|
|
1563
|
-
|
|
1564
|
-
gl.renderbufferStorageMultisample(gl.RENDERBUFFER, antiAliasing, internalFormat, width, height);
|
|
1565
|
-
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, MSAADepthRenderBuffer);
|
|
1557
|
+
var _ref = _instanceof(_depth, engineCore.Texture) ? /** @ts-ignore */ _depth._platformTexture._formatDetail : GLTexture._getRenderBufferDepthFormatDetail(_depth, gl, isWebGL2), internalFormat1 = _ref.internalFormat, attachment = _ref.attachment;
|
|
1558
|
+
this._MSAADepthRenderBuffer = this._createRenderBuffer(internalFormat1, attachment);
|
|
1566
1559
|
}
|
|
1567
1560
|
this._checkFrameBuffer();
|
|
1568
1561
|
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
1569
1562
|
gl.bindRenderbuffer(gl.RENDERBUFFER, null);
|
|
1570
1563
|
};
|
|
1564
|
+
_proto._createRenderBuffer = function _createRenderBuffer(internalFormat, attachment) {
|
|
1565
|
+
var gl = this._gl;
|
|
1566
|
+
var _this__target = this._target, width = _this__target.width, height = _this__target.height, antiAliasing = _this__target.antiAliasing;
|
|
1567
|
+
var renderBuffer = gl.createRenderbuffer();
|
|
1568
|
+
gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer);
|
|
1569
|
+
if (antiAliasing > 1) {
|
|
1570
|
+
gl.renderbufferStorageMultisample(gl.RENDERBUFFER, antiAliasing, internalFormat, width, height);
|
|
1571
|
+
} else {
|
|
1572
|
+
gl.renderbufferStorage(gl.RENDERBUFFER, internalFormat, width, height);
|
|
1573
|
+
}
|
|
1574
|
+
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, renderBuffer);
|
|
1575
|
+
return renderBuffer;
|
|
1576
|
+
};
|
|
1571
1577
|
_proto._checkFrameBuffer = function _checkFrameBuffer() {
|
|
1572
1578
|
var gl = this._gl;
|
|
1573
1579
|
var e = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
|
|
@@ -1685,12 +1691,12 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1685
1691
|
height = height || Math.max(1, this._texture.height >> mipLevel) - y;
|
|
1686
1692
|
length = length || this._texture.length;
|
|
1687
1693
|
this._bind();
|
|
1688
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
|
|
1689
|
-
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
|
|
1690
|
-
gl.pixelStorei(gl.UNPACK_ALIGNMENT, formatDetail.alignment);
|
|
1691
1694
|
if (isCompressed) {
|
|
1692
1695
|
gl.compressedTexSubImage3D(target, mipLevel, x, y, offsetIndex, width, height, length, internalFormat, colorBuffer);
|
|
1693
1696
|
} else {
|
|
1697
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
|
|
1698
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
|
|
1699
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, formatDetail.alignment);
|
|
1694
1700
|
gl.texSubImage3D(target, mipLevel, x, y, offsetIndex, width, height, length, baseFormat, dataType, colorBuffer);
|
|
1695
1701
|
}
|
|
1696
1702
|
};
|
|
@@ -1765,9 +1771,6 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1765
1771
|
width = width || mipSize - x;
|
|
1766
1772
|
height = height || mipSize - y;
|
|
1767
1773
|
this._bind();
|
|
1768
|
-
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
|
|
1769
|
-
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
|
|
1770
|
-
gl.pixelStorei(gl.UNPACK_ALIGNMENT, formatDetail.alignment);
|
|
1771
1774
|
if (isCompressed) {
|
|
1772
1775
|
var mipBit = 1 << mipLevel;
|
|
1773
1776
|
if (isWebGL2 || this._compressedFaceFilled[face] & mipBit) {
|
|
@@ -1777,6 +1780,9 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1777
1780
|
this._compressedFaceFilled[face] |= mipBit;
|
|
1778
1781
|
}
|
|
1779
1782
|
} else {
|
|
1783
|
+
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
|
|
1784
|
+
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
|
|
1785
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, formatDetail.alignment);
|
|
1780
1786
|
gl.texSubImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, mipLevel, x, y, width, height, baseFormat, dataType, colorBuffer);
|
|
1781
1787
|
}
|
|
1782
1788
|
};
|
|
@@ -1801,6 +1807,159 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1801
1807
|
return GLTextureCube;
|
|
1802
1808
|
}(GLTexture);
|
|
1803
1809
|
|
|
1810
|
+
/**
|
|
1811
|
+
* @internal
|
|
1812
|
+
* WebGL2 implementation of Transform Feedback.
|
|
1813
|
+
*/ var GLTransformFeedback = /*#__PURE__*/ function() {
|
|
1814
|
+
function GLTransformFeedback(rhi) {
|
|
1815
|
+
var gl = rhi.gl;
|
|
1816
|
+
this._gl = gl;
|
|
1817
|
+
this._glTransformFeedback = gl.createTransformFeedback();
|
|
1818
|
+
}
|
|
1819
|
+
var _proto = GLTransformFeedback.prototype;
|
|
1820
|
+
_proto.bindBufferRange = function bindBufferRange(index, buffer, byteOffset, byteSize) {
|
|
1821
|
+
var gl = this._gl;
|
|
1822
|
+
gl.bindBufferRange(gl.TRANSFORM_FEEDBACK_BUFFER, index, buffer._glBuffer, byteOffset, byteSize);
|
|
1823
|
+
};
|
|
1824
|
+
_proto.unbindBuffer = function unbindBuffer(index) {
|
|
1825
|
+
var gl = this._gl;
|
|
1826
|
+
gl.bindBufferBase(gl.TRANSFORM_FEEDBACK_BUFFER, index, null);
|
|
1827
|
+
};
|
|
1828
|
+
_proto.begin = function begin(primitiveMode) {
|
|
1829
|
+
this._gl.beginTransformFeedback(primitiveMode);
|
|
1830
|
+
};
|
|
1831
|
+
_proto.end = function end() {
|
|
1832
|
+
this._gl.endTransformFeedback();
|
|
1833
|
+
};
|
|
1834
|
+
_proto.bind = function bind() {
|
|
1835
|
+
var gl = this._gl;
|
|
1836
|
+
gl.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, this._glTransformFeedback);
|
|
1837
|
+
};
|
|
1838
|
+
_proto.unbind = function unbind() {
|
|
1839
|
+
var gl = this._gl;
|
|
1840
|
+
gl.bindTransformFeedback(gl.TRANSFORM_FEEDBACK, null);
|
|
1841
|
+
};
|
|
1842
|
+
_proto.destroy = function destroy() {
|
|
1843
|
+
if (this._glTransformFeedback) {
|
|
1844
|
+
this._gl.deleteTransformFeedback(this._glTransformFeedback);
|
|
1845
|
+
this._glTransformFeedback = null;
|
|
1846
|
+
}
|
|
1847
|
+
};
|
|
1848
|
+
return GLTransformFeedback;
|
|
1849
|
+
}();
|
|
1850
|
+
|
|
1851
|
+
function _array_like_to_array(arr, len) {
|
|
1852
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
1853
|
+
|
|
1854
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
1855
|
+
|
|
1856
|
+
return arr2;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
1860
|
+
if (!o) return;
|
|
1861
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
1862
|
+
|
|
1863
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1864
|
+
|
|
1865
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1866
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1867
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
|
|
1871
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
1872
|
+
|
|
1873
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
1874
|
+
// Fallback for engines without symbol support
|
|
1875
|
+
if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
1876
|
+
if (it) o = it;
|
|
1877
|
+
|
|
1878
|
+
var i = 0;
|
|
1879
|
+
|
|
1880
|
+
return function() {
|
|
1881
|
+
if (i >= o.length) return { done: true };
|
|
1882
|
+
|
|
1883
|
+
return { done: false, value: o[i++] };
|
|
1884
|
+
};
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
/**
|
|
1891
|
+
* @internal
|
|
1892
|
+
* WebGL2 implementation of Transform Feedback primitive.
|
|
1893
|
+
* Maintains two VAOs (one per read direction), auto-rebuilds when program changes.
|
|
1894
|
+
*/ var GLTransformFeedbackPrimitive = /*#__PURE__*/ function() {
|
|
1895
|
+
function GLTransformFeedbackPrimitive(gl) {
|
|
1896
|
+
this._lastProgramId = -1;
|
|
1897
|
+
this._gl = gl;
|
|
1898
|
+
}
|
|
1899
|
+
var _proto = GLTransformFeedbackPrimitive.prototype;
|
|
1900
|
+
_proto.updateVertexLayout = function updateVertexLayout(program, readBinding, writeBinding, feedbackElements, inputBinding, inputElements) {
|
|
1901
|
+
if (program.id === this._lastProgramId) return;
|
|
1902
|
+
this._deleteVAOs();
|
|
1903
|
+
var attribs = program.attributeLocation;
|
|
1904
|
+
this._vaoA = this._createVAO(attribs, readBinding, feedbackElements, inputBinding, inputElements);
|
|
1905
|
+
this._vaoB = this._createVAO(attribs, writeBinding, feedbackElements, inputBinding, inputElements);
|
|
1906
|
+
this._lastProgramId = program.id;
|
|
1907
|
+
this._gl.bindVertexArray(null);
|
|
1908
|
+
};
|
|
1909
|
+
_proto.bind = function bind(readIsA) {
|
|
1910
|
+
this._gl.bindVertexArray(readIsA ? this._vaoA : this._vaoB);
|
|
1911
|
+
};
|
|
1912
|
+
_proto.unbind = function unbind() {
|
|
1913
|
+
this._gl.bindVertexArray(null);
|
|
1914
|
+
};
|
|
1915
|
+
_proto.draw = function draw(mode, first, count) {
|
|
1916
|
+
this._gl.drawArrays(mode, first, count);
|
|
1917
|
+
};
|
|
1918
|
+
_proto.invalidate = function invalidate() {
|
|
1919
|
+
this._deleteVAOs();
|
|
1920
|
+
};
|
|
1921
|
+
_proto.destroy = function destroy() {
|
|
1922
|
+
this._deleteVAOs();
|
|
1923
|
+
};
|
|
1924
|
+
_proto._deleteVAOs = function _deleteVAOs() {
|
|
1925
|
+
var gl = this._gl;
|
|
1926
|
+
if (this._vaoA) {
|
|
1927
|
+
gl.deleteVertexArray(this._vaoA);
|
|
1928
|
+
this._vaoA = null;
|
|
1929
|
+
}
|
|
1930
|
+
if (this._vaoB) {
|
|
1931
|
+
gl.deleteVertexArray(this._vaoB);
|
|
1932
|
+
this._vaoB = null;
|
|
1933
|
+
}
|
|
1934
|
+
this._lastProgramId = -1;
|
|
1935
|
+
};
|
|
1936
|
+
_proto._createVAO = function _createVAO(attribs, feedbackBinding, feedbackElements, inputBinding, inputElements) {
|
|
1937
|
+
var gl = this._gl;
|
|
1938
|
+
var vao = gl.createVertexArray();
|
|
1939
|
+
gl.bindVertexArray(vao);
|
|
1940
|
+
// @ts-ignore: Access internal _platformBuffer across packages
|
|
1941
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, feedbackBinding.buffer._platformBuffer._glBuffer);
|
|
1942
|
+
this._bindElements(gl, attribs, feedbackElements, feedbackBinding.stride);
|
|
1943
|
+
// @ts-ignore: Access internal _platformBuffer across packages
|
|
1944
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, inputBinding.buffer._platformBuffer._glBuffer);
|
|
1945
|
+
this._bindElements(gl, attribs, inputElements, inputBinding.stride);
|
|
1946
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
1947
|
+
return vao;
|
|
1948
|
+
};
|
|
1949
|
+
_proto._bindElements = function _bindElements(gl, attribs, elements, stride) {
|
|
1950
|
+
for(var _iterator = _create_for_of_iterator_helper_loose(elements), _step; !(_step = _iterator()).done;){
|
|
1951
|
+
var element = _step.value;
|
|
1952
|
+
var loc = attribs[element.attribute];
|
|
1953
|
+
if (loc !== undefined && loc !== -1) {
|
|
1954
|
+
var info = element._formatMetaInfo;
|
|
1955
|
+
gl.enableVertexAttribArray(loc);
|
|
1956
|
+
gl.vertexAttribPointer(loc, info.size, info.type, info.normalized, stride, element.offset);
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
};
|
|
1960
|
+
return GLTransformFeedbackPrimitive;
|
|
1961
|
+
}();
|
|
1962
|
+
|
|
1804
1963
|
/**
|
|
1805
1964
|
* WebGL mode.
|
|
1806
1965
|
*/ var WebGLMode = /*#__PURE__*/ function(WebGLMode) {
|
|
@@ -1922,6 +2081,37 @@ var GLBuffer = /*#__PURE__*/ function() {
|
|
|
1922
2081
|
if (bufferUsage === void 0) bufferUsage = engineCore.BufferUsage.Static;
|
|
1923
2082
|
return new GLBuffer(this, type, byteLength, bufferUsage, data);
|
|
1924
2083
|
};
|
|
2084
|
+
_proto.createPlatformTransformFeedback = function createPlatformTransformFeedback() {
|
|
2085
|
+
return new GLTransformFeedback(this);
|
|
2086
|
+
};
|
|
2087
|
+
_proto.createPlatformTransformFeedbackPrimitive = function createPlatformTransformFeedbackPrimitive() {
|
|
2088
|
+
return new GLTransformFeedbackPrimitive(this._gl);
|
|
2089
|
+
};
|
|
2090
|
+
/**
|
|
2091
|
+
* Enable GL_RASTERIZER_DISCARD (WebGL2 only).
|
|
2092
|
+
*/ _proto.enableRasterizerDiscard = function enableRasterizerDiscard() {
|
|
2093
|
+
if (this._isWebGL2) {
|
|
2094
|
+
var gl = this._gl;
|
|
2095
|
+
gl.enable(gl.RASTERIZER_DISCARD);
|
|
2096
|
+
}
|
|
2097
|
+
};
|
|
2098
|
+
/**
|
|
2099
|
+
* Disable GL_RASTERIZER_DISCARD (WebGL2 only).
|
|
2100
|
+
*/ _proto.disableRasterizerDiscard = function disableRasterizerDiscard() {
|
|
2101
|
+
if (this._isWebGL2) {
|
|
2102
|
+
var gl = this._gl;
|
|
2103
|
+
gl.disable(gl.RASTERIZER_DISCARD);
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
/**
|
|
2107
|
+
* Invalidate the cached shader program state.
|
|
2108
|
+
* Call this after using a custom program (e.g., Transform Feedback) outside the engine's pipeline.
|
|
2109
|
+
*/ _proto.invalidateShaderProgramState = function invalidateShaderProgramState() {
|
|
2110
|
+
if (this._currentBindShaderProgram) {
|
|
2111
|
+
this._gl.useProgram(null);
|
|
2112
|
+
this._currentBindShaderProgram = null;
|
|
2113
|
+
}
|
|
2114
|
+
};
|
|
1925
2115
|
_proto.requireExtension = function requireExtension(ext) {
|
|
1926
2116
|
return this._extensions.requireExtension(ext);
|
|
1927
2117
|
};
|