OSDN Git Service

Various, mostly meshbuilder ensure size
[mikumikustudio/libgdx-mikumikustudio.git] / gdx / src / com / badlogic / gdx / graphics / g3d / attributes / DepthTestAttribute.java
1 package com.badlogic.gdx.graphics.g3d.attributes;
2
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;
7
8 public class DepthTestAttribute extends Attribute {
9    public final static String Alias = "depthStencil";
10    public final static long Type = register(Alias);
11
12    protected static long Mask = Type;
13
14    public final static boolean is(final long mask) {
15        return (mask & Mask) != 0;
16    }
17
18    /** The depth test function, or 0 to disable depth test (default: GL10.GL_LEQUAL) */
19    public int depthFunc;
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;
26
27    public DepthTestAttribute() {
28         this(GL10.GL_LEQUAL);
29    }
30    
31    public DepthTestAttribute(boolean depthMask) {
32         this(GL10.GL_LEQUAL, depthMask);
33    }
34    
35    public DepthTestAttribute(final int depthFunc) {
36         this(depthFunc, true);
37    }
38    
39    public DepthTestAttribute(int depthFunc, boolean depthMask) {
40         this(depthFunc, 0, 1, depthMask);
41    }
42    
43    public DepthTestAttribute(int depthFunc, float depthRangeNear, float depthRangeFar) {
44         this(depthFunc, depthRangeNear, depthRangeFar, true);
45    }
46    
47    public DepthTestAttribute(int depthFunc, float depthRangeNear, float depthRangeFar, boolean depthMask) {
48         this(Type, depthFunc, depthRangeNear, depthRangeFar, depthMask);
49    }
50    
51    public DepthTestAttribute(final long type, int depthFunc, float depthRangeNear, float depthRangeFar, boolean depthMask) {
52         super(type);
53       if (!is(type))
54         throw new GdxRuntimeException("Invalid type specified");
55       this.depthFunc = depthFunc;
56       this.depthRangeNear = depthRangeNear;
57       this.depthRangeFar = depthRangeFar;
58       this.depthMask = depthMask;
59    }
60    
61    public DepthTestAttribute(final DepthTestAttribute rhs) {
62         this(rhs.type, rhs.depthFunc, rhs.depthRangeNear, rhs.depthRangeFar, rhs.depthMask);
63    }
64
65    @Override
66    public Attribute copy () {
67       return new DepthTestAttribute(this);
68    }
69
70    @Override
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; 
74    }
75 }