Example usage for org.lwjgl.opengl EXTBlendFuncSeparate glBlendFuncSeparateEXT

List of usage examples for org.lwjgl.opengl EXTBlendFuncSeparate glBlendFuncSeparateEXT

Introduction

In this page you can find the example usage for org.lwjgl.opengl EXTBlendFuncSeparate glBlendFuncSeparateEXT.

Prototype

public static native void glBlendFuncSeparateEXT(@NativeType("GLenum") int sfactorRGB,
            @NativeType("GLenum") int dfactorRGB, @NativeType("GLenum") int sfactorAlpha,
            @NativeType("GLenum") int dfactorAlpha);

Source Link

Usage

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

License:Open Source License

protected static void applyBlendFunctions(final boolean enabled, final BlendState state,
        final BlendStateRecord record, final ContextCapabilities caps) {
    if (record.isValid()) {
        if (enabled) {
            final int glSrcRGB = getGLSrcValue(state.getSourceFunctionRGB(), caps);
            final int glDstRGB = getGLDstValue(state.getDestinationFunctionRGB(), caps);
            if (caps.isSeparateBlendFunctionsSupported()) {
                final int glSrcAlpha = getGLSrcValue(state.getSourceFunctionAlpha(), caps);
                final int glDstAlpha = getGLDstValue(state.getDestinationFunctionAlpha(), caps);
                if (record.srcFactorRGB != glSrcRGB || record.dstFactorRGB != glDstRGB
                        || record.srcFactorAlpha != glSrcAlpha || record.dstFactorAlpha != glDstAlpha) {
                    EXTBlendFuncSeparate.glBlendFuncSeparateEXT(glSrcRGB, glDstRGB, glSrcAlpha, glDstAlpha);
                    record.srcFactorRGB = glSrcRGB;
                    record.dstFactorRGB = glDstRGB;
                    record.srcFactorAlpha = glSrcAlpha;
                    record.dstFactorAlpha = glDstAlpha;
                }//from w  w w  .  jav a2 s . c om
            } else if (record.srcFactorRGB != glSrcRGB || record.dstFactorRGB != glDstRGB) {
                GL11.glBlendFunc(glSrcRGB, glDstRGB);
                record.srcFactorRGB = glSrcRGB;
                record.dstFactorRGB = glDstRGB;
            }
        }
    } else {
        if (enabled) {
            final int glSrcRGB = getGLSrcValue(state.getSourceFunctionRGB(), caps);
            final int glDstRGB = getGLDstValue(state.getDestinationFunctionRGB(), caps);
            if (caps.isSeparateBlendFunctionsSupported()) {
                final int glSrcAlpha = getGLSrcValue(state.getSourceFunctionAlpha(), caps);
                final int glDstAlpha = getGLDstValue(state.getDestinationFunctionAlpha(), caps);
                EXTBlendFuncSeparate.glBlendFuncSeparateEXT(glSrcRGB, glDstRGB, glSrcAlpha, glDstAlpha);
                record.srcFactorRGB = glSrcRGB;
                record.dstFactorRGB = glDstRGB;
                record.srcFactorAlpha = glSrcAlpha;
                record.dstFactorAlpha = glDstAlpha;
            } else {
                GL11.glBlendFunc(glSrcRGB, glDstRGB);
                record.srcFactorRGB = glSrcRGB;
                record.dstFactorRGB = glDstRGB;
            }
        }
    }
}