<commit_before>/**
 * @module ogs.vgl
 */

/**
 * Create a new instance of clas blendFunction
 *
 * @class
 * @param source
 * @param destination
 * @returns {vglModule.blendFunction}
 */
vglModule.blendFunction = function(source, destination) {

  if (!(this instanceof vglModule.blendFunction)) {
    return new vglModule.blendFunction(source, destination);
  }

  /** @private */
  var m_source = source;

  /** @private */
  var m_destination = destination;

  /**
   * Apply blend function to the current state
   *
   * @param {vglModule.renderState}
   */
  this.apply = function(renderState) {
    gl.blendFunc(m_source, m_destination);
  };

  return this;
};

/**
 * Create a new instance of class blend
 *
 * @class
 * @returns {vglModule.blend}
 */
vglModule.blend = function() {

  if (!(this instanceof vglModule.blend)) {
    return new vglModule.blend();
  }
  vglModule.materialAttribute.call(this, materialAttributeType.Blend);

  /** @private */
  var m_wasEnabled = false;

  /** @private */
  var m_blendFunction = vglModule.blendFunction(gl.SRC_ALPHA,
                                                gl.ONE_MINUS_SRC_ALPHA);

  /**
   * Bind blend attribute
   *
   * @param {vglModule.renderState}
   */
  this.bind = function(renderState) {
    m_wasEnabled = gl.isEnabled(gl.BLEND);

    if (this.enabled()) {
      gl.enable(gl.BLEND);
      m_blendFunction.apply(renderState);
    }
    else {
      gl.disable(gl.BLEND);
    }

    return true;
  };

  /**
   * Undo bind blend attribute
   *
   * @param {vglModule.renderState}
   */
  this.undoBind = function(renderState) {
    if (m_wasEnabled) {
      gl.enable(gl.BLEND);
    }
    else {
      gl.disable(gl.BLEND);
    }
    return true;
  };

  return this;
};

inherit(vglModule.blend, vglModule.materialAttribute);<commit_msg>Fixed blending<commit_after>/**
 * @module ogs.vgl
 */

/**
 * Create a new instance of clas blendFunction
 *
 * @class
 * @param source
 * @param destination
 * @returns {vglModule.blendFunction}
 */
vglModule.blendFunction = function(source, destination) {

  if (!(this instanceof vglModule.blendFunction)) {
    return new vglModule.blendFunction(source, destination);
  }

  /** @private */
  var m_source = source;

  /** @private */
  var m_destination = destination;

  /**
   * Apply blend function to the current state
   *
   * @param {vglModule.renderState}
   */
  this.apply = function(renderState) {
    gl.blendFuncSeparate(m_source, m_destination, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  };

  return this;
};

/**
 * Create a new instance of class blend
 *
 * @class
 * @returns {vglModule.blend}
 */
vglModule.blend = function() {

  if (!(this instanceof vglModule.blend)) {
    return new vglModule.blend();
  }
  vglModule.materialAttribute.call(this, materialAttributeType.Blend);

  /** @private */
  var m_wasEnabled = false;

  /** @private */
  var m_blendFunction = vglModule.blendFunction(gl.SRC_ALPHA,
                                                gl.ONE_MINUS_SRC_ALPHA);

  /**
   * Bind blend attribute
   *
   * @param {vglModule.renderState}
   */
  this.bind = function(renderState) {
    m_wasEnabled = gl.isEnabled(gl.BLEND);

    if (this.enabled()) {
      gl.enable(gl.BLEND);
      m_blendFunction.apply(renderState);
    }
    else {
      gl.disable(gl.BLEND);
    }

    return true;
  };

  /**
   * Undo bind blend attribute
   *
   * @param {vglModule.renderState}
   */
  this.undoBind = function(renderState) {
    if (m_wasEnabled) {
      gl.enable(gl.BLEND);
    }
    else {
      gl.disable(gl.BLEND);
    }

    return true;
  };

  return this;
};

inherit(vglModule.blend, vglModule.materialAttribute);
{'fraction_non_alphanumeric': 0.13453159041394336, 'fraction_numerical': 0.0, 'mean_word_length': 2.713852376137513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1719675', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1225, 'n_words': 236}