Example usage for org.lwjgl.opengl GL11 glEnable

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

Introduction

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

Prototype

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

Source Link

Document

Enables the specified OpenGL state.

Usage

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  w  w.  ja va  2 s  . 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;
            }// www .ja va  2  s.  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;
            }/*from   www . j a v  a  2  s .  c  om*/
            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 w w w  .  ja  v  a  2 s  .  c o 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 {// ww w .  j a  va2 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);
            record.enabled = true;/* w w w .j  a  v  a  2 s  .c  o  m*/
        } 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;
    }
}

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

License:Open Source License

public static void apply(final FragmentProgramState state) {
    final RenderContext context = ContextManager.getCurrentContext();
    if (context.getCapabilities().isFragmentProgramSupported()) {
        final FragmentProgramStateRecord record = (FragmentProgramStateRecord) context
                .getStateRecord(StateType.FragmentProgram);
        context.setCurrentState(StateType.FragmentProgram, state);

        if (!record.isValid() || record.getReference() != state) {
            record.setReference(state);// w ww .j  av a2s .c o m
            if (state.isEnabled()) {
                // Fragment program not yet loaded
                if (state._getProgramID() == -1) {
                    if (state.getProgramAsBuffer() != null) {
                        final int id = create(state.getProgramAsBuffer());
                        state._setProgramID(id);
                    } else {
                        return;
                    }
                }

                GL11.glEnable(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB);
                ARBProgram.glBindProgramARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, state._getProgramID());

                // load environmental parameters...
                // TODO: Reevaluate how this is done.
                /*
                 * for (int i = 0; i < envparameters.length; i++) if (envparameters[i] != null)
                 * ARBFragmentProgram.glProgramEnvParameter4fARB( ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB, i,
                 * envparameters[i][0], envparameters[i][1], envparameters[i][2], envparameters[i][3]);
                 */

                // load local parameters...
                if (state.isUsingParameters()) {
                    // no parameters are used
                    for (int i = 0; i < state._getParameters().length; i++) {
                        if (state._getParameters()[i] != null) {
                            ARBProgram.glProgramLocalParameter4fARB(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB,
                                    i, state._getParameters()[i][0], state._getParameters()[i][1],
                                    state._getParameters()[i][2], state._getParameters()[i][3]);
                        }
                    }
                }

            } else {
                GL11.glDisable(ARBFragmentProgram.GL_FRAGMENT_PROGRAM_ARB);
            }
        }

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

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

License:Open Source License

private static void setSingleLightEnabled(final boolean enable, final int index, final LightStateRecord record,
        final LightRecord lr) {
    if (!record.isValid() || lr.isEnabled() != enable) {
        if (enable) {
            GL11.glEnable(GL11.GL_LIGHT0 + index);
        } else {/*  w  w w  .jav  a2 s. com*/
            GL11.glDisable(GL11.GL_LIGHT0 + index);
        }

        lr.setEnabled(enable);
    }
}

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

License:Open Source License

private static void setLightEnabled(final boolean enable, final LightStateRecord record) {
    if (!record.isValid() || record.isEnabled() != enable) {
        if (enable) {
            GL11.glEnable(GL11.GL_LIGHTING);
        } else {//from   ww w.  j  a va 2s.  c om
            GL11.glDisable(GL11.GL_LIGHTING);
        }
        record.setEnabled(enable);
    }
}

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

License:Open Source License

private static void applyColorMaterial(final ColorMaterial colorMaterial, final MaterialFace face,
        final MaterialStateRecord record) {
    if (!record.isValid() || face != record.colorMaterialFace || colorMaterial != record.colorMaterial) {
        if (colorMaterial == ColorMaterial.None) {
            GL11.glDisable(GL11.GL_COLOR_MATERIAL);
        } else {//from  ww  w  .  java 2s .c  om
            final int glMat = getGLColorMaterial(colorMaterial);
            final int glFace = getGLMaterialFace(face);

            GL11.glColorMaterial(glFace, glMat);
            GL11.glEnable(GL11.GL_COLOR_MATERIAL);
            record.resetColorsForCM(face, colorMaterial);
        }
        record.colorMaterial = colorMaterial;
        record.colorMaterialFace = face;
    }
}