-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathTextureArray.java
More file actions
67 lines (51 loc) · 1.73 KB
/
TextureArray.java
File metadata and controls
67 lines (51 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package arc.graphics;
import arc.*;
import arc.files.*;
import arc.graphics.gl.*;
import arc.util.*;
/**
* OpenGL ES wrapper for TextureArray
* @author Tomski
*/
public class TextureArray extends GLTexture{
private TextureArrayData data;
public TextureArray(String... internalPaths){
this(getInternalHandles(internalPaths));
}
public TextureArray(Fi... files){
this(false, files);
}
public TextureArray(boolean useMipMaps, Fi... files){
this(new FileTextureArrayData(useMipMaps, files));
}
public TextureArray(TextureArrayData data){
super(GL30.GL_TEXTURE_2D_ARRAY, Gl.genTexture());
if(Core.gl30 == null){
throw new ArcRuntimeException("TextureArray requires a device running with GLES 3.0 compatibilty");
}
load(data);
}
private static Fi[] getInternalHandles(String... internalPaths){
Fi[] handles = new Fi[internalPaths.length];
for(int i = 0; i < internalPaths.length; i++){
handles[i] = Core.files.internal(internalPaths[i]);
}
return handles;
}
private void load(TextureArrayData data){
this.data = data;
this.width = data.getWidth();
this.height = data.getHeight();
bind();
Core.gl30.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, data.getInternalFormat(), data.getWidth(), data.getHeight(), data.getDepth(), 0, data.getInternalFormat(), data.getGLType(), null);
if(!data.isPrepared()) data.prepare();
data.consumeTextureArrayData();
setFilter(minFilter, magFilter);
setWrap(uWrap, vWrap);
Gl.bindTexture(glTarget, 0);
}
@Override
public int getDepth(){
return data.getDepth();
}
}