Example usage for org.lwjgl.opengl EXTStencilTwoSide glActiveStencilFaceEXT

List of usage examples for org.lwjgl.opengl EXTStencilTwoSide glActiveStencilFaceEXT

Introduction

In this page you can find the example usage for org.lwjgl.opengl EXTStencilTwoSide glActiveStencilFaceEXT.

Prototype

public static native void glActiveStencilFaceEXT(@NativeType("GLenum") int face);

Source Link

Usage

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

License:Open Source License

public static void apply(final StencilState state) {
    // ask for the current state record
    final RenderContext context = ContextManager.getCurrentContext();
    final ContextCapabilities caps = context.getCapabilities();
    final StencilStateRecord record = (StencilStateRecord) context.getStateRecord(StateType.Stencil);
    context.setCurrentState(StateType.Stencil, state);

    setEnabled(state.isEnabled(), caps.isTwoSidedStencilSupported() ? state.isUseTwoSided() : false, record,
            caps);//  ww  w. j av  a 2  s.com
    if (state.isEnabled()) {
        if (state.isUseTwoSided() && caps.isTwoSidedStencilSupported()) {
            EXTStencilTwoSide.glActiveStencilFaceEXT(GL11.GL_BACK);
            applyMask(state.getStencilWriteMaskBack(), record, 2);
            applyFunc(getGLStencilFunction(state.getStencilFunctionBack()), state.getStencilReferenceBack(),
                    state.getStencilFuncMaskBack(), record, 2);
            applyOp(getGLStencilOp(state.getStencilOpFailBack(), caps),
                    getGLStencilOp(state.getStencilOpZFailBack(), caps),
                    getGLStencilOp(state.getStencilOpZPassBack(), caps), record, 2);

            EXTStencilTwoSide.glActiveStencilFaceEXT(GL11.GL_FRONT);
            applyMask(state.getStencilWriteMaskFront(), record, 1);
            applyFunc(getGLStencilFunction(state.getStencilFunctionFront()), state.getStencilReferenceFront(),
                    state.getStencilFuncMaskFront(), record, 1);
            applyOp(getGLStencilOp(state.getStencilOpFailFront(), caps),
                    getGLStencilOp(state.getStencilOpZFailFront(), caps),
                    getGLStencilOp(state.getStencilOpZPassFront(), caps), record, 1);
        } else {
            applyMask(state.getStencilWriteMaskFront(), record, 0);
            applyFunc(getGLStencilFunction(state.getStencilFunctionFront()), state.getStencilReferenceFront(),
                    state.getStencilFuncMaskFront(), record, 0);
            applyOp(getGLStencilOp(state.getStencilOpFailFront(), caps),
                    getGLStencilOp(state.getStencilOpZFailFront(), caps),
                    getGLStencilOp(state.getStencilOpZPassFront(), caps), record, 0);
        }
    }

    if (!record.isValid()) {
        record.validate();
    }
}