Example usage for com.badlogic.gdx.graphics.g3d.attributes DepthTestAttribute Type

List of usage examples for com.badlogic.gdx.graphics.g3d.attributes DepthTestAttribute Type

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g3d.attributes DepthTestAttribute Type.

Prototype

long Type

To view the source code for com.badlogic.gdx.graphics.g3d.attributes DepthTestAttribute Type.

Click Source Link

Usage

From source file:gaia.cu9.ari.gaiaorbit.util.override.AtmosphereShader.java

License:Apache License

protected void bindMaterial(final Renderable renderable) {
    if (currentMaterial == renderable.material)
        return;// w  ww.  ja v a 2  s.com

    int cullFace = config.defaultCullFace == -1 ? defaultCullFace : config.defaultCullFace;
    int depthFunc = config.defaultDepthFunc == -1 ? defaultDepthFunc : config.defaultDepthFunc;
    float depthRangeNear = 0f;
    float depthRangeFar = 1f;
    boolean depthMask = true;

    currentMaterial = renderable.material;
    for (final Attribute attr : currentMaterial) {
        final long t = attr.type;
        if (BlendingAttribute.is(t)) {
            context.setBlending(true, ((BlendingAttribute) attr).sourceFunction,
                    ((BlendingAttribute) attr).destFunction);
        } else if ((t & IntAttribute.CullFace) == IntAttribute.CullFace)
            cullFace = ((IntAttribute) attr).value;
        else if ((t & DepthTestAttribute.Type) == DepthTestAttribute.Type) {
            DepthTestAttribute dta = (DepthTestAttribute) attr;
            depthFunc = dta.depthFunc;
            depthRangeNear = dta.depthRangeNear;
            depthRangeFar = dta.depthRangeFar;
            depthMask = dta.depthMask;
        } else if (!config.ignoreUnimplemented)
            throw new GdxRuntimeException("Unknown material attribute: " + attr.toString());
    }

    context.setCullFace(cullFace);
    context.setDepthTest(depthFunc, depthRangeNear, depthRangeFar);
    context.setDepthMask(depthMask);
}