function restoreContext()

in seriously.js [1181:1237]


		function restoreContext() {
			var context,
				target,
				i,
				node;

			if (primaryTarget && !gl) {
				target = primaryTarget.target;

				//todo: if too many webglcontextlost events fired in too short a time, abort
				//todo: consider allowing "manual" control of restoring context

				if (target instanceof WebGLFramebuffer) {
					Seriously.logger.error('Unable to restore target built on WebGLFramebuffer');
					return;
				}

				context = getWebGlContext(target, {
					alpha: true,
					premultipliedAlpha: false,
					preserveDrawingBuffer: true,
					stencil: true,
					debugContext: primaryTarget.debugContext
				});

				if (context) {
					if (context.isContextLost()) {
						Seriously.logger.error('Unable to restore WebGL Context');
						return;
					}

					attachContext(context);

					if (primaryTarget.renderToTexture) {
						primaryTarget.frameBuffer = new FrameBuffer(gl, primaryTarget.width, primaryTarget.height, false);
					} else {
						primaryTarget.frameBuffer = {
							frameBuffer: null
						};
					}

					/*
					Set all nodes dirty. In most cases, it should only be necessary
					to set sources dirty, but we want to make sure unattached nodes are covered

					This should get renderDaemon running again if necessary.
					*/
					for (i = 0; i < nodes.length; i++) {
						node = nodes[i];
						node.setDirty();
						node.emit('webglcontextrestored');
					}

					Seriously.logger.log('WebGL context restored');
				}
			}
		}