Example usage for org.lwjgl.opengl ARBImaging glBlendEquation

List of usage examples for org.lwjgl.opengl ARBImaging glBlendEquation

Introduction

In this page you can find the example usage for org.lwjgl.opengl ARBImaging glBlendEquation.

Prototype

public static void glBlendEquation(@NativeType("GLenum") int mode) 

Source Link

Document

Controls the blend equations used for per-fragment blending.

Usage

From source file:com.ardor3d.scene.state.lwjgl.LwjglBlendStateUtil.java

License:Open Source License

protected static void applyBlendEquations(final boolean enabled, final BlendState state,
        final BlendStateRecord record, final ContextCapabilities caps) {
    if (record.isValid()) {
        if (enabled) {
            if (!record.blendEnabled) {
                GL11.glEnable(GL11.GL_BLEND);
                record.blendEnabled = true;
            }// ww  w.j a  va 2 s. c  om
            final int blendEqRGB = getGLEquationValue(state.getBlendEquationRGB(), caps);
            if (caps.isSeparateBlendEquationsSupported()) {
                final int blendEqAlpha = getGLEquationValue(state.getBlendEquationAlpha(), caps);
                if (record.blendEqRGB != blendEqRGB || record.blendEqAlpha != blendEqAlpha) {
                    EXTBlendEquationSeparate.glBlendEquationSeparateEXT(blendEqRGB, blendEqAlpha);
                    record.blendEqRGB = blendEqRGB;
                    record.blendEqAlpha = blendEqAlpha;
                }
            } else if (caps.isBlendEquationSupported()) {
                if (record.blendEqRGB != blendEqRGB) {
                    ARBImaging.glBlendEquation(blendEqRGB);
                    record.blendEqRGB = blendEqRGB;
                }
            }
        } else if (record.blendEnabled) {
            GL11.glDisable(GL11.GL_BLEND);
            record.blendEnabled = false;
        }

    } else {
        if (enabled) {
            GL11.glEnable(GL11.GL_BLEND);
            record.blendEnabled = true;
            final int blendEqRGB = getGLEquationValue(state.getBlendEquationRGB(), caps);
            if (caps.isSeparateBlendEquationsSupported()) {
                final int blendEqAlpha = getGLEquationValue(state.getBlendEquationAlpha(), caps);
                EXTBlendEquationSeparate.glBlendEquationSeparateEXT(blendEqRGB, blendEqAlpha);
                record.blendEqRGB = blendEqRGB;
                record.blendEqAlpha = blendEqAlpha;
            } else if (caps.isBlendEquationSupported()) {
                ARBImaging.glBlendEquation(blendEqRGB);
                record.blendEqRGB = blendEqRGB;
            }
        } else {
            GL11.glDisable(GL11.GL_BLEND);
            record.blendEnabled = false;
        }
    }
}