melonjs 13.0.0 → 13.1.0

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.
@@ -5,7 +5,6 @@ import Ellipse from "./../../geometries/ellipse.js";
5
5
  import RoundRect from "./../../geometries/roundrect.js";
6
6
  import Rect from "./../../geometries/rectangle.js";
7
7
  import Bounds from "./../../physics/bounds.js";
8
- import { createCanvas } from "./../video.js";
9
8
  import * as event from "./../../system/event.js";
10
9
 
11
10
  /**
@@ -19,7 +18,6 @@ class CanvasRenderer extends Renderer {
19
18
  * @param {number} options.width The width of the canvas without scaling
20
19
  * @param {number} options.height The height of the canvas without scaling
21
20
  * @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
22
- * @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
23
21
  * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
24
22
  * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
25
23
  * @param {boolean} [options.subPixel=false] Whether to enable subpixel renderering (performance hit when enabled)
@@ -32,17 +30,7 @@ class CanvasRenderer extends Renderer {
32
30
  super(options);
33
31
 
34
32
  // defined the 2d context
35
- this.context = this.getContext2d(this.getScreenCanvas(), this.settings.transparent);
36
-
37
- // create the back buffer if we use double buffering
38
- if (this.settings.doubleBuffering) {
39
- this.backBufferCanvas = createCanvas(this.settings.width, this.settings.height, true);
40
- this.backBufferContext2D = this.getContext2d(this.backBufferCanvas);
41
- }
42
- else {
43
- this.backBufferCanvas = this.getScreenCanvas();
44
- this.backBufferContext2D = this.context;
45
- }
33
+ this.context = this.getContext2d(this.getCanvas(), this.settings.transparent);
46
34
 
47
35
  this.setBlendMode(this.settings.blendMode);
48
36
 
@@ -58,13 +46,13 @@ class CanvasRenderer extends Renderer {
58
46
  }
59
47
 
60
48
  // context lost & restore event for canvas
61
- this.getScreenCanvas().addEventListener("contextlost", (e) => {
49
+ this.getCanvas().addEventListener("contextlost", (e) => {
62
50
  e.preventDefault();
63
51
  this.isContextValid = false;
64
52
  event.emit(event.ONCONTEXT_LOST, this);
65
53
  }, false );
66
54
  // ctx.restoreContext()
67
- this.getScreenCanvas().addEventListener("contextrestored", () => {
55
+ this.getCanvas().addEventListener("contextrestored", () => {
68
56
  this.isContextValid = true;
69
57
  event.emit(event.ONCONTEXT_RESTORED, this);
70
58
  }, false );
@@ -86,7 +74,7 @@ class CanvasRenderer extends Renderer {
86
74
  * @memberof CanvasRenderer
87
75
  */
88
76
  resetTransform() {
89
- this.backBufferContext2D.setTransform(1, 0, 0, 1, 0, 0);
77
+ this.getContext().setTransform(1, 0, 0, 1, 0, 0);
90
78
  }
91
79
 
92
80
  /**
@@ -128,12 +116,6 @@ class CanvasRenderer extends Renderer {
128
116
  this.currentBlendMode = "normal";
129
117
  break;
130
118
  }
131
-
132
- // transparent setting will override the given blendmode for this.context
133
- if (this.settings.doubleBuffering && this.settings.transparent) {
134
- // Clears the front buffer for each frame blit
135
- this.context.globalCompositeOperation = "copy";
136
- }
137
119
  }
138
120
 
139
121
  /**
@@ -147,17 +129,6 @@ class CanvasRenderer extends Renderer {
147
129
  }
148
130
  }
149
131
 
150
- /**
151
- * render the main framebuffer on screen
152
- * @name flush
153
- * @memberof CanvasRenderer
154
- */
155
- flush() {
156
- if (this.settings.doubleBuffering) {
157
- this.context.drawImage(this.backBufferCanvas, 0, 0);
158
- }
159
- }
160
-
161
132
  /**
162
133
  * Clears the main framebuffer with the given color
163
134
  * @name clearColor
@@ -166,11 +137,14 @@ class CanvasRenderer extends Renderer {
166
137
  * @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
167
138
  */
168
139
  clearColor(color = "#000000", opaque) {
140
+ var canvas = this.getCanvas();
141
+ var context = this.getContext();
142
+
169
143
  this.save();
170
144
  this.resetTransform();
171
- this.backBufferContext2D.globalCompositeOperation = opaque ? "copy" : "source-over";
172
- this.backBufferContext2D.fillStyle = (color instanceof Color) ? color.toRGBA() : color;
173
- this.fillRect(0, 0, this.backBufferCanvas.width, this.backBufferCanvas.height);
145
+ context.globalCompositeOperation = opaque ? "copy" : "source-over";
146
+ context.fillStyle = (color instanceof Color) ? color.toRGBA() : color;
147
+ this.fillRect(0, 0, canvas.width, canvas.height);
174
148
  this.restore();
175
149
  }
176
150
 
@@ -530,17 +504,6 @@ class CanvasRenderer extends Renderer {
530
504
  this.strokeRoundRect(x, y, width, height, radius, true);
531
505
  }
532
506
 
533
-
534
- /**
535
- * return a reference to the system 2d Context
536
- * @name getContext
537
- * @memberof CanvasRenderer
538
- * @returns {CanvasRenderingContext2D}
539
- */
540
- getContext() {
541
- return this.backBufferContext2D;
542
- }
543
-
544
507
  /**
545
508
  * return a reference to the font 2d Context
546
509
  * @ignore
@@ -556,7 +519,7 @@ class CanvasRenderer extends Renderer {
556
519
  * @memberof CanvasRenderer
557
520
  */
558
521
  save() {
559
- this.backBufferContext2D.save();
522
+ this.getContext().save();
560
523
  }
561
524
 
562
525
  /**
@@ -565,12 +528,12 @@ class CanvasRenderer extends Renderer {
565
528
  * @memberof CanvasRenderer
566
529
  */
567
530
  restore() {
568
- this.backBufferContext2D.restore();
531
+ this.getContext().restore();
569
532
  this.currentColor.glArray[3] = this.getGlobalAlpha();
570
533
  this.currentScissor[0] = 0;
571
534
  this.currentScissor[1] = 0;
572
- this.currentScissor[2] = this.backBufferCanvas.width;
573
- this.currentScissor[3] = this.backBufferCanvas.height;
535
+ this.currentScissor[2] = this.getCanvas().width;
536
+ this.currentScissor[3] = this.getCanvas().height;
574
537
  }
575
538
 
576
539
  /**
@@ -580,7 +543,7 @@ class CanvasRenderer extends Renderer {
580
543
  * @param {number} angle in radians
581
544
  */
582
545
  rotate(angle) {
583
- this.backBufferContext2D.rotate(angle);
546
+ this.getContext().rotate(angle);
584
547
  }
585
548
 
586
549
  /**
@@ -591,7 +554,7 @@ class CanvasRenderer extends Renderer {
591
554
  * @param {number} y
592
555
  */
593
556
  scale(x, y) {
594
- this.backBufferContext2D.scale(x, y);
557
+ this.getContext().scale(x, y);
595
558
  }
596
559
 
597
560
  /**
@@ -602,8 +565,9 @@ class CanvasRenderer extends Renderer {
602
565
  * @param {Color|string} color css color value
603
566
  */
604
567
  setColor(color) {
605
- this.backBufferContext2D.strokeStyle =
606
- this.backBufferContext2D.fillStyle = (
568
+ var context = this.getContext();
569
+ context.strokeStyle =
570
+ context.fillStyle = (
607
571
  color instanceof Color ?
608
572
  color.toRGBA() :
609
573
  color
@@ -617,7 +581,7 @@ class CanvasRenderer extends Renderer {
617
581
  * @param {number} alpha 0.0 to 1.0 values accepted.
618
582
  */
619
583
  setGlobalAlpha(alpha) {
620
- this.backBufferContext2D.globalAlpha = this.currentColor.glArray[3] = alpha;
584
+ this.getContext().globalAlpha = this.currentColor.glArray[3] = alpha;
621
585
  }
622
586
 
623
587
  /**
@@ -627,7 +591,7 @@ class CanvasRenderer extends Renderer {
627
591
  * @returns {number} global alpha value
628
592
  */
629
593
  getGlobalAlpha() {
630
- return this.backBufferContext2D.globalAlpha;
594
+ return this.getContext().globalAlpha;
631
595
  }
632
596
 
633
597
  /**
@@ -637,7 +601,7 @@ class CanvasRenderer extends Renderer {
637
601
  * @param {number} width Line width
638
602
  */
639
603
  setLineWidth(width) {
640
- this.backBufferContext2D.lineWidth = width;
604
+ this.getContext().lineWidth = width;
641
605
  }
642
606
 
643
607
  /**
@@ -672,7 +636,7 @@ class CanvasRenderer extends Renderer {
672
636
  f |= 0;
673
637
  }
674
638
 
675
- this.backBufferContext2D.transform(a, b, c, d, e, f);
639
+ this.getContext().transform(a, b, c, d, e, f);
676
640
  }
677
641
 
678
642
  /**
@@ -684,9 +648,9 @@ class CanvasRenderer extends Renderer {
684
648
  */
685
649
  translate(x, y) {
686
650
  if (this.settings.subPixel === false) {
687
- this.backBufferContext2D.translate(~~x, ~~y);
651
+ this.getContext().translate(~~x, ~~y);
688
652
  } else {
689
- this.backBufferContext2D.translate(x, y);
653
+ this.getContext().translate(x, y);
690
654
  }
691
655
  }
692
656
 
@@ -704,14 +668,14 @@ class CanvasRenderer extends Renderer {
704
668
  * @param {number} height
705
669
  */
706
670
  clipRect(x, y, width, height) {
707
- var canvas = this.backBufferCanvas;
671
+ var canvas = this.getCanvas();
708
672
  // if requested box is different from the current canvas size;
709
673
  if (x !== 0 || y !== 0 || width !== canvas.width || height !== canvas.height) {
710
674
  var currentScissor = this.currentScissor;
711
675
  // if different from the current scissor box
712
676
  if (currentScissor[0] !== x || currentScissor[1] !== y ||
713
677
  currentScissor[2] !== width || currentScissor[3] !== height) {
714
- var context = this.backBufferContext2D;
678
+ var context = this.getContext();
715
679
  context.beginPath();
716
680
  context.rect(x, y, width, height);
717
681
  context.clip();
@@ -22,7 +22,6 @@ class Renderer {
22
22
  * @param {number} options.width The width of the canvas without scaling
23
23
  * @param {number} options.height The height of the canvas without scaling
24
24
  * @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
25
- * @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering (not applicable when using the WebGL Renderer)
26
25
  * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing, use false (default) for a pixelated effect.
27
26
  * @param {boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
28
27
  * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
@@ -84,13 +83,9 @@ class Renderer {
84
83
  } else if (typeof this.settings.canvas !== "undefined") {
85
84
  this.canvas = this.settings.canvas;
86
85
  } else {
87
- this.canvas = createCanvas(this.settings.zoomX, this.settings.zoomY);
86
+ this.canvas = createCanvas(this.settings.width, this.settings.height);
88
87
  }
89
88
 
90
- // canvas object and context
91
- this.backBufferCanvas = this.canvas;
92
- this.context = null;
93
-
94
89
  // global color
95
90
  this.currentColor = new Color(0, 0, 0, 1.0);
96
91
 
@@ -116,6 +111,13 @@ class Renderer {
116
111
  */
117
112
  clear() {}
118
113
 
114
+ /**
115
+ * render the main framebuffer on screen
116
+ * @name flush
117
+ * @memberof Renderer
118
+ */
119
+ flush() {}
120
+
119
121
  /**
120
122
  * Reset context state
121
123
  * @name reset
@@ -129,39 +131,29 @@ class Renderer {
129
131
  this.cache.clear();
130
132
  this.currentScissor[0] = 0;
131
133
  this.currentScissor[1] = 0;
132
- this.currentScissor[2] = this.backBufferCanvas.width;
133
- this.currentScissor[3] = this.backBufferCanvas.height;
134
+ this.currentScissor[2] = this.getCanvas().width;
135
+ this.currentScissor[3] = this.getCanvas().height;
134
136
  this.clearMask();
135
137
  }
136
138
 
137
139
  /**
138
- * return a reference to the system canvas
140
+ * return a reference to the canvas which this renderer draws to
139
141
  * @name getCanvas
140
142
  * @memberof Renderer
141
143
  * @returns {HTMLCanvasElement}
142
144
  */
143
145
  getCanvas() {
144
- return this.backBufferCanvas;
145
- }
146
-
147
- /**
148
- * return a reference to the screen canvas
149
- * @name getScreenCanvas
150
- * @memberof Renderer
151
- * @returns {HTMLCanvasElement}
152
- */
153
- getScreenCanvas() {
154
146
  return this.canvas;
155
147
  }
156
148
 
149
+
157
150
  /**
158
- * return a reference to the screen canvas corresponding 2d Context<br>
159
- * (will return buffered context if double buffering is enabled, or a reference to the Screen Context)
160
- * @name getScreenContext
151
+ * return a reference to this renderer canvas corresponding Context
152
+ * @name getContext
161
153
  * @memberof Renderer
162
- * @returns {CanvasRenderingContext2D}
154
+ * @returns {CanvasRenderingContext2D|WebGLRenderingContext}
163
155
  */
164
- getScreenContext() {
156
+ getContext() {
165
157
  return this.context;
166
158
  }
167
159
 
@@ -220,7 +212,7 @@ class Renderer {
220
212
  * @returns {number}
221
213
  */
222
214
  getWidth() {
223
- return this.backBufferCanvas.width;
215
+ return this.getCanvas().width;
224
216
  }
225
217
 
226
218
  /**
@@ -230,7 +222,7 @@ class Renderer {
230
222
  * @returns {number} height of the system Canvas
231
223
  */
232
224
  getHeight() {
233
- return this.backBufferCanvas.height;
225
+ return this.getCanvas().height;
234
226
  }
235
227
 
236
228
  /**
@@ -276,9 +268,10 @@ class Renderer {
276
268
  * @param {number} height new height of the canvas
277
269
  */
278
270
  resize(width, height) {
279
- if (width !== this.backBufferCanvas.width || height !== this.backBufferCanvas.height) {
280
- this.canvas.width = this.backBufferCanvas.width = width;
281
- this.canvas.height = this.backBufferCanvas.height = height;
271
+ var canvas = this.getCanvas();
272
+ if (width !== canvas.width || height !== canvas.height) {
273
+ canvas.width = width;
274
+ canvas.height = height;
282
275
  this.currentScissor[0] = 0;
283
276
  this.currentScissor[1] = 0;
284
277
  this.currentScissor[2] = width;
@@ -5,7 +5,8 @@ import { setPrefixed } from "./../../utils/agent.js";
5
5
  var defaultAttributes = {
6
6
  offscreenCanvas : false,
7
7
  willReadFrequently : false,
8
- antiAlias : false
8
+ antiAlias : false,
9
+ context: "2d"
9
10
  };
10
11
 
11
12
  /**
@@ -15,7 +16,8 @@ class CanvasTexture {
15
16
  /**
16
17
  * @param {number} width the desired width of the canvas
17
18
  * @param {number} height the desired height of the canvas
18
- * @param {object} attributes The attributes to create both the canvas and 2d context
19
+ * @param {object} attributes The attributes to create both the canvas and context
20
+ * @param {boolean} [attributes.context="2d"] the context type to be created ("2d", "webgl", "webgl2")
19
21
  * @param {boolean} [attributes.offscreenCanvas=false] will create an offscreenCanvas if true instead of a standard canvas
20
22
  * @param {boolean} [attributes.willReadFrequently=false] Indicates whether or not a lot of read-back operations are planned
21
23
  * @param {boolean} [attributes.antiAlias=false] Whether to enable anti-aliasing, use false (default) for a pixelated effect.
@@ -20,10 +20,9 @@ var designHeight = 0;
20
20
  var settings = {
21
21
  parent : undefined,
22
22
  renderer : 2, // AUTO
23
- doubleBuffering : false,
24
23
  autoScale : false,
25
24
  scale : 1.0,
26
- scaleMethod : "fit",
25
+ scaleMethod : "manual",
27
26
  transparent : false,
28
27
  blendMode : "normal",
29
28
  antiAlias : false,
@@ -65,7 +64,7 @@ function onresize() {
65
64
  var canvasMaxHeight = Infinity;
66
65
 
67
66
  if (globalThis.getComputedStyle) {
68
- var style = globalThis.getComputedStyle(renderer.getScreenCanvas(), null);
67
+ var style = globalThis.getComputedStyle(renderer.getCanvas(), null);
69
68
  canvasMaxWidth = parseInt(style.maxWidth, 10) || Infinity;
70
69
  canvasMaxHeight = parseInt(style.maxHeight, 10) || Infinity;
71
70
  }
@@ -119,6 +118,9 @@ function onresize() {
119
118
 
120
119
  // adjust scaling ratio based on the new scaling ratio
121
120
  scale(scaleX, scaleY);
121
+ } else {
122
+ // adjust scaling ratio based on the given settings
123
+ scale(settings.scale, settings.scale);
122
124
  }
123
125
  };
124
126
 
@@ -196,7 +198,6 @@ export let renderer = null;
196
198
  * @param {object} [options] The optional video/renderer parameters.<br> (see Renderer(s) documentation for further specific options)
197
199
  * @param {string|HTMLElement} [options.parent=document.body] the DOM parent element to hold the canvas in the HTML file
198
200
  * @param {number} [options.renderer=video.AUTO] renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO)
199
- * @param {boolean} [options.doubleBuffering=false] enable/disable double buffering
200
201
  * @param {number|string} [options.scale=1.0] enable scaling of the canvas ('auto' for automatic scaling)
201
202
  * @param {string} [options.scaleMethod="fit"] screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
202
203
  * @param {boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
@@ -211,8 +212,7 @@ export let renderer = null;
211
212
  * parent : "screen",
212
213
  * renderer : me.video.AUTO,
213
214
  * scale : "auto",
214
- * scaleMethod : "fit",
215
- * doubleBuffering : true
215
+ * scaleMethod : "fit"
216
216
  * });
217
217
  */
218
218
  export function init(width, height, options) {
@@ -228,7 +228,6 @@ export function init(width, height, options) {
228
228
  // sanitize potential given parameters
229
229
  settings.width = width;
230
230
  settings.height = height;
231
- settings.doubleBuffering = !!(settings.doubleBuffering);
232
231
  settings.transparent = !!(settings.transparent);
233
232
  settings.antiAlias = !!(settings.antiAlias);
234
233
  settings.failIfMajorPerformanceCaveat = !!(settings.failIfMajorPerformanceCaveat);
@@ -248,24 +247,21 @@ export function init(width, height, options) {
248
247
  console.log("melonJS 2 (v" + version + ") | http://melonjs.org" );
249
248
  }
250
249
 
251
- // override renderer settings if &webgl is defined in the URL
250
+ // override renderer settings if &webgl or &canvas is defined in the URL
252
251
  var uriFragment = utils.getUriFragment();
253
252
  if (uriFragment.webgl === true || uriFragment.webgl1 === true || uriFragment.webgl2 === true) {
254
253
  settings.renderer = WEBGL;
255
254
  if (uriFragment.webgl1 === true) {
256
255
  settings.preferWebGL1 = true;
257
256
  }
257
+ } else if (uriFragment.canvas === true) {
258
+ settings.renderer = CANVAS;
258
259
  }
259
260
 
260
261
  // normalize scale
261
262
  settings.scale = (settings.autoScale) ? 1.0 : (+settings.scale || 1.0);
262
263
  scaleRatio.set(settings.scale, settings.scale);
263
264
 
264
- // force double buffering if scaling is required
265
- if (settings.autoScale || (settings.scale !== 1.0)) {
266
- settings.doubleBuffering = true;
267
- }
268
-
269
265
  // hold the requested video size ratio
270
266
  designRatio = width / height;
271
267
  designWidth = width;
@@ -337,7 +333,7 @@ export function init(width, height, options) {
337
333
 
338
334
  // add our canvas (default to document.body if settings.parent is undefined)
339
335
  parent = device.getElement(typeof settings.parent !== "undefined" ? settings.parent : document.body);
340
- parent.appendChild(renderer.getScreenCanvas());
336
+ parent.appendChild(renderer.getCanvas());
341
337
 
342
338
  // Mobile browser hacks
343
339
  if (device.platform.isMobile) {
@@ -434,8 +430,8 @@ export function getParent() {
434
430
  * @param {number} y y scaling multiplier
435
431
  */
436
432
  export function scale(x, y) {
437
- var canvas = renderer.getScreenCanvas();
438
- var context = renderer.getScreenContext();
433
+ var canvas = renderer.getCanvas();
434
+ var context = renderer.getContext();
439
435
  var settings = renderer.settings;
440
436
  var pixelRatio = device.devicePixelRatio;
441
437
 
@@ -132,8 +132,8 @@ class WebGLCompositor {
132
132
  // initial viewport size
133
133
  this.setViewport(
134
134
  0, 0,
135
- this.renderer.getScreenCanvas().width,
136
- this.renderer.getScreenCanvas().height
135
+ this.renderer.getCanvas().width,
136
+ this.renderer.getCanvas().height
137
137
  );
138
138
 
139
139
  // Initialize clear color
@@ -20,7 +20,6 @@ class WebGLRenderer extends Renderer {
20
20
  * @param {number} options.width The width of the canvas without scaling
21
21
  * @param {number} options.height The height of the canvas without scaling
22
22
  * @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
23
- * @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering (not applicable when using the WebGL Renderer)
24
23
  * @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
25
24
  * @param {boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
26
25
  * @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
@@ -72,7 +71,7 @@ class WebGLRenderer extends Renderer {
72
71
  * @memberof WebGLRenderer
73
72
  * @type {WebGLRenderingContext}
74
73
  */
75
- this.context = this.gl = this.getContextGL(this.getScreenCanvas(), options.transparent);
74
+ this.context = this.gl = this.getContextGL(this.getCanvas(), options.transparent);
76
75
 
77
76
  /**
78
77
  * Maximum number of texture unit supported under the current context
@@ -154,13 +153,13 @@ class WebGLRenderer extends Renderer {
154
153
  // to simulate context lost and restore in WebGL:
155
154
  // var ctx = me.video.renderer.context.getExtension('WEBGL_lose_context');
156
155
  // ctx.loseContext()
157
- this.getScreenCanvas().addEventListener("webglcontextlost", (e) => {
156
+ this.getCanvas().addEventListener("webglcontextlost", (e) => {
158
157
  e.preventDefault();
159
158
  this.isContextValid = false;
160
159
  event.emit(event.ONCONTEXT_LOST, this);
161
160
  }, false );
162
161
  // ctx.restoreContext()
163
- this.getScreenCanvas().addEventListener("webglcontextrestored", () => {
162
+ this.getCanvas().addEventListener("webglcontextrestored", () => {
164
163
  this.reset();
165
164
  this.isContextValid = true;
166
165
  event.emit(event.ONCONTEXT_RESTORED, this);
@@ -231,7 +230,7 @@ class WebGLRenderer extends Renderer {
231
230
  */
232
231
  createFontTexture(cache) {
233
232
  if (typeof this.fontTexture === "undefined") {
234
- var canvas = this.backBufferCanvas;
233
+ var canvas = this.getCanvas();
235
234
  var width = canvas.width;
236
235
  var height = canvas.height;
237
236
 
@@ -459,17 +458,6 @@ class WebGLRenderer extends Renderer {
459
458
  this.currentCompositor.addQuad(pattern, x, y, width, height, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32());
460
459
  }
461
460
 
462
-
463
- /**
464
- * return a reference to the screen canvas corresponding WebGL Context
465
- * @name getScreenContext
466
- * @memberof WebGLRenderer
467
- * @returns {WebGLRenderingContext}
468
- */
469
- getScreenContext() {
470
- return this.gl;
471
- }
472
-
473
461
  /**
474
462
  * Returns the WebGL Context object of the given Canvas
475
463
  * @name getContextGL
@@ -627,8 +615,8 @@ class WebGLRenderer extends Renderer {
627
615
  this.gl.disable(this.gl.SCISSOR_TEST);
628
616
  this.currentScissor[0] = 0;
629
617
  this.currentScissor[1] = 0;
630
- this.currentScissor[2] = this.backBufferCanvas.width;
631
- this.currentScissor[3] = this.backBufferCanvas.height;
618
+ this.currentScissor[2] = this.getCanvas().width;
619
+ this.currentScissor[3] = this.getCanvas().height;
632
620
  }
633
621
  }
634
622
 
@@ -719,7 +707,7 @@ class WebGLRenderer extends Renderer {
719
707
  * @param {number} width Line width
720
708
  */
721
709
  setLineWidth(width) {
722
- this.getScreenContext().lineWidth(width);
710
+ this.getContext().lineWidth(width);
723
711
  }
724
712
 
725
713
  /**
@@ -1015,7 +1003,7 @@ class WebGLRenderer extends Renderer {
1015
1003
  * @param {number} height
1016
1004
  */
1017
1005
  clipRect(x, y, width, height) {
1018
- var canvas = this.backBufferCanvas;
1006
+ var canvas = this.getCanvas();
1019
1007
  var gl = this.gl;
1020
1008
  // if requested box is different from the current canvas size
1021
1009
  if (x !== 0 || y !== 0 || width !== canvas.width || height !== canvas.height) {