diff --git a/src/ol/render/canvas/Replay.js b/src/ol/render/canvas/Replay.js
index 7a7a5a205a..f3253383d3 100644
--- a/src/ol/render/canvas/Replay.js
+++ b/src/ol/render/canvas/Replay.js
@@ -17,7 +17,7 @@ import {isEmpty} from '../../obj.js';
import VectorContext from '../VectorContext.js';
import {drawImage, resetTransform, defaultPadding, defaultFillStyle, defaultStrokeStyle, defaultMiterLimit, defaultLineWidth, defaultLineJoin, defaultLineDashOffset, defaultLineDash, defaultLineCap} from '../canvas.js';
import CanvasInstruction from '../canvas/Instruction.js';
-import _ol_render_replay_ from '../replay.js';
+import {TEXT_ALIGN} from '../replay.js';
import {
create as createTransform,
compose as composeTransform,
@@ -718,7 +718,7 @@ CanvasReplay.prototype.replay_ = function(
const textLength = measure(text);
if (overflow || textLength <= pathLength) {
const textAlign = /** @type {ol.render.canvas.TextReplay} */ (this).textStates[textKey].textAlign;
- const startM = (pathLength - textLength) * _ol_render_replay_.TEXT_ALIGN[textAlign];
+ const startM = (pathLength - textLength) * TEXT_ALIGN[textAlign];
const parts = drawTextOnPath(
pixelCoordinates, begin, end, 2, text, measure, startM, maxAngle);
if (parts) {
diff --git a/src/ol/render/canvas/ReplayGroup.js b/src/ol/render/canvas/ReplayGroup.js
index 436349b897..21d31ce01c 100644
--- a/src/ol/render/canvas/ReplayGroup.js
+++ b/src/ol/render/canvas/ReplayGroup.js
@@ -14,7 +14,7 @@ import CanvasImageReplay from '../canvas/ImageReplay.js';
import CanvasLineStringReplay from '../canvas/LineStringReplay.js';
import CanvasPolygonReplay from '../canvas/PolygonReplay.js';
import CanvasTextReplay from '../canvas/TextReplay.js';
-import _ol_render_replay_ from '../replay.js';
+import {ORDER} from '../replay.js';
import {create as createTransform, compose as composeTransform} from '../../transform.js';
@@ -370,8 +370,8 @@ CanvasReplayGroup.prototype.forEachFeatureAtCoordinate = function(
for (i = zs.length - 1; i >= 0; --i) {
const zIndexKey = zs[i].toString();
replays = this.replaysByZIndex_[zIndexKey];
- for (j = _ol_render_replay_.ORDER.length - 1; j >= 0; --j) {
- replayType = _ol_render_replay_.ORDER[j];
+ for (j = ORDER.length - 1; j >= 0; --j) {
+ replayType = ORDER[j];
replay = replays[replayType];
if (replay !== undefined) {
if (declutterReplays &&
@@ -473,7 +473,7 @@ CanvasReplayGroup.prototype.replay = function(context,
context.save();
this.clip(context, transform);
- const replayTypes = opt_replayTypes ? opt_replayTypes : _ol_render_replay_.ORDER;
+ const replayTypes = opt_replayTypes ? opt_replayTypes : ORDER;
let i, ii, j, jj, replays, replay;
for (i = 0, ii = zs.length; i < ii; ++i) {
const zIndexKey = zs[i].toString();
diff --git a/src/ol/render/canvas/TextReplay.js b/src/ol/render/canvas/TextReplay.js
index 1c3321056c..82db004ef8 100644
--- a/src/ol/render/canvas/TextReplay.js
+++ b/src/ol/render/canvas/TextReplay.js
@@ -11,7 +11,7 @@ import {CANVAS_LINE_DASH, SAFARI} from '../../has.js';
import {labelCache, measureTextWidth, defaultTextAlign, measureTextHeight, defaultPadding, defaultLineCap, defaultLineDashOffset, defaultLineDash, defaultLineJoin, defaultFillStyle, checkFont, defaultFont, defaultLineWidth, defaultMiterLimit, defaultStrokeStyle, defaultTextBaseline} from '../canvas.js';
import CanvasInstruction from '../canvas/Instruction.js';
import CanvasReplay from '../canvas/Replay.js';
-import _ol_render_replay_ from '../replay.js';
+import {TEXT_ALIGN} from '../replay.js';
import TextPlacement from '../../style/TextPlacement.js';
/**
@@ -290,7 +290,7 @@ CanvasTextReplay.prototype.getImage = function(text, textKey, fillKey, strokeKey
const textState = this.textStates[textKey] || this.textState_;
const pixelRatio = this.pixelRatio;
const scale = textState.scale * pixelRatio;
- const align = _ol_render_replay_.TEXT_ALIGN[textState.textAlign || defaultTextAlign];
+ const align = TEXT_ALIGN[textState.textAlign || defaultTextAlign];
const strokeWidth = strokeKey && strokeState.lineWidth ? strokeState.lineWidth : 0;
const lines = text.split('\n');
@@ -353,8 +353,8 @@ CanvasTextReplay.prototype.drawTextImage_ = function(label, begin, end) {
const textState = this.textState_;
const strokeState = this.textStrokeState_;
const pixelRatio = this.pixelRatio;
- const align = _ol_render_replay_.TEXT_ALIGN[textState.textAlign || defaultTextAlign];
- const baseline = _ol_render_replay_.TEXT_ALIGN[textState.textBaseline];
+ const align = TEXT_ALIGN[textState.textAlign || defaultTextAlign];
+ const baseline = TEXT_ALIGN[textState.textBaseline];
const strokeWidth = strokeState && strokeState.lineWidth ? strokeState.lineWidth : 0;
const anchorX = align * label.width / pixelRatio + 2 * (0.5 - align) * strokeWidth;
@@ -421,7 +421,7 @@ CanvasTextReplay.prototype.drawChars_ = function(begin, end, declutterGroup) {
}
const pixelRatio = this.pixelRatio;
- const baseline = _ol_render_replay_.TEXT_ALIGN[textState.textBaseline];
+ const baseline = TEXT_ALIGN[textState.textBaseline];
const offsetY = this.textOffsetY_ * pixelRatio;
const text = this.text_;
diff --git a/src/ol/render/replay.js b/src/ol/render/replay.js
index c477763e7a..ad9e4cb861 100644
--- a/src/ol/render/replay.js
+++ b/src/ol/render/replay.js
@@ -2,14 +2,13 @@
* @module ol/render/replay
*/
import ReplayType from '../render/ReplayType.js';
-const _ol_render_replay_ = {};
/**
* @const
* @type {Array.
}
*/
-_ol_render_replay_.ORDER = [
+export const ORDER = [
ReplayType.POLYGON,
ReplayType.CIRCLE,
ReplayType.LINE_STRING,
@@ -22,16 +21,15 @@ _ol_render_replay_.ORDER = [
* @const
* @enum {number}
*/
-_ol_render_replay_.TEXT_ALIGN = {};
-_ol_render_replay_.TEXT_ALIGN['left'] = 0;
-_ol_render_replay_.TEXT_ALIGN['end'] = 0;
-_ol_render_replay_.TEXT_ALIGN['center'] = 0.5;
-_ol_render_replay_.TEXT_ALIGN['right'] = 1;
-_ol_render_replay_.TEXT_ALIGN['start'] = 1;
-_ol_render_replay_.TEXT_ALIGN['top'] = 0;
-_ol_render_replay_.TEXT_ALIGN['middle'] = 0.5;
-_ol_render_replay_.TEXT_ALIGN['hanging'] = 0.2;
-_ol_render_replay_.TEXT_ALIGN['alphabetic'] = 0.8;
-_ol_render_replay_.TEXT_ALIGN['ideographic'] = 0.8;
-_ol_render_replay_.TEXT_ALIGN['bottom'] = 1;
-export default _ol_render_replay_;
+export const TEXT_ALIGN = {};
+TEXT_ALIGN['left'] = 0;
+TEXT_ALIGN['end'] = 0;
+TEXT_ALIGN['center'] = 0.5;
+TEXT_ALIGN['right'] = 1;
+TEXT_ALIGN['start'] = 1;
+TEXT_ALIGN['top'] = 0;
+TEXT_ALIGN['middle'] = 0.5;
+TEXT_ALIGN['hanging'] = 0.2;
+TEXT_ALIGN['alphabetic'] = 0.8;
+TEXT_ALIGN['ideographic'] = 0.8;
+TEXT_ALIGN['bottom'] = 1;
diff --git a/src/ol/render/webgl.js b/src/ol/render/webgl.js
index b02b092533..dcfbb1c019 100644
--- a/src/ol/render/webgl.js
+++ b/src/ol/render/webgl.js
@@ -1,83 +1,88 @@
/**
* @module ol/render/webgl
*/
-const _ol_render_webgl_ = {};
/**
* @const
* @type {string}
*/
-_ol_render_webgl_.defaultFont = '10px sans-serif';
+export const DEFAULT_FONT = '10px sans-serif';
/**
* @const
* @type {ol.Color}
*/
-_ol_render_webgl_.defaultFillStyle = [0.0, 0.0, 0.0, 1.0];
+export const DEFAULT_FILLSTYLE = [0.0, 0.0, 0.0, 1.0];
/**
* @const
* @type {string}
*/
-_ol_render_webgl_.defaultLineCap = 'round';
+export const DEFAULT_LINECAP = 'round';
/**
* @const
* @type {Array.}
*/
-_ol_render_webgl_.defaultLineDash = [];
+export const DEFAULT_LINEDASH = [];
/**
* @const
* @type {number}
*/
-_ol_render_webgl_.defaultLineDashOffset = 0;
+export const DEFAULT_LINEDASHOFFSET = 0;
/**
* @const
* @type {string}
*/
-_ol_render_webgl_.defaultLineJoin = 'round';
+export const DEFAULT_LINEJOIN = 'round';
/**
* @const
* @type {number}
*/
-_ol_render_webgl_.defaultMiterLimit = 10;
+export const DEFAULT_MITERLIMIT = 10;
/**
* @const
* @type {ol.Color}
*/
-_ol_render_webgl_.defaultStrokeStyle = [0.0, 0.0, 0.0, 1.0];
+export const DEFAULT_STROKESTYLE = [0.0, 0.0, 0.0, 1.0];
/**
* @const
* @type {number}
*/
-_ol_render_webgl_.defaultTextAlign = 0.5;
+export const DEFAULT_TEXTALIGN = 0.5;
/**
* @const
* @type {number}
*/
-_ol_render_webgl_.defaultTextBaseline = 0.5;
+export const DEFAULT_TEXTBASELINE = 0.5;
/**
* @const
* @type {number}
*/
-_ol_render_webgl_.defaultLineWidth = 1;
+export const DEFAULT_LINEWIDTH = 1;
+
+/**
+ * @const
+ * @type {number}
+ */
+export const EPSILON = Number.EPSILON || 2.220446049250313e-16;
/**
* Calculates the orientation of a triangle based on the determinant method.
@@ -89,15 +94,9 @@ _ol_render_webgl_.defaultLineWidth = 1;
* @param {number} y3 Third Y coordinate.
* @return {boolean|undefined} Triangle is clockwise.
*/
-_ol_render_webgl_.triangleIsCounterClockwise = function(x1, y1, x2, y2, x3, y3) {
+export const triangleIsCounterClockwise = function(x1, y1, x2, y2, x3, y3) {
const area = (x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1);
- return (area <= _ol_render_webgl_.EPSILON && area >= -_ol_render_webgl_.EPSILON) ?
+ return (area <= EPSILON && area >= -EPSILON) ?
undefined : area > 0;
};
-/**
- * @const
- * @type {number}
- */
-_ol_render_webgl_.EPSILON = Number.EPSILON || 2.220446049250313e-16;
-export default _ol_render_webgl_;
diff --git a/src/ol/render/webgl/CircleReplay.js b/src/ol/render/webgl/CircleReplay.js
index 086ab71921..e6005b622b 100644
--- a/src/ol/render/webgl/CircleReplay.js
+++ b/src/ol/render/webgl/CircleReplay.js
@@ -10,8 +10,9 @@ import {translate} from '../../geom/flat/transform.js';
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 {DEFAULT_LINEDASH, DEFAULT_LINEDASHOFFSET, DEFAULT_STROKESTYLE,
+ DEFAULT_FILLSTYLE, DEFAULT_LINEWIDTH} from '../webgl.js';
+import {FLOAT} from '../../webgl.js';
import WebGLBuffer from '../../webgl/Buffer.js';
/**
@@ -211,15 +212,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.
@@ -377,22 +378,22 @@ WebGLCircleReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle
if (strokeStyle) {
const strokeStyleLineDash = strokeStyle.getLineDash();
this.state_.lineDash = strokeStyleLineDash ?
- strokeStyleLineDash : _ol_render_webgl_.defaultLineDash;
+ strokeStyleLineDash : DEFAULT_LINEDASH;
const strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
this.state_.lineDashOffset = strokeStyleLineDashOffset ?
- strokeStyleLineDashOffset : _ol_render_webgl_.defaultLineDashOffset;
+ strokeStyleLineDashOffset : DEFAULT_LINEDASHOFFSET;
strokeStyleColor = strokeStyle.getColor();
if (!(strokeStyleColor instanceof CanvasGradient) &&
!(strokeStyleColor instanceof CanvasPattern)) {
strokeStyleColor = asArray(strokeStyleColor).map(function(c, i) {
return i != 3 ? c / 255 : c;
- }) || _ol_render_webgl_.defaultStrokeStyle;
+ }) || DEFAULT_STROKESTYLE;
} else {
- strokeStyleColor = _ol_render_webgl_.defaultStrokeStyle;
+ strokeStyleColor = DEFAULT_STROKESTYLE;
}
strokeStyleWidth = strokeStyle.getWidth();
strokeStyleWidth = strokeStyleWidth !== undefined ?
- strokeStyleWidth : _ol_render_webgl_.defaultLineWidth;
+ strokeStyleWidth : DEFAULT_LINEWIDTH;
} else {
strokeStyleColor = [0, 0, 0, 0];
strokeStyleWidth = 0;
@@ -402,9 +403,9 @@ WebGLCircleReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle
!(fillStyleColor instanceof CanvasPattern)) {
fillStyleColor = asArray(fillStyleColor).map(function(c, i) {
return i != 3 ? c / 255 : c;
- }) || _ol_render_webgl_.defaultFillStyle;
+ }) || DEFAULT_FILLSTYLE;
} else {
- fillStyleColor = _ol_render_webgl_.defaultFillStyle;
+ fillStyleColor = DEFAULT_FILLSTYLE;
}
if (!this.state_.strokeColor || !equals(this.state_.strokeColor, strokeStyleColor) ||
!this.state_.fillColor || !equals(this.state_.fillColor, fillStyleColor) ||
diff --git a/src/ol/render/webgl/LineStringReplay.js b/src/ol/render/webgl/LineStringReplay.js
index f48ea91aba..fd45af9c49 100644
--- a/src/ol/render/webgl/LineStringReplay.js
+++ b/src/ol/render/webgl/LineStringReplay.js
@@ -9,11 +9,13 @@ import {linearRingIsClockwise} from '../../geom/flat/orient.js';
import {translate} from '../../geom/flat/transform.js';
import {lineStringIsClosed} from '../../geom/flat/topology.js';
import {isEmpty} from '../../obj.js';
-import _ol_render_webgl_ from '../webgl.js';
+import {DEFAULT_LINECAP, DEFAULT_LINEDASH, DEFAULT_LINEDASHOFFSET,
+ DEFAULT_LINEJOIN, DEFAULT_LINEWIDTH, DEFAULT_MITERLIMIT, DEFAULT_STROKESTYLE,
+ triangleIsCounterClockwise} 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';
@@ -210,7 +212,7 @@ WebGLLineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, off
}
// We group CW and straight lines, thus the not so inituitive CCW checking function.
- sign = _ol_render_webgl_.triangleIsCounterClockwise(p0[0], p0[1], p1[0], p1[1], p2[0], p2[1])
+ sign = triangleIsCounterClockwise(p0[0], p0[1], p1[0], p1[1], p2[0], p2[1])
? -1 : 1;
numVertices = this.addVertices_(p0, p1, p2,
@@ -471,19 +473,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.
@@ -646,31 +648,31 @@ WebGLLineStringReplay.prototype.setStrokeStyle_ = function(gl, color, lineWidth,
WebGLLineStringReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
const strokeStyleLineCap = strokeStyle.getLineCap();
this.state_.lineCap = strokeStyleLineCap !== undefined ?
- strokeStyleLineCap : _ol_render_webgl_.defaultLineCap;
+ strokeStyleLineCap : DEFAULT_LINECAP;
const strokeStyleLineDash = strokeStyle.getLineDash();
this.state_.lineDash = strokeStyleLineDash ?
- strokeStyleLineDash : _ol_render_webgl_.defaultLineDash;
+ strokeStyleLineDash : DEFAULT_LINEDASH;
const strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
this.state_.lineDashOffset = strokeStyleLineDashOffset ?
- strokeStyleLineDashOffset : _ol_render_webgl_.defaultLineDashOffset;
+ strokeStyleLineDashOffset : DEFAULT_LINEDASHOFFSET;
const strokeStyleLineJoin = strokeStyle.getLineJoin();
this.state_.lineJoin = strokeStyleLineJoin !== undefined ?
- strokeStyleLineJoin : _ol_render_webgl_.defaultLineJoin;
+ strokeStyleLineJoin : DEFAULT_LINEJOIN;
let strokeStyleColor = strokeStyle.getColor();
if (!(strokeStyleColor instanceof CanvasGradient) &&
!(strokeStyleColor instanceof CanvasPattern)) {
strokeStyleColor = asArray(strokeStyleColor).map(function(c, i) {
return i != 3 ? c / 255 : c;
- }) || _ol_render_webgl_.defaultStrokeStyle;
+ }) || DEFAULT_STROKESTYLE;
} else {
- strokeStyleColor = _ol_render_webgl_.defaultStrokeStyle;
+ strokeStyleColor = DEFAULT_STROKESTYLE;
}
let strokeStyleWidth = strokeStyle.getWidth();
strokeStyleWidth = strokeStyleWidth !== undefined ?
- strokeStyleWidth : _ol_render_webgl_.defaultLineWidth;
+ strokeStyleWidth : DEFAULT_LINEWIDTH;
let strokeStyleMiterLimit = strokeStyle.getMiterLimit();
strokeStyleMiterLimit = strokeStyleMiterLimit !== undefined ?
- strokeStyleMiterLimit : _ol_render_webgl_.defaultMiterLimit;
+ strokeStyleMiterLimit : DEFAULT_MITERLIMIT;
if (!this.state_.strokeColor || !equals(this.state_.strokeColor, strokeStyleColor) ||
this.state_.lineWidth !== strokeStyleWidth || this.state_.miterLimit !== strokeStyleMiterLimit) {
this.state_.changed = true;
diff --git a/src/ol/render/webgl/PolygonReplay.js b/src/ol/render/webgl/PolygonReplay.js
index 4389e86db6..1e0a7c9088 100644
--- a/src/ol/render/webgl/PolygonReplay.js
+++ b/src/ol/render/webgl/PolygonReplay.js
@@ -13,11 +13,11 @@ import {fragment, vertex} from '../webgl/polygonreplay/defaultshader.js';
import Locations from '../webgl/polygonreplay/defaultshader/Locations.js';
import WebGLLineStringReplay from '../webgl/LineStringReplay.js';
import WebGLReplay from '../webgl/Replay.js';
-import _ol_render_webgl_ from '../webgl.js';
+import {triangleIsCounterClockwise, EPSILON, DEFAULT_FILLSTYLE} 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';
/**
@@ -220,9 +220,9 @@ WebGLPolygonReplay.prototype.classifyPoints_ = function(list, rtree, ccw) {
let s1 = list.nextItem();
let pointsReclassified = false;
do {
- const reflex = ccw ? _ol_render_webgl_.triangleIsCounterClockwise(s1.p1.x,
+ const reflex = ccw ? triangleIsCounterClockwise(s1.p1.x,
s1.p1.y, s0.p1.x, s0.p1.y, s0.p0.x, s0.p0.y) :
- _ol_render_webgl_.triangleIsCounterClockwise(s0.p0.x, s0.p0.y, s0.p1.x,
+ triangleIsCounterClockwise(s0.p0.x, s0.p0.y, s0.p1.x,
s0.p1.y, s1.p1.x, s1.p1.y);
if (reflex === undefined) {
this.removeItem_(s0, s1, list, rtree);
@@ -273,7 +273,7 @@ WebGLPolygonReplay.prototype.bridgeHole_ = function(hole, holeMaxX,
const intersection = this.calculateIntersection_(p1, p2, currSeg.p0,
currSeg.p1, true);
const dist = Math.abs(p1.x - intersection[0]);
- if (dist < minDist && _ol_render_webgl_.triangleIsCounterClockwise(p1.x, p1.y,
+ if (dist < minDist && triangleIsCounterClockwise(p1.x, p1.y,
currSeg.p0.x, currSeg.p0.y, currSeg.p1.x, currSeg.p1.y) !== undefined) {
minDist = dist;
p5 = {x: intersection[0], y: intersection[1], i: -1};
@@ -714,8 +714,8 @@ WebGLPolygonReplay.prototype.calculateIntersection_ = function(p0, p1, p2, p3, o
if (denom !== 0) {
const ua = ((p3.x - p2.x) * (p0.y - p2.y) - (p3.y - p2.y) * (p0.x - p2.x)) / denom;
const ub = ((p1.x - p0.x) * (p0.y - p2.y) - (p1.y - p0.y) * (p0.x - p2.x)) / denom;
- if ((!opt_touch && ua > _ol_render_webgl_.EPSILON && ua < 1 - _ol_render_webgl_.EPSILON &&
- ub > _ol_render_webgl_.EPSILON && ub < 1 - _ol_render_webgl_.EPSILON) || (opt_touch &&
+ if ((!opt_touch && ua > EPSILON && ua < 1 - EPSILON &&
+ ub > EPSILON && ub < 1 - EPSILON) || (opt_touch &&
ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1)) {
return [p0.x + ua * (p1.x - p0.x), p0.y + ua * (p1.y - p0.y)];
}
@@ -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;
@@ -1042,9 +1042,9 @@ WebGLPolygonReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyl
!(fillStyleColor instanceof CanvasPattern)) {
fillStyleColor = asArray(fillStyleColor).map(function(c, i) {
return i != 3 ? c / 255 : c;
- }) || _ol_render_webgl_.defaultFillStyle;
+ }) || DEFAULT_FILLSTYLE;
} else {
- fillStyleColor = _ol_render_webgl_.defaultFillStyle;
+ fillStyleColor = DEFAULT_FILLSTYLE;
}
if (!this.state_.fillColor || !equals(fillStyleColor, this.state_.fillColor)) {
this.state_.fillColor = fillStyleColor;
diff --git a/src/ol/render/webgl/Replay.js b/src/ol/render/webgl/Replay.js
index 6b0961415f..cefdfc8fb4 100644
--- a/src/ol/render/webgl/Replay.js
+++ b/src/ol/render/webgl/Replay.js
@@ -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;
diff --git a/src/ol/render/webgl/ReplayGroup.js b/src/ol/render/webgl/ReplayGroup.js
index c2f787ad10..4fb2cceb78 100644
--- a/src/ol/render/webgl/ReplayGroup.js
+++ b/src/ol/render/webgl/ReplayGroup.js
@@ -5,7 +5,7 @@ import {inherits} from '../../index.js';
import {numberSafeCompareFunction} from '../../array.js';
import {buffer, createOrUpdateFromCoordinate} from '../../extent.js';
import {isEmpty} from '../../obj.js';
-import _ol_render_replay_ from '../replay.js';
+import {ORDER} from '../replay.js';
import ReplayGroup from '../ReplayGroup.js';
import WebGLCircleReplay from '../webgl/CircleReplay.js';
import WebGLImageReplay from '../webgl/ImageReplay.js';
@@ -171,8 +171,8 @@ WebGLReplayGroup.prototype.replay = function(context,
let i, ii, j, jj, replays, replay;
for (i = 0, ii = zs.length; i < ii; ++i) {
replays = this.replaysByZIndex_[zs[i].toString()];
- for (j = 0, jj = _ol_render_replay_.ORDER.length; j < jj; ++j) {
- replay = replays[_ol_render_replay_.ORDER[j]];
+ for (j = 0, jj = ORDER.length; j < jj; ++j) {
+ replay = replays[ORDER[j]];
if (replay !== undefined) {
replay.replay(context,
center, resolution, rotation, size, pixelRatio,
@@ -214,8 +214,8 @@ WebGLReplayGroup.prototype.replayHitDetection_ = function(context,
let i, ii, j, replays, replay, result;
for (i = 0, ii = zs.length; i < ii; ++i) {
replays = this.replaysByZIndex_[zs[i].toString()];
- for (j = _ol_render_replay_.ORDER.length - 1; j >= 0; --j) {
- replay = replays[_ol_render_replay_.ORDER[j]];
+ for (j = ORDER.length - 1; j >= 0; --j) {
+ replay = replays[ORDER[j]];
if (replay !== undefined) {
result = replay.replay(context,
center, resolution, rotation, size, pixelRatio, opacity,
diff --git a/src/ol/render/webgl/TextReplay.js b/src/ol/render/webgl/TextReplay.js
index 0029df007d..739e587a74 100644
--- a/src/ol/render/webgl/TextReplay.js
+++ b/src/ol/render/webgl/TextReplay.js
@@ -6,8 +6,10 @@ import {asColorLike} from '../../colorlike.js';
import {createCanvasContext2D} from '../../dom.js';
import GeometryType from '../../geom/GeometryType.js';
import {CANVAS_LINE_DASH} from '../../has.js';
-import _ol_render_replay_ from '../replay.js';
-import _ol_render_webgl_ from '../webgl.js';
+import {TEXT_ALIGN} from '../replay.js';
+import {DEFAULT_FILLSTYLE, DEFAULT_FONT, DEFAULT_LINECAP, DEFAULT_LINEDASH,
+ DEFAULT_LINEDASHOFFSET, DEFAULT_LINEJOIN, DEFAULT_LINEWIDTH, DEFAULT_MITERLIMIT,
+ DEFAULT_STROKESTYLE, DEFAULT_TEXTALIGN, DEFAULT_TEXTBASELINE} from '../webgl.js';
import WebGLTextureReplay from '../webgl/TextureReplay.js';
import AtlasManager from '../../style/AtlasManager.js';
import WebGLBuffer from '../../webgl/Buffer.js';
@@ -356,7 +358,7 @@ WebGLTextReplay.prototype.setTextStyle = function(textStyle) {
} else {
const textFillStyleColor = textFillStyle.getColor();
state.fillColor = asColorLike(textFillStyleColor ?
- textFillStyleColor : _ol_render_webgl_.defaultFillStyle);
+ textFillStyleColor : DEFAULT_FILLSTYLE);
}
if (!textStrokeStyle) {
state.strokeColor = null;
@@ -364,24 +366,24 @@ WebGLTextReplay.prototype.setTextStyle = function(textStyle) {
} else {
const textStrokeStyleColor = textStrokeStyle.getColor();
state.strokeColor = asColorLike(textStrokeStyleColor ?
- textStrokeStyleColor : _ol_render_webgl_.defaultStrokeStyle);
- state.lineWidth = textStrokeStyle.getWidth() || _ol_render_webgl_.defaultLineWidth;
- state.lineCap = textStrokeStyle.getLineCap() || _ol_render_webgl_.defaultLineCap;
- state.lineDashOffset = textStrokeStyle.getLineDashOffset() || _ol_render_webgl_.defaultLineDashOffset;
- state.lineJoin = textStrokeStyle.getLineJoin() || _ol_render_webgl_.defaultLineJoin;
- state.miterLimit = textStrokeStyle.getMiterLimit() || _ol_render_webgl_.defaultMiterLimit;
+ textStrokeStyleColor : DEFAULT_STROKESTYLE);
+ state.lineWidth = textStrokeStyle.getWidth() || DEFAULT_LINEWIDTH;
+ state.lineCap = textStrokeStyle.getLineCap() || DEFAULT_LINECAP;
+ state.lineDashOffset = textStrokeStyle.getLineDashOffset() || DEFAULT_LINEDASHOFFSET;
+ state.lineJoin = textStrokeStyle.getLineJoin() || DEFAULT_LINEJOIN;
+ state.miterLimit = textStrokeStyle.getMiterLimit() || DEFAULT_MITERLIMIT;
const lineDash = textStrokeStyle.getLineDash();
- state.lineDash = lineDash ? lineDash.slice() : _ol_render_webgl_.defaultLineDash;
+ state.lineDash = lineDash ? lineDash.slice() : DEFAULT_LINEDASH;
}
- state.font = textStyle.getFont() || _ol_render_webgl_.defaultFont;
+ state.font = textStyle.getFont() || DEFAULT_FONT;
state.scale = textStyle.getScale() || 1;
this.text_ = /** @type {string} */ (textStyle.getText());
- const textAlign = _ol_render_replay_.TEXT_ALIGN[textStyle.getTextAlign()];
- const textBaseline = _ol_render_replay_.TEXT_ALIGN[textStyle.getTextBaseline()];
+ const textAlign = TEXT_ALIGN[textStyle.getTextAlign()];
+ const textBaseline = TEXT_ALIGN[textStyle.getTextBaseline()];
this.textAlign_ = textAlign === undefined ?
- _ol_render_webgl_.defaultTextAlign : textAlign;
+ DEFAULT_TEXTALIGN : textAlign;
this.textBaseline_ = textBaseline === undefined ?
- _ol_render_webgl_.defaultTextBaseline : textBaseline;
+ DEFAULT_TEXTBASELINE : textBaseline;
this.offsetX_ = textStyle.getOffsetX() || 0;
this.offsetY_ = textStyle.getOffsetY() || 0;
this.rotateWithView = !!textStyle.getRotateWithView();
diff --git a/src/ol/render/webgl/TextureReplay.js b/src/ol/render/webgl/TextureReplay.js
index d1ff6080be..2a3894b29f 100644
--- a/src/ol/render/webgl/TextureReplay.js
+++ b/src/ol/render/webgl/TextureReplay.js
@@ -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];
diff --git a/src/ol/renderer/canvas/VectorTileLayer.js b/src/ol/renderer/canvas/VectorTileLayer.js
index 761a13f2de..0550e8f86a 100644
--- a/src/ol/renderer/canvas/VectorTileLayer.js
+++ b/src/ol/renderer/canvas/VectorTileLayer.js
@@ -15,7 +15,7 @@ import Units from '../../proj/Units.js';
import ReplayType from '../../render/ReplayType.js';
import {labelCache, rotateAtOffset} from '../../render/canvas.js';
import CanvasReplayGroup from '../../render/canvas/ReplayGroup.js';
-import _ol_render_replay_ from '../../render/replay.js';
+import {ORDER} from '../../render/replay.js';
import RendererType from '../Type.js';
import CanvasTileLayerRenderer from '../canvas/TileLayer.js';
import {getSquaredTolerance as getSquaredRenderTolerance, renderFeature} from '../vector.js';
@@ -44,7 +44,7 @@ const IMAGE_REPLAYS = {
const VECTOR_REPLAYS = {
'image': [ReplayType.DEFAULT],
'hybrid': [ReplayType.IMAGE, ReplayType.TEXT, ReplayType.DEFAULT],
- 'vector': _ol_render_replay_.ORDER
+ 'vector': ORDER
};
diff --git a/src/ol/renderer/webgl/ImageLayer.js b/src/ol/renderer/webgl/ImageLayer.js
index 0211f6092f..9f46e75ddd 100644
--- a/src/ol/renderer/webgl/ImageLayer.js
+++ b/src/ol/renderer/webgl/ImageLayer.js
@@ -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);
};
diff --git a/src/ol/renderer/webgl/Layer.js b/src/ol/renderer/webgl/Layer.js
index f79980c35e..476d51e4af 100644
--- a/src/ol/renderer/webgl/Layer.js
+++ b/src/ol/renderer/webgl/Layer.js
@@ -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);
};
diff --git a/src/ol/renderer/webgl/Map.js b/src/ol/renderer/webgl/Map.js
index de9fa5024e..32b9786eb6 100644
--- a/src/ol/renderer/webgl/Map.js
+++ b/src/ol/renderer/webgl/Map.js
@@ -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) {
diff --git a/src/ol/renderer/webgl/TileLayer.js b/src/ol/renderer/webgl/TileLayer.js
index 373ca0de7d..ad610801e0 100644
--- a/src/ol/renderer/webgl/TileLayer.js
+++ b/src/ol/renderer/webgl/TileLayer.js
@@ -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);
}
}
diff --git a/src/ol/webgl.js b/src/ol/webgl.js
index f43d768af6..795a628de7 100644
--- a/src/ol/webgl.js
+++ b/src/ol/webgl.js
@@ -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.}
*/
-_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_;
+}
diff --git a/src/ol/webgl/Buffer.js b/src/ol/webgl/Buffer.js
index c4c8b7ad73..58423b1831 100644
--- a/src/ol/webgl/Buffer.js
+++ b/src/ol/webgl/Buffer.js
@@ -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
};
/**
diff --git a/src/ol/webgl/Context.js b/src/ol/webgl/Context.js
index f1f3365429..aa232347a7 100644
--- a/src/ol/webgl/Context.js
+++ b/src/ol/webgl/Context.js
@@ -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;
diff --git a/src/ol/webgl/Fragment.js b/src/ol/webgl/Fragment.js
index ac33747050..1f4f9d9ccc 100644
--- a/src/ol/webgl/Fragment.js
+++ b/src/ol/webgl/Fragment.js
@@ -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;
diff --git a/src/ol/webgl/Vertex.js b/src/ol/webgl/Vertex.js
index b0eadd0820..1259e74e2f 100644
--- a/src/ol/webgl/Vertex.js
+++ b/src/ol/webgl/Vertex.js
@@ -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;