Webgl / remove handling of element_index_uint extension
From now on we will assume this extension is always enabled. An error message have been added in the unlikely scenario of a lack of support.
This commit is contained in:
@@ -2,8 +2,7 @@
|
||||
* @module ol/webgl/Buffer
|
||||
*/
|
||||
import {STATIC_DRAW, STREAM_DRAW, DYNAMIC_DRAW} from '../webgl.js';
|
||||
import {includes} from '../array.js';
|
||||
import {ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER, EXTENSIONS as WEBGL_EXTENSIONS} from '../webgl.js';
|
||||
import {ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER} from '../webgl.js';
|
||||
import {assert} from '../asserts.js';
|
||||
|
||||
/**
|
||||
@@ -44,7 +43,7 @@ class WebGLArrayBuffer {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Float32Array|Uint32Array|Uint16Array}
|
||||
* @type {Float32Array|Uint32Array}
|
||||
*/
|
||||
this.array = null;
|
||||
|
||||
@@ -96,7 +95,7 @@ class WebGLArrayBuffer {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Float32Array|Uint32Array|Uint16Array} Array.
|
||||
* @return {Float32Array|Uint32Array} Array.
|
||||
*/
|
||||
getArray() {
|
||||
return this.array;
|
||||
@@ -113,15 +112,14 @@ class WebGLArrayBuffer {
|
||||
/**
|
||||
* Returns a typed array constructor based on the given buffer type
|
||||
* @param {number} type Buffer type, either ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER.
|
||||
* @returns {Float32ArrayConstructor|Uint16ArrayConstructor|Uint32ArrayConstructor} The typed array class to use for this buffer.
|
||||
* @returns {Float32ArrayConstructor|Uint32ArrayConstructor} The typed array class to use for this buffer.
|
||||
*/
|
||||
export function getArrayClassForType(type) {
|
||||
switch (type) {
|
||||
case ARRAY_BUFFER:
|
||||
return Float32Array;
|
||||
case ELEMENT_ARRAY_BUFFER:
|
||||
const hasExtension = includes(WEBGL_EXTENSIONS, 'OES_element_index_uint');
|
||||
return hasExtension ? Uint32Array : Uint16Array;
|
||||
return Uint32Array;
|
||||
default:
|
||||
return Float32Array;
|
||||
}
|
||||
|
||||
+7
-26
@@ -2,12 +2,10 @@
|
||||
* @module ol/webgl/Helper
|
||||
*/
|
||||
import {getUid} from '../util.js';
|
||||
import {EXTENSIONS as WEBGL_EXTENSIONS} from '../webgl.js';
|
||||
import Disposable from '../Disposable.js';
|
||||
import {includes} from '../array.js';
|
||||
import {listen, unlistenAll} from '../events.js';
|
||||
import {clear} from '../obj.js';
|
||||
import {TEXTURE_2D, TEXTURE_WRAP_S, TEXTURE_WRAP_T} from '../webgl.js';
|
||||
import {TEXTURE_2D, TEXTURE_WRAP_S, TEXTURE_WRAP_T, EXTENSIONS as WEBGL_EXTENSIONS} from '../webgl.js';
|
||||
import ContextEventType from '../webgl/ContextEventType.js';
|
||||
import {
|
||||
create as createTransform,
|
||||
@@ -19,6 +17,8 @@ import {
|
||||
import {create, fromTransform} from '../vec/mat4.js';
|
||||
import WebGLPostProcessingPass from './PostProcessingPass.js';
|
||||
import {getContext} from '../webgl.js';
|
||||
import {includes} from '../array.js';
|
||||
import {assert} from '../asserts.js';
|
||||
|
||||
|
||||
/**
|
||||
@@ -258,16 +258,8 @@ class WebGLHelper extends Disposable {
|
||||
*/
|
||||
this.currentProgram_ = null;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
this.hasOESElementIndexUint_ = includes(WEBGL_EXTENSIONS, 'OES_element_index_uint');
|
||||
|
||||
// use the OES_element_index_uint extension if available
|
||||
if (this.hasOESElementIndexUint_) {
|
||||
gl.getExtension('OES_element_index_uint');
|
||||
}
|
||||
assert(includes(WEBGL_EXTENSIONS, 'OES_element_index_uint'), 63);
|
||||
gl.getExtension('OES_element_index_uint');
|
||||
|
||||
listen(this.canvas_, ContextEventType.LOST,
|
||||
this.handleWebGLContextLost, this);
|
||||
@@ -453,9 +445,8 @@ class WebGLHelper extends Disposable {
|
||||
*/
|
||||
drawElements(start, end) {
|
||||
const gl = this.getGL();
|
||||
const elementType = this.hasOESElementIndexUint_ ?
|
||||
gl.UNSIGNED_INT : gl.UNSIGNED_SHORT;
|
||||
const elementSize = this.hasOESElementIndexUint_ ? 4 : 2;
|
||||
const elementType = gl.UNSIGNED_INT;
|
||||
const elementSize = 4;
|
||||
|
||||
const numItems = end - start;
|
||||
const offsetInBytes = start * elementSize;
|
||||
@@ -747,16 +738,6 @@ class WebGLHelper extends Disposable {
|
||||
handleWebGLContextRestored() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the `OES_element_index_uint` WebGL extension is enabled for this context.
|
||||
* @return {boolean} If true, Uint16Array should be used for element array buffers
|
||||
* instead of Uint8Array.
|
||||
* @api
|
||||
*/
|
||||
getElementIndexUintEnabled() {
|
||||
return this.hasOESElementIndexUint_;
|
||||
}
|
||||
|
||||
// TODO: shutdown program
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user