void activate(RenderContextWebGL renderContext)

Source

void activate(RenderContextWebGL renderContext) {

  if (this.contextIdentifier != renderContext.contextIdentifier) {

    _renderContext = renderContext;
    _contextIdentifier = renderContext.contextIdentifier;
    _renderingContext = renderContext.rawContext;
    _framebuffer = renderContext.rawContext.createFramebuffer();
    _renderContext.activateRenderTexture(_renderTexture);
    _renderContext.activateRenderStencilBuffer(_renderStencilBuffer);

    var target = gl.FRAMEBUFFER;
    var color = gl.COLOR_ATTACHMENT0;
    var colorTarget = gl.TEXTURE_2D;
    var colorData = _renderTexture.texture;
    var stencil = gl.DEPTH_STENCIL_ATTACHMENT;
    var stencilTarget = gl.RENDERBUFFER;
    var stencilData = _renderStencilBuffer.renderbuffer;

    _renderingContext.bindFramebuffer(target, _framebuffer);
    _renderingContext.framebufferTexture2D(target, color, colorTarget, colorData, 0);
    _renderingContext.framebufferRenderbuffer(target, stencil, stencilTarget, stencilData);

  } else {

    _renderingContext.bindFramebuffer(gl.FRAMEBUFFER, _framebuffer);

  }
}