OSDN Git Service

184d232b453b83a556d6bac3a529f56fc117262d
[mikumikustudio/libgdx-mikumikustudio.git] / gdx / src / com / badlogic / gdx / graphics / g3d / attributes / CubemapAttribute.java
1 package com.badlogic.gdx.graphics.g3d.attributes;
2
3 import com.badlogic.gdx.graphics.Cubemap;
4 import com.badlogic.gdx.graphics.Texture;
5 import com.badlogic.gdx.graphics.g3d.Attribute;
6 import com.badlogic.gdx.graphics.g3d.utils.TextureDescriptor;
7 import com.badlogic.gdx.utils.GdxRuntimeException;
8
9 public class CubemapAttribute extends Attribute {
10         public final static String EnvironmentMapAlias = "environmentMapTexture";
11         public final static long EnvironmentMap = register(EnvironmentMapAlias);
12         
13         // FIXME add more types!
14         // FIXME add scaling + offset?
15         // FIXME add filter settings? MipMap needs to be obeyed during loading :/
16         
17         protected static long Mask = EnvironmentMap;
18         
19         public final static boolean is(final long mask) {
20                 return (mask & Mask) != 0;
21         }
22         
23         public final TextureDescriptor<Cubemap> textureDescription;
24         
25         public CubemapAttribute(final long type) {
26                 super(type);
27                 if (!is(type))
28                         throw new GdxRuntimeException("Invalid type specified");
29                 textureDescription = new TextureDescriptor<Cubemap>();
30         }
31         
32         public <T extends Cubemap> CubemapAttribute(final long type, final TextureDescriptor<T> textureDescription) {
33                 this(type);
34                 this.textureDescription.set(textureDescription);
35         }
36         
37         public CubemapAttribute(final long type, final Cubemap texture) {
38                 this(type);
39                 textureDescription.texture = texture;
40         }
41         
42         public CubemapAttribute(final CubemapAttribute copyFrom) {
43                 this(copyFrom.type, copyFrom.textureDescription);
44         }
45         
46         @Override
47         public Attribute copy () {
48                 return new CubemapAttribute(this);
49         }
50
51         @Override
52         protected boolean equals (Attribute other) {
53                 return ((CubemapAttribute)other).textureDescription.equals(textureDescription);
54         }
55 }