'use strict';

var constants = require('../../constants.js');
var extensions = require('../../extensions.js');

class MultisampleSystem {
  constructor(renderer) {
    this.renderer = renderer;
  }
  contextChange(gl) {
    let samples;
    if (this.renderer.context.webGLVersion === 1) {
      const framebuffer = gl.getParameter(gl.FRAMEBUFFER_BINDING);
      gl.bindFramebuffer(gl.FRAMEBUFFER, null);
      samples = gl.getParameter(gl.SAMPLES);
      gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
    } else {
      const framebuffer = gl.getParameter(gl.DRAW_FRAMEBUFFER_BINDING);
      gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, null);
      samples = gl.getParameter(gl.SAMPLES);
      gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, framebuffer);
    }
    if (samples >= constants.MSAA_QUALITY.HIGH) {
      this.multisample = constants.MSAA_QUALITY.HIGH;
    } else if (samples >= constants.MSAA_QUALITY.MEDIUM) {
      this.multisample = constants.MSAA_QUALITY.MEDIUM;
    } else if (samples >= constants.MSAA_QUALITY.LOW) {
      this.multisample = constants.MSAA_QUALITY.LOW;
    } else {
      this.multisample = constants.MSAA_QUALITY.NONE;
    }
  }
  destroy() {
  }
}
MultisampleSystem.extension = {
  type: extensions.ExtensionType.RendererSystem,
  name: "_multisample"
};
extensions.extensions.add(MultisampleSystem);

exports.MultisampleSystem = MultisampleSystem;
//# sourceMappingURL=MultisampleSystem.js.map
