ol/webgl exports

This commit is contained in:
raiyni
2018-02-15 21:39:53 -06:00
parent 3d4883f332
commit 1674eba2cd
14 changed files with 133 additions and 130 deletions

View File

@@ -11,7 +11,7 @@ import {fragment, vertex} from '../webgl/circlereplay/defaultshader.js';
import Locations from '../webgl/circlereplay/defaultshader/Locations.js';
import WebGLReplay from '../webgl/Replay.js';
import _ol_render_webgl_ from '../webgl.js';
import _ol_webgl_ from '../../webgl.js';
import {FLOAT} from '../../webgl.js';
import WebGLBuffer from '../../webgl/Buffer.js';
/**
@@ -211,15 +211,15 @@ WebGLCircleReplay.prototype.setUpProgram = function(gl, context, size, pixelRati
// enable the vertex attrib arrays
gl.enableVertexAttribArray(locations.a_position);
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
gl.vertexAttribPointer(locations.a_position, 2, FLOAT,
false, 16, 0);
gl.enableVertexAttribArray(locations.a_instruction);
gl.vertexAttribPointer(locations.a_instruction, 1, _ol_webgl_.FLOAT,
gl.vertexAttribPointer(locations.a_instruction, 1, FLOAT,
false, 16, 8);
gl.enableVertexAttribArray(locations.a_radius);
gl.vertexAttribPointer(locations.a_radius, 1, _ol_webgl_.FLOAT,
gl.vertexAttribPointer(locations.a_radius, 1, FLOAT,
false, 16, 12);
// Enable renderer specific uniforms.

View File

@@ -13,7 +13,7 @@ import _ol_render_webgl_ from '../webgl.js';
import WebGLReplay from '../webgl/Replay.js';
import {fragment, vertex} from '../webgl/linestringreplay/defaultshader.js';
import Locations from '../webgl/linestringreplay/defaultshader/Locations.js';
import _ol_webgl_ from '../../webgl.js';
import {FLOAT} from '../../webgl.js';
import WebGLBuffer from '../../webgl/Buffer.js';
@@ -471,19 +471,19 @@ WebGLLineStringReplay.prototype.setUpProgram = function(gl, context, size, pixel
// enable the vertex attrib arrays
gl.enableVertexAttribArray(locations.a_lastPos);
gl.vertexAttribPointer(locations.a_lastPos, 2, _ol_webgl_.FLOAT,
gl.vertexAttribPointer(locations.a_lastPos, 2, FLOAT,
false, 28, 0);
gl.enableVertexAttribArray(locations.a_position);
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
gl.vertexAttribPointer(locations.a_position, 2, FLOAT,
false, 28, 8);
gl.enableVertexAttribArray(locations.a_nextPos);
gl.vertexAttribPointer(locations.a_nextPos, 2, _ol_webgl_.FLOAT,
gl.vertexAttribPointer(locations.a_nextPos, 2, FLOAT,
false, 28, 16);
gl.enableVertexAttribArray(locations.a_direction);
gl.vertexAttribPointer(locations.a_direction, 1, _ol_webgl_.FLOAT,
gl.vertexAttribPointer(locations.a_direction, 1, FLOAT,
false, 28, 24);
// Enable renderer specific uniforms.

View File

@@ -17,7 +17,7 @@ import _ol_render_webgl_ from '../webgl.js';
import Stroke from '../../style/Stroke.js';
import LinkedList from '../../structs/LinkedList.js';
import RBush from '../../structs/RBush.js';
import _ol_webgl_ from '../../webgl.js';
import {FLOAT} from '../../webgl.js';
import WebGLBuffer from '../../webgl/Buffer.js';
/**
@@ -888,7 +888,7 @@ WebGLPolygonReplay.prototype.setUpProgram = function(gl, context, size, pixelRat
// enable the vertex attrib arrays
gl.enableVertexAttribArray(locations.a_position);
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
gl.vertexAttribPointer(locations.a_position, 2, FLOAT,
false, 8, 0);
return locations;

View File

@@ -12,7 +12,8 @@ import {
translate as translateTransform
} from '../../transform.js';
import {create, fromTransform} from '../../vec/mat4.js';
import _ol_webgl_ from '../../webgl.js';
import {ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER, TRIANGLES,
UNSIGNED_INT, UNSIGNED_SHORT} from '../../webgl.js';
/**
* @constructor
@@ -293,9 +294,9 @@ WebGLReplay.prototype.replay = function(context,
gl.stencilFunc(gl.NOTEQUAL, 1, 255);
}
context.bindBuffer(_ol_webgl_.ARRAY_BUFFER, this.verticesBuffer);
context.bindBuffer(ARRAY_BUFFER, this.verticesBuffer);
context.bindBuffer(_ol_webgl_.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
context.bindBuffer(ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
const locations = this.setUpProgram(gl, context, size, pixelRatio);
@@ -359,11 +360,11 @@ WebGLReplay.prototype.replay = function(context,
WebGLReplay.prototype.drawElements = function(
gl, context, start, end) {
const elementType = context.hasOESElementIndexUint ?
_ol_webgl_.UNSIGNED_INT : _ol_webgl_.UNSIGNED_SHORT;
UNSIGNED_INT : UNSIGNED_SHORT;
const elementSize = context.hasOESElementIndexUint ? 4 : 2;
const numItems = end - start;
const offsetInBytes = start * elementSize;
gl.drawElements(_ol_webgl_.TRIANGLES, numItems, elementType, offsetInBytes);
gl.drawElements(TRIANGLES, numItems, elementType, offsetInBytes);
};
export default WebGLReplay;

View File

@@ -7,7 +7,7 @@ import {isEmpty} from '../../obj.js';
import {fragment, vertex} from '../webgl/texturereplay/defaultshader.js';
import Locations from '../webgl/texturereplay/defaultshader/Locations.js';
import WebGLReplay from '../webgl/Replay.js';
import _ol_webgl_ from '../../webgl.js';
import {CLAMP_TO_EDGE, FLOAT, TEXTURE_2D} from '../../webgl.js';
import {createTexture} from '../../webgl/Context.js';
/**
@@ -258,7 +258,7 @@ WebGLTextureReplay.prototype.createTextures = function(textures, images, texture
texture = texturePerImage[uid];
} else {
texture = createTexture(
gl, image, _ol_webgl_.CLAMP_TO_EDGE, _ol_webgl_.CLAMP_TO_EDGE);
gl, image, CLAMP_TO_EDGE, CLAMP_TO_EDGE);
texturePerImage[uid] = texture;
}
textures[i] = texture;
@@ -287,23 +287,23 @@ WebGLTextureReplay.prototype.setUpProgram = function(gl, context, size, pixelRat
// enable the vertex attrib arrays
gl.enableVertexAttribArray(locations.a_position);
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
gl.vertexAttribPointer(locations.a_position, 2, FLOAT,
false, 32, 0);
gl.enableVertexAttribArray(locations.a_offsets);
gl.vertexAttribPointer(locations.a_offsets, 2, _ol_webgl_.FLOAT,
gl.vertexAttribPointer(locations.a_offsets, 2, FLOAT,
false, 32, 8);
gl.enableVertexAttribArray(locations.a_texCoord);
gl.vertexAttribPointer(locations.a_texCoord, 2, _ol_webgl_.FLOAT,
gl.vertexAttribPointer(locations.a_texCoord, 2, FLOAT,
false, 32, 16);
gl.enableVertexAttribArray(locations.a_opacity);
gl.vertexAttribPointer(locations.a_opacity, 1, _ol_webgl_.FLOAT,
gl.vertexAttribPointer(locations.a_opacity, 1, FLOAT,
false, 32, 24);
gl.enableVertexAttribArray(locations.a_rotateWithView);
gl.vertexAttribPointer(locations.a_rotateWithView, 1, _ol_webgl_.FLOAT,
gl.vertexAttribPointer(locations.a_rotateWithView, 1, FLOAT,
false, 32, 28);
return locations;
@@ -334,7 +334,7 @@ WebGLTextureReplay.prototype.drawReplay = function(gl, context, skippedFeaturesH
} else {
let i, ii, start;
for (i = 0, ii = textures.length, start = 0; i < ii; ++i) {
gl.bindTexture(_ol_webgl_.TEXTURE_2D, textures[i]);
gl.bindTexture(TEXTURE_2D, textures[i]);
const end = groupIndices[i];
this.drawElements(gl, context, start, end);
start = end;
@@ -375,7 +375,7 @@ WebGLTextureReplay.prototype.drawReplaySkipping = function(gl, context, skippedF
let i, ii;
for (i = 0, ii = textures.length; i < ii; ++i) {
gl.bindTexture(_ol_webgl_.TEXTURE_2D, textures[i]);
gl.bindTexture(TEXTURE_2D, textures[i]);
const groupStart = (i > 0) ? groupIndices[i - 1] : 0;
const groupEnd = groupIndices[i];
@@ -422,7 +422,7 @@ WebGLTextureReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, conte
let featureIndex = this.startIndices.length - 1;
const hitDetectionTextures = this.getHitDetectionTextures();
for (i = hitDetectionTextures.length - 1; i >= 0; --i) {
gl.bindTexture(_ol_webgl_.TEXTURE_2D, hitDetectionTextures[i]);
gl.bindTexture(TEXTURE_2D, hitDetectionTextures[i]);
groupStart = (i > 0) ? this.hitDetectionGroupIndices[i - 1] : 0;
end = this.hitDetectionGroupIndices[i];

View File

@@ -20,7 +20,7 @@ import {
invert as invertTransform,
multiply as multiplyTransform
} from '../../transform.js';
import _ol_webgl_ from '../../webgl.js';
import {CLAMP_TO_EDGE} from '../../webgl.js';
import {createTexture} from '../../webgl/Context.js';
/**
@@ -98,7 +98,7 @@ WebGLImageLayerRenderer.prototype.createTexture_ = function(image) {
const gl = this.mapRenderer.getGL();
return createTexture(
gl, imageElement, _ol_webgl_.CLAMP_TO_EDGE, _ol_webgl_.CLAMP_TO_EDGE);
gl, imageElement, CLAMP_TO_EDGE, CLAMP_TO_EDGE);
};

View File

@@ -10,7 +10,8 @@ import {fragment, vertex} from '../webgl/defaultmapshader.js';
import Locations from '../webgl/defaultmapshader/Locations.js';
import {create as createTransform} from '../../transform.js';
import {create, fromTransform} from '../../vec/mat4.js';
import _ol_webgl_ from '../../webgl.js';
import {ARRAY_BUFFER, FRAMEBUFFER, FLOAT, TEXTURE_2D,
TRIANGLE_STRIP, COLOR_ATTACHMENT0} from '../../webgl.js';
import WebGLBuffer from '../../webgl/Buffer.js';
import {createEmptyTexture} from '../../webgl/Context.js';
@@ -120,16 +121,16 @@ WebGLLayerRenderer.prototype.bindFramebuffer = function(frameState, framebufferD
gl, framebufferDimension, framebufferDimension);
const framebuffer = gl.createFramebuffer();
gl.bindFramebuffer(_ol_webgl_.FRAMEBUFFER, framebuffer);
gl.framebufferTexture2D(_ol_webgl_.FRAMEBUFFER,
_ol_webgl_.COLOR_ATTACHMENT0, _ol_webgl_.TEXTURE_2D, texture, 0);
gl.bindFramebuffer(FRAMEBUFFER, framebuffer);
gl.framebufferTexture2D(FRAMEBUFFER,
COLOR_ATTACHMENT0, TEXTURE_2D, texture, 0);
this.texture = texture;
this.framebuffer = framebuffer;
this.framebufferDimension = framebufferDimension;
} else {
gl.bindFramebuffer(_ol_webgl_.FRAMEBUFFER, this.framebuffer);
gl.bindFramebuffer(FRAMEBUFFER, this.framebuffer);
}
};
@@ -144,7 +145,7 @@ WebGLLayerRenderer.prototype.composeFrame = function(frameState, layerState, con
this.dispatchComposeEvent_(RenderEventType.PRECOMPOSE, context, frameState);
context.bindBuffer(_ol_webgl_.ARRAY_BUFFER, this.arrayBuffer_);
context.bindBuffer(ARRAY_BUFFER, this.arrayBuffer_);
const gl = context.getGL();
@@ -161,10 +162,10 @@ WebGLLayerRenderer.prototype.composeFrame = function(frameState, layerState, con
if (context.useProgram(program)) {
gl.enableVertexAttribArray(locations.a_position);
gl.vertexAttribPointer(
locations.a_position, 2, _ol_webgl_.FLOAT, false, 16, 0);
locations.a_position, 2, FLOAT, false, 16, 0);
gl.enableVertexAttribArray(locations.a_texCoord);
gl.vertexAttribPointer(
locations.a_texCoord, 2, _ol_webgl_.FLOAT, false, 16, 8);
locations.a_texCoord, 2, FLOAT, false, 16, 8);
gl.uniform1i(locations.u_texture, 0);
}
@@ -173,8 +174,8 @@ WebGLLayerRenderer.prototype.composeFrame = function(frameState, layerState, con
gl.uniformMatrix4fv(locations.u_projectionMatrix, false,
fromTransform(this.tmpMat4_, this.getProjectionMatrix()));
gl.uniform1f(locations.u_opacity, layerState.opacity);
gl.bindTexture(_ol_webgl_.TEXTURE_2D, this.getTexture());
gl.drawArrays(_ol_webgl_.TRIANGLE_STRIP, 0, 4);
gl.bindTexture(TEXTURE_2D, this.getTexture());
gl.drawArrays(TRIANGLE_STRIP, 0, 4);
this.dispatchComposeEvent_(RenderEventType.POSTCOMPOSE, context, frameState);
};

View File

@@ -17,7 +17,10 @@ import RendererType from '../Type.js';
import SourceState from '../../source/State.js';
import LRUCache from '../../structs/LRUCache.js';
import PriorityQueue from '../../structs/PriorityQueue.js';
import _ol_webgl_ from '../../webgl.js';
import {BLEND, CLAMP_TO_EDGE, COLOR_BUFFER_BIT, CULL_FACE, DEPTH_TEST, FRAMEBUFFER,
getContext, LINEAR, ONE, ONE_MINUS_SRC_ALPHA, RGBA, SCISSOR_TEST, SRC_ALPHA,
STENCIL_TEST, TEXTURE0, TEXTURE_2D, TEXTURE_MAG_FILTER, TEXTURE_MIN_FILTER,
TEXTURE_WRAP_S, TEXTURE_WRAP_T, UNSIGNED_BYTE} from '../../webgl.js';
import WebGLContext from '../../webgl/Context.js';
import ContextEventType from '../../webgl/ContextEventType.js';
@@ -79,7 +82,7 @@ const WebGLMapRenderer = function(container, map) {
* @private
* @type {WebGLRenderingContext}
*/
this.gl_ = _ol_webgl_.getContext(this.canvas_, {
this.gl_ = getContext(this.canvas_, {
antialias: true,
depth: true,
failIfMajorPerformanceCaveat: true,
@@ -152,7 +155,7 @@ const WebGLMapRenderer = function(container, map) {
const tileSize = /** @type {ol.Size} */ (element[3]);
const tileGutter = /** @type {number} */ (element[4]);
this.bindTileTexture(
tile, tileSize, tileGutter, _ol_webgl_.LINEAR, _ol_webgl_.LINEAR);
tile, tileSize, tileGutter, LINEAR, LINEAR);
}
return false;
}.bind(this);
@@ -203,20 +206,20 @@ WebGLMapRenderer.prototype.bindTileTexture = function(tile, tileSize, tileGutter
const tileKey = tile.getKey();
if (this.textureCache_.containsKey(tileKey)) {
const textureCacheEntry = this.textureCache_.get(tileKey);
gl.bindTexture(_ol_webgl_.TEXTURE_2D, textureCacheEntry.texture);
gl.bindTexture(TEXTURE_2D, textureCacheEntry.texture);
if (textureCacheEntry.magFilter != magFilter) {
gl.texParameteri(
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MAG_FILTER, magFilter);
TEXTURE_2D, TEXTURE_MAG_FILTER, magFilter);
textureCacheEntry.magFilter = magFilter;
}
if (textureCacheEntry.minFilter != minFilter) {
gl.texParameteri(
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MIN_FILTER, minFilter);
TEXTURE_2D, TEXTURE_MIN_FILTER, minFilter);
textureCacheEntry.minFilter = minFilter;
}
} else {
const texture = gl.createTexture();
gl.bindTexture(_ol_webgl_.TEXTURE_2D, texture);
gl.bindTexture(TEXTURE_2D, texture);
if (tileGutter > 0) {
const clipTileCanvas = this.clipTileContext_.canvas;
const clipTileContext = this.clipTileContext_;
@@ -231,22 +234,22 @@ WebGLMapRenderer.prototype.bindTileTexture = function(tile, tileSize, tileGutter
}
clipTileContext.drawImage(tile.getImage(), tileGutter, tileGutter,
tileSize[0], tileSize[1], 0, 0, tileSize[0], tileSize[1]);
gl.texImage2D(_ol_webgl_.TEXTURE_2D, 0,
_ol_webgl_.RGBA, _ol_webgl_.RGBA,
_ol_webgl_.UNSIGNED_BYTE, clipTileCanvas);
gl.texImage2D(TEXTURE_2D, 0,
RGBA, RGBA,
UNSIGNED_BYTE, clipTileCanvas);
} else {
gl.texImage2D(_ol_webgl_.TEXTURE_2D, 0,
_ol_webgl_.RGBA, _ol_webgl_.RGBA,
_ol_webgl_.UNSIGNED_BYTE, tile.getImage());
gl.texImage2D(TEXTURE_2D, 0,
RGBA, RGBA,
UNSIGNED_BYTE, tile.getImage());
}
gl.texParameteri(
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MAG_FILTER, magFilter);
TEXTURE_2D, TEXTURE_MAG_FILTER, magFilter);
gl.texParameteri(
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MIN_FILTER, minFilter);
gl.texParameteri(_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_S,
_ol_webgl_.CLAMP_TO_EDGE);
gl.texParameteri(_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_T,
_ol_webgl_.CLAMP_TO_EDGE);
TEXTURE_2D, TEXTURE_MIN_FILTER, minFilter);
gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S,
CLAMP_TO_EDGE);
gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T,
CLAMP_TO_EDGE);
this.textureCache_.set(tileKey, {
texture: texture,
magFilter: magFilter,
@@ -394,14 +397,14 @@ WebGLMapRenderer.prototype.handleWebGLContextRestored = function() {
*/
WebGLMapRenderer.prototype.initializeGL_ = function() {
const gl = this.gl_;
gl.activeTexture(_ol_webgl_.TEXTURE0);
gl.activeTexture(TEXTURE0);
gl.blendFuncSeparate(
_ol_webgl_.SRC_ALPHA, _ol_webgl_.ONE_MINUS_SRC_ALPHA,
_ol_webgl_.ONE, _ol_webgl_.ONE_MINUS_SRC_ALPHA);
gl.disable(_ol_webgl_.CULL_FACE);
gl.disable(_ol_webgl_.DEPTH_TEST);
gl.disable(_ol_webgl_.SCISSOR_TEST);
gl.disable(_ol_webgl_.STENCIL_TEST);
SRC_ALPHA, ONE_MINUS_SRC_ALPHA,
ONE, ONE_MINUS_SRC_ALPHA);
gl.disable(CULL_FACE);
gl.disable(DEPTH_TEST);
gl.disable(SCISSOR_TEST);
gl.disable(STENCIL_TEST);
};
@@ -466,11 +469,11 @@ WebGLMapRenderer.prototype.renderFrame = function(frameState) {
this.canvas_.height = height;
}
gl.bindFramebuffer(_ol_webgl_.FRAMEBUFFER, null);
gl.bindFramebuffer(FRAMEBUFFER, null);
gl.clearColor(0, 0, 0, 0);
gl.clear(_ol_webgl_.COLOR_BUFFER_BIT);
gl.enable(_ol_webgl_.BLEND);
gl.clear(COLOR_BUFFER_BIT);
gl.enable(BLEND);
gl.viewport(0, 0, this.canvas_.width, this.canvas_.height);
for (i = 0, ii = layerStatesToDraw.length; i < ii; ++i) {

View File

@@ -23,7 +23,7 @@ import {
translate as translateTransform,
apply as applyTransform
} from '../../transform.js';
import _ol_webgl_ from '../../webgl.js';
import {COLOR_BUFFER_BIT, BLEND, ARRAY_BUFFER, FLOAT, LINEAR, TRIANGLE_STRIP} from '../../webgl.js';
import WebGLBuffer from '../../webgl/Buffer.js';
/**
@@ -223,8 +223,8 @@ WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState,
gl.viewport(0, 0, framebufferDimension, framebufferDimension);
gl.clearColor(0, 0, 0, 0);
gl.clear(_ol_webgl_.COLOR_BUFFER_BIT);
gl.disable(_ol_webgl_.BLEND);
gl.clear(COLOR_BUFFER_BIT);
gl.disable(BLEND);
const program = context.getProgram(this.fragmentShader_, this.vertexShader_);
context.useProgram(program);
@@ -232,13 +232,13 @@ WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState,
this.locations_ = new Locations(gl, program);
}
context.bindBuffer(_ol_webgl_.ARRAY_BUFFER, this.renderArrayBuffer_);
context.bindBuffer(ARRAY_BUFFER, this.renderArrayBuffer_);
gl.enableVertexAttribArray(this.locations_.a_position);
gl.vertexAttribPointer(
this.locations_.a_position, 2, _ol_webgl_.FLOAT, false, 16, 0);
this.locations_.a_position, 2, FLOAT, false, 16, 0);
gl.enableVertexAttribArray(this.locations_.a_texCoord);
gl.vertexAttribPointer(
this.locations_.a_texCoord, 2, _ol_webgl_.FLOAT, false, 16, 8);
this.locations_.a_texCoord, 2, FLOAT, false, 16, 8);
gl.uniform1i(this.locations_.u_texture, 0);
/**
@@ -320,8 +320,8 @@ WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState,
framebufferExtentDimension - 1;
gl.uniform4fv(this.locations_.u_tileOffset, u_tileOffset);
mapRenderer.bindTileTexture(tile, tilePixelSize,
tileGutter * pixelRatio, _ol_webgl_.LINEAR, _ol_webgl_.LINEAR);
gl.drawArrays(_ol_webgl_.TRIANGLE_STRIP, 0, 4);
tileGutter * pixelRatio, LINEAR, LINEAR);
gl.drawArrays(TRIANGLE_STRIP, 0, 4);
}
}

View File

@@ -1,7 +1,6 @@
/**
* @module ol/webgl
*/
const _ol_webgl_ = {};
/**
* Constants taken from goog.webgl
@@ -12,245 +11,245 @@ const _ol_webgl_ = {};
* @const
* @type {number}
*/
_ol_webgl_.ONE = 1;
export const ONE = 1;
/**
* @const
* @type {number}
*/
_ol_webgl_.SRC_ALPHA = 0x0302;
export const SRC_ALPHA = 0x0302;
/**
* @const
* @type {number}
*/
_ol_webgl_.COLOR_ATTACHMENT0 = 0x8CE0;
export const COLOR_ATTACHMENT0 = 0x8CE0;
/**
* @const
* @type {number}
*/
_ol_webgl_.COLOR_BUFFER_BIT = 0x00004000;
export const COLOR_BUFFER_BIT = 0x00004000;
/**
* @const
* @type {number}
*/
_ol_webgl_.TRIANGLES = 0x0004;
export const TRIANGLES = 0x0004;
/**
* @const
* @type {number}
*/
_ol_webgl_.TRIANGLE_STRIP = 0x0005;
export const TRIANGLE_STRIP = 0x0005;
/**
* @const
* @type {number}
*/
_ol_webgl_.ONE_MINUS_SRC_ALPHA = 0x0303;
export const ONE_MINUS_SRC_ALPHA = 0x0303;
/**
* @const
* @type {number}
*/
_ol_webgl_.ARRAY_BUFFER = 0x8892;
export const ARRAY_BUFFER = 0x8892;
/**
* @const
* @type {number}
*/
_ol_webgl_.ELEMENT_ARRAY_BUFFER = 0x8893;
export const ELEMENT_ARRAY_BUFFER = 0x8893;
/**
* @const
* @type {number}
*/
_ol_webgl_.STREAM_DRAW = 0x88E0;
export const STREAM_DRAW = 0x88E0;
/**
* @const
* @type {number}
*/
_ol_webgl_.STATIC_DRAW = 0x88E4;
export const STATIC_DRAW = 0x88E4;
/**
* @const
* @type {number}
*/
_ol_webgl_.DYNAMIC_DRAW = 0x88E8;
export const DYNAMIC_DRAW = 0x88E8;
/**
* @const
* @type {number}
*/
_ol_webgl_.CULL_FACE = 0x0B44;
export const CULL_FACE = 0x0B44;
/**
* @const
* @type {number}
*/
_ol_webgl_.BLEND = 0x0BE2;
export const BLEND = 0x0BE2;
/**
* @const
* @type {number}
*/
_ol_webgl_.STENCIL_TEST = 0x0B90;
export const STENCIL_TEST = 0x0B90;
/**
* @const
* @type {number}
*/
_ol_webgl_.DEPTH_TEST = 0x0B71;
export const DEPTH_TEST = 0x0B71;
/**
* @const
* @type {number}
*/
_ol_webgl_.SCISSOR_TEST = 0x0C11;
export const SCISSOR_TEST = 0x0C11;
/**
* @const
* @type {number}
*/
_ol_webgl_.UNSIGNED_BYTE = 0x1401;
export const UNSIGNED_BYTE = 0x1401;
/**
* @const
* @type {number}
*/
_ol_webgl_.UNSIGNED_SHORT = 0x1403;
export const UNSIGNED_SHORT = 0x1403;
/**
* @const
* @type {number}
*/
_ol_webgl_.UNSIGNED_INT = 0x1405;
export const UNSIGNED_INT = 0x1405;
/**
* @const
* @type {number}
*/
_ol_webgl_.FLOAT = 0x1406;
export const FLOAT = 0x1406;
/**
* @const
* @type {number}
*/
_ol_webgl_.RGBA = 0x1908;
export const RGBA = 0x1908;
/**
* @const
* @type {number}
*/
_ol_webgl_.FRAGMENT_SHADER = 0x8B30;
export const FRAGMENT_SHADER = 0x8B30;
/**
* @const
* @type {number}
*/
_ol_webgl_.VERTEX_SHADER = 0x8B31;
export const VERTEX_SHADER = 0x8B31;
/**
* @const
* @type {number}
*/
_ol_webgl_.LINK_STATUS = 0x8B82;
export const LINK_STATUS = 0x8B82;
/**
* @const
* @type {number}
*/
_ol_webgl_.LINEAR = 0x2601;
export const LINEAR = 0x2601;
/**
* @const
* @type {number}
*/
_ol_webgl_.TEXTURE_MAG_FILTER = 0x2800;
export const TEXTURE_MAG_FILTER = 0x2800;
/**
* @const
* @type {number}
*/
_ol_webgl_.TEXTURE_MIN_FILTER = 0x2801;
export const TEXTURE_MIN_FILTER = 0x2801;
/**
* @const
* @type {number}
*/
_ol_webgl_.TEXTURE_WRAP_S = 0x2802;
export const TEXTURE_WRAP_S = 0x2802;
/**
* @const
* @type {number}
*/
_ol_webgl_.TEXTURE_WRAP_T = 0x2803;
export const TEXTURE_WRAP_T = 0x2803;
/**
* @const
* @type {number}
*/
_ol_webgl_.TEXTURE_2D = 0x0DE1;
export const TEXTURE_2D = 0x0DE1;
/**
* @const
* @type {number}
*/
_ol_webgl_.TEXTURE0 = 0x84C0;
export const TEXTURE0 = 0x84C0;
/**
* @const
* @type {number}
*/
_ol_webgl_.CLAMP_TO_EDGE = 0x812F;
export const CLAMP_TO_EDGE = 0x812F;
/**
* @const
* @type {number}
*/
_ol_webgl_.COMPILE_STATUS = 0x8B81;
export const COMPILE_STATUS = 0x8B81;
/**
* @const
* @type {number}
*/
_ol_webgl_.FRAMEBUFFER = 0x8D40;
export const FRAMEBUFFER = 0x8D40;
/** end of goog.webgl constants
@@ -262,7 +261,7 @@ _ol_webgl_.FRAMEBUFFER = 0x8D40;
* @private
* @type {Array.<string>}
*/
_ol_webgl_.CONTEXT_IDS_ = [
export const CONTEXT_IDS_ = [
'experimental-webgl',
'webgl',
'webkit-3d',
@@ -275,11 +274,11 @@ _ol_webgl_.CONTEXT_IDS_ = [
* @param {Object=} opt_attributes Attributes.
* @return {WebGLRenderingContext} WebGL rendering context.
*/
_ol_webgl_.getContext = function(canvas, opt_attributes) {
const ii = _ol_webgl_.CONTEXT_IDS_.length;
export function getContext(canvas, opt_attributes) {
const ii = CONTEXT_IDS_.length;
for (let i = 0; i < ii; ++i) {
try {
const context = canvas.getContext(_ol_webgl_.CONTEXT_IDS_[i], opt_attributes);
const context = canvas.getContext(CONTEXT_IDS_[i], opt_attributes);
if (context) {
return /** @type {!WebGLRenderingContext} */ (context);
}
@@ -288,5 +287,4 @@ _ol_webgl_.getContext = function(canvas, opt_attributes) {
}
}
return null;
};
export default _ol_webgl_;
}

View File

@@ -1,15 +1,15 @@
/**
* @module ol/webgl/Buffer
*/
import _ol_webgl_ from '../webgl.js';
import {STATIC_DRAW, STREAM_DRAW, DYNAMIC_DRAW} from '../webgl.js';
/**
* @enum {number}
*/
const BufferUsage = {
STATIC_DRAW: _ol_webgl_.STATIC_DRAW,
STREAM_DRAW: _ol_webgl_.STREAM_DRAW,
DYNAMIC_DRAW: _ol_webgl_.DYNAMIC_DRAW
STATIC_DRAW: STATIC_DRAW,
STREAM_DRAW: STREAM_DRAW,
DYNAMIC_DRAW: DYNAMIC_DRAW
};
/**

View File

@@ -6,7 +6,7 @@ import Disposable from '../Disposable.js';
import {includes} from '../array.js';
import {listen, unlistenAll} from '../events.js';
import {clear} from '../obj.js';
import _ol_webgl_ from '../webgl.js';
import {ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER, TEXTURE_2D, TEXTURE_WRAP_S, TEXTURE_WRAP_T} from '../webgl.js';
import ContextEventType from '../webgl/ContextEventType.js';
/**
@@ -112,9 +112,9 @@ WebGLContext.prototype.bindBuffer = function(target, buf) {
const buffer = gl.createBuffer();
gl.bindBuffer(target, buffer);
let /** @type {ArrayBufferView} */ arrayBuffer;
if (target == _ol_webgl_.ARRAY_BUFFER) {
if (target == ARRAY_BUFFER) {
arrayBuffer = new Float32Array(arr);
} else if (target == _ol_webgl_.ELEMENT_ARRAY_BUFFER) {
} else if (target == ELEMENT_ARRAY_BUFFER) {
arrayBuffer = this.hasOESElementIndexUint ?
new Uint32Array(arr) : new Uint16Array(arr);
}
@@ -323,11 +323,11 @@ function createTextureInternal(gl, opt_wrapS, opt_wrapT) {
if (opt_wrapS !== undefined) {
gl.texParameteri(
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_S, opt_wrapS);
TEXTURE_2D, TEXTURE_WRAP_S, opt_wrapS);
}
if (opt_wrapT !== undefined) {
gl.texParameteri(
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_T, opt_wrapT);
TEXTURE_2D, TEXTURE_WRAP_T, opt_wrapT);
}
return texture;

View File

@@ -2,7 +2,7 @@
* @module ol/webgl/Fragment
*/
import {inherits} from '../index.js';
import _ol_webgl_ from '../webgl.js';
import {FRAGMENT_SHADER} from '../webgl.js';
import WebGLShader from '../webgl/Shader.js';
/**
@@ -22,6 +22,6 @@ inherits(WebGLFragment, WebGLShader);
* @inheritDoc
*/
WebGLFragment.prototype.getType = function() {
return _ol_webgl_.FRAGMENT_SHADER;
return FRAGMENT_SHADER;
};
export default WebGLFragment;

View File

@@ -2,7 +2,7 @@
* @module ol/webgl/Vertex
*/
import {inherits} from '../index.js';
import _ol_webgl_ from '../webgl.js';
import {VERTEX_SHADER} from '../webgl.js';
import WebGLShader from '../webgl/Shader.js';
/**
@@ -22,6 +22,6 @@ inherits(WebGLVertex, WebGLShader);
* @inheritDoc
*/
WebGLVertex.prototype.getType = function() {
return _ol_webgl_.VERTEX_SHADER;
return VERTEX_SHADER;
};
export default WebGLVertex;