Example usage for org.lwjgl.opengl GL11 glDisable

List of usage examples for org.lwjgl.opengl GL11 glDisable

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glDisable.

Prototype

public static void glDisable(@NativeType("GLenum") int target) 

Source Link

Document

Disables the specified OpenGL state.

Usage

From source file:com.ardor3d.renderer.lwjgl.LwjglPbufferTextureRenderer.java

License:Open Source License

@Override
protected void clearBuffers(final int clear) {
    GL11.glDisable(GL11.GL_SCISSOR_TEST);
    _parentRenderer.clearBuffers(clear);
}

From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java

License:Open Source License

public void applyNormalsMode(final NormalsMode normalsMode, final ReadOnlyTransform worldTransform) {
    final RenderContext context = ContextManager.getCurrentContext();
    final RendererRecord rendRecord = context.getRendererRecord();
    if (normalsMode != NormalsMode.Off) {
        final ContextCapabilities caps = context.getCapabilities();
        switch (normalsMode) {
        case NormalizeIfScaled:
            if (worldTransform.isRotationMatrix()) {
                final ReadOnlyVector3 scale = worldTransform.getScale();
                if (!(scale.getX() == 1.0 && scale.getY() == 1.0 && scale.getZ() == 1.0)) {
                    if (scale.getX() == scale.getY() && scale.getY() == scale.getZ()
                            && caps.isOpenGL1_2Supported()
                            && rendRecord.getNormalMode() != GL12.GL_RESCALE_NORMAL) {
                        if (rendRecord.getNormalMode() == GL11.GL_NORMALIZE) {
                            GL11.glDisable(GL11.GL_NORMALIZE);
                        }//ww w.j a  v  a  2  s.  c  o  m
                        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
                        rendRecord.setNormalMode(GL12.GL_RESCALE_NORMAL);
                    } else if (rendRecord.getNormalMode() != GL11.GL_NORMALIZE) {
                        if (rendRecord.getNormalMode() == GL12.GL_RESCALE_NORMAL) {
                            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
                        }
                        GL11.glEnable(GL11.GL_NORMALIZE);
                        rendRecord.setNormalMode(GL11.GL_NORMALIZE);
                    }
                } else {
                    if (rendRecord.getNormalMode() == GL12.GL_RESCALE_NORMAL) {
                        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
                    } else if (rendRecord.getNormalMode() == GL11.GL_NORMALIZE) {
                        GL11.glDisable(GL11.GL_NORMALIZE);
                    }
                    rendRecord.setNormalMode(GL11.GL_ZERO);
                }
            } else {
                if (!worldTransform.getMatrix().isIdentity()) {
                    // *might* be scaled...
                    if (rendRecord.getNormalMode() != GL11.GL_NORMALIZE) {
                        if (rendRecord.getNormalMode() == GL12.GL_RESCALE_NORMAL) {
                            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
                        }
                        GL11.glEnable(GL11.GL_NORMALIZE);
                        rendRecord.setNormalMode(GL11.GL_NORMALIZE);
                    }
                } else {
                    // not scaled
                    if (rendRecord.getNormalMode() == GL12.GL_RESCALE_NORMAL) {
                        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
                    } else if (rendRecord.getNormalMode() == GL11.GL_NORMALIZE) {
                        GL11.glDisable(GL11.GL_NORMALIZE);
                    }
                    rendRecord.setNormalMode(GL11.GL_ZERO);
                }
            }
            break;
        case AlwaysNormalize:
            if (rendRecord.getNormalMode() != GL11.GL_NORMALIZE) {
                if (rendRecord.getNormalMode() == GL12.GL_RESCALE_NORMAL) {
                    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
                }
                GL11.glEnable(GL11.GL_NORMALIZE);
                rendRecord.setNormalMode(GL11.GL_NORMALIZE);
            }
            break;
        case UseProvided:
        default:
            if (rendRecord.getNormalMode() == GL12.GL_RESCALE_NORMAL) {
                GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            } else if (rendRecord.getNormalMode() == GL11.GL_NORMALIZE) {
                GL11.glDisable(GL11.GL_NORMALIZE);
            }
            rendRecord.setNormalMode(GL11.GL_ZERO);
            break;
        }
    } else {
        if (rendRecord.getNormalMode() == GL12.GL_RESCALE_NORMAL) {
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        } else if (rendRecord.getNormalMode() == GL11.GL_NORMALIZE) {
            GL11.glDisable(GL11.GL_NORMALIZE);
        }
        rendRecord.setNormalMode(GL11.GL_ZERO);
    }
}

From source file:com.ardor3d.renderer.lwjgl.LwjglRenderer.java

License:Open Source License

public void setupLineParameters(final float lineWidth, final int stippleFactor, final short stipplePattern,
        final boolean antialiased) {
    final LineRecord lineRecord = ContextManager.getCurrentContext().getLineRecord();

    if (!lineRecord.isValid() || lineRecord.width != lineWidth) {
        GL11.glLineWidth(lineWidth);/* w ww.ja va 2 s.c om*/
        lineRecord.width = lineWidth;
    }

    if (stipplePattern != (short) 0xFFFF) {
        if (!lineRecord.isValid() || !lineRecord.stippled) {
            GL11.glEnable(GL11.GL_LINE_STIPPLE);
            lineRecord.stippled = true;
        }

        if (!lineRecord.isValid() || stippleFactor != lineRecord.stippleFactor
                || stipplePattern != lineRecord.stipplePattern) {
            GL11.glLineStipple(stippleFactor, stipplePattern);
            lineRecord.stippleFactor = stippleFactor;
            lineRecord.stipplePattern = stipplePattern;
        }
    } else if (!lineRecord.isValid() || lineRecord.stippled) {
        GL11.glDisable(GL11.GL_LINE_STIPPLE);
        lineRecord.stippled = false;
    }

    if (antialiased) {
        if (!lineRecord.isValid() || !lineRecord.smoothed) {
            GL11.glEnable(GL11.GL_LINE_SMOOTH);
            lineRecord.smoothed = true;
        }
        if (!lineRecord.isValid() || lineRecord.smoothHint != GL11.GL_NICEST) {
            GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
            lineRecord.smoothHint = GL11.GL_NICEST;
        }
    } else if (!lineRecord.isValid() || lineRecord.smoothed) {
        GL11.glDisable(GL11.GL_LINE_SMOOTH);
        lineRecord.smoothed = false;
    }

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

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;
            }/*w w w.j a  va 2 s.  c  o  m*/
            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;
        }
    }
}

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

License:Open Source License

protected static void applyAlphaCoverage(final boolean sampleAlphaToCoverageEnabled,
        final boolean sampleAlphaToOneEnabled, final BlendStateRecord record, final ContextCapabilities caps) {
    if (record.isValid()) {
        if (sampleAlphaToCoverageEnabled != record.sampleAlphaToCoverageEnabled) {
            if (sampleAlphaToCoverageEnabled) {
                GL11.glEnable(ARBMultisample.GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
            } else {
                GL11.glDisable(ARBMultisample.GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
            }//from   w  ww  .  ja  v  a2s .  co m
            record.sampleAlphaToCoverageEnabled = sampleAlphaToCoverageEnabled;
        }
        if (sampleAlphaToOneEnabled != record.sampleAlphaToOneEnabled) {
            if (sampleAlphaToOneEnabled) {
                GL11.glEnable(ARBMultisample.GL_SAMPLE_ALPHA_TO_ONE_ARB);
            } else {
                GL11.glDisable(ARBMultisample.GL_SAMPLE_ALPHA_TO_ONE_ARB);
            }
            record.sampleAlphaToOneEnabled = sampleAlphaToOneEnabled;
        }
    } else {
        if (sampleAlphaToCoverageEnabled) {
            GL11.glEnable(ARBMultisample.GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
        } else {
            GL11.glDisable(ARBMultisample.GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
        }
        record.sampleAlphaToCoverageEnabled = sampleAlphaToCoverageEnabled;
        if (sampleAlphaToOneEnabled) {
            GL11.glEnable(ARBMultisample.GL_SAMPLE_ALPHA_TO_ONE_ARB);
        } else {
            GL11.glDisable(ARBMultisample.GL_SAMPLE_ALPHA_TO_ONE_ARB);
        }
        record.sampleAlphaToOneEnabled = sampleAlphaToOneEnabled;
    }
}

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

License:Open Source License

protected static void applySampleCoverage(final boolean enabled, final BlendState state,
        final BlendStateRecord record, final ContextCapabilities caps) {

    final boolean coverageInverted = state.isSampleCoverageInverted();
    final float coverageValue = state.getSampleCoverage();

    if (record.isValid()) {
        if (enabled) {
            if (!record.sampleCoverageEnabled) {
                GL11.glEnable(ARBMultisample.GL_SAMPLE_COVERAGE_ARB);
                record.sampleCoverageEnabled = true;
            }/*  w w  w  . j av a2s  .com*/
            if (record.sampleCoverageInverted != coverageInverted || record.sampleCoverage != coverageValue) {
                ARBMultisample.glSampleCoverageARB(coverageValue, coverageInverted);
                record.sampleCoverageInverted = coverageInverted;
                record.sampleCoverage = coverageValue;
            }
        } else {
            if (record.sampleCoverageEnabled) {
                GL11.glDisable(ARBMultisample.GL_SAMPLE_COVERAGE_ARB);
                record.sampleCoverageEnabled = false;
            }
        }
    } else {
        if (enabled) {
            GL11.glEnable(ARBMultisample.GL_SAMPLE_COVERAGE_ARB);
            record.sampleCoverageEnabled = true;
            ARBMultisample.glSampleCoverageARB(coverageValue, coverageInverted);
            record.sampleCoverageInverted = coverageInverted;
            record.sampleCoverage = coverageValue;
        } else {
            GL11.glDisable(ARBMultisample.GL_SAMPLE_COVERAGE_ARB);
            record.sampleCoverageEnabled = false;
        }
    }
}

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

License:Open Source License

protected static void applyTest(final boolean enabled, final BlendState state, final BlendStateRecord record) {
    if (record.isValid()) {
        if (enabled) {
            if (!record.testEnabled) {
                GL11.glEnable(GL11.GL_ALPHA_TEST);
                record.testEnabled = true;
            }/*  ww w.  j  a  v a2 s.  c o m*/
            final int glFunc = getGLFuncValue(state.getTestFunction());
            if (record.alphaFunc != glFunc || record.alphaRef != state.getReference()) {
                GL11.glAlphaFunc(glFunc, state.getReference());
                record.alphaFunc = glFunc;
                record.alphaRef = state.getReference();
            }
        } else if (record.testEnabled) {
            GL11.glDisable(GL11.GL_ALPHA_TEST);
            record.testEnabled = false;
        }

    } else {
        if (enabled) {
            GL11.glEnable(GL11.GL_ALPHA_TEST);
            record.testEnabled = true;
            final int glFunc = getGLFuncValue(state.getTestFunction());
            GL11.glAlphaFunc(glFunc, state.getReference());
            record.alphaFunc = glFunc;
            record.alphaRef = state.getReference();
        } else {
            GL11.glDisable(GL11.GL_ALPHA_TEST);
            record.testEnabled = false;
        }
    }
}

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

License:Open Source License

private static void enableClipPlane(final int planeIndex, final boolean enable, final ClipState state,
        final ClipStateRecord record) {
    if (enable) {
        if (!record.isValid() || !record.planeEnabled[planeIndex]) {
            GL11.glEnable(GL11.GL_CLIP_PLANE0 + planeIndex);
            record.planeEnabled[planeIndex] = true;
        }/*from   www  .  ja  v a2s  .  co m*/

        record.buf.rewind();
        ((DoubleBuffer) record.buf).put(state.getPlaneEquations(planeIndex));
        record.buf.flip();
        GL11.glClipPlane(GL11.GL_CLIP_PLANE0 + planeIndex, (DoubleBuffer) record.buf);

    } else {
        if (!record.isValid() || record.planeEnabled[planeIndex]) {
            GL11.glDisable(GL11.GL_CLIP_PLANE0 + planeIndex);
            record.planeEnabled[planeIndex] = false;
        }
    }
}

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

License:Open Source License

private static void setCullEnabled(final boolean enable, final CullStateRecord record) {
    if (!record.isValid() || record.enabled != enable) {
        if (enable) {
            GL11.glEnable(GL11.GL_CULL_FACE);
        } else {//from  w w  w. j  av a 2  s . c  om
            GL11.glDisable(GL11.GL_CULL_FACE);
        }
        record.enabled = enable;
    }
}

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

License:Open Source License

private static void enableFog(final boolean enable, final FogStateRecord record) {
    if (record.isValid()) {
        if (enable && !record.enabled) {
            GL11.glEnable(GL11.GL_FOG);/*from  w  w  w  . j  av  a2s .com*/
            record.enabled = true;
        } else if (!enable && record.enabled) {
            GL11.glDisable(GL11.GL_FOG);
            record.enabled = false;
        }
    } else {
        if (enable) {
            GL11.glEnable(GL11.GL_FOG);
        } else {
            GL11.glDisable(GL11.GL_FOG);
        }
        record.enabled = enable;
    }
}