Preserve the drawing buffer by default for WebGL layers

This commit is contained in:
Tim Schaub
2021-12-18 11:36:44 -07:00
parent c8cfbfccf8
commit 0cc3bae8fe
8 changed files with 72 additions and 2 deletions
+4 -1
View File
@@ -2,6 +2,8 @@
* @module ol/webgl
*/
import {assign} from './obj.js';
/**
* Constants taken from goog.webgl
*/
@@ -89,10 +91,11 @@ const CONTEXT_IDS = ['experimental-webgl', 'webgl', 'webkit-3d', 'moz-webgl'];
* @return {WebGLRenderingContext} WebGL rendering context.
*/
export function getContext(canvas, opt_attributes) {
const attributes = assign({preserveDrawingBuffer: true}, opt_attributes);
const ii = CONTEXT_IDS.length;
for (let i = 0; i < ii; ++i) {
try {
const context = canvas.getContext(CONTEXT_IDS[i], opt_attributes);
const context = canvas.getContext(CONTEXT_IDS[i], attributes);
if (context) {
return /** @type {!WebGLRenderingContext} */ (context);
}