1 package com.badlogic.gdx.graphics.g3d.attributes;
3 import com.badlogic.gdx.graphics.Color;
4 import com.badlogic.gdx.graphics.GL10;
5 import com.badlogic.gdx.graphics.g3d.Attribute;
6 import com.badlogic.gdx.utils.GdxRuntimeException;
8 public class DepthTestAttribute extends Attribute {
9 public final static String Alias = "depthStencil";
10 public final static long Type = register(Alias);
12 protected static long Mask = Type;
14 public final static boolean is(final long mask) {
15 return (mask & Mask) != 0;
18 /** The depth test function, or 0 to disable depth test (default: GL10.GL_LEQUAL) */
20 /** Mapping of near clipping plane to window coordinates (default: 0) */
21 public float depthRangeNear;
22 /** Mapping of far clipping plane to window coordinates (default: 1) */
23 public float depthRangeFar;
24 /** Whether to write to the depth mask, only applicable if depthFunc is non zero (default: true) */
25 public boolean depthMask;
27 public DepthTestAttribute() {
31 public DepthTestAttribute(boolean depthMask) {
32 this(GL10.GL_LEQUAL, depthMask);
35 public DepthTestAttribute(final int depthFunc) {
36 this(depthFunc, true);
39 public DepthTestAttribute(int depthFunc, boolean depthMask) {
40 this(depthFunc, 0, 1, depthMask);
43 public DepthTestAttribute(int depthFunc, float depthRangeNear, float depthRangeFar) {
44 this(depthFunc, depthRangeNear, depthRangeFar, true);
47 public DepthTestAttribute(int depthFunc, float depthRangeNear, float depthRangeFar, boolean depthMask) {
48 this(Type, depthFunc, depthRangeNear, depthRangeFar, depthMask);
51 public DepthTestAttribute(final long type, int depthFunc, float depthRangeNear, float depthRangeFar, boolean depthMask) {
54 throw new GdxRuntimeException("Invalid type specified");
55 this.depthFunc = depthFunc;
56 this.depthRangeNear = depthRangeNear;
57 this.depthRangeFar = depthRangeFar;
58 this.depthMask = depthMask;
61 public DepthTestAttribute(final DepthTestAttribute rhs) {
62 this(rhs.type, rhs.depthFunc, rhs.depthRangeNear, rhs.depthRangeFar, rhs.depthMask);
66 public Attribute copy () {
67 return new DepthTestAttribute(this);
71 protected boolean equals (Attribute other) {
72 DepthTestAttribute attr = (DepthTestAttribute)other;
73 return depthFunc == attr.depthFunc && depthRangeNear == attr.depthRangeNear && depthRangeFar == attr.depthRangeFar && depthMask == attr.depthMask;