-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextureLibrary.java
More file actions
27 lines (24 loc) · 887 Bytes
/
Copy pathTextureLibrary.java
File metadata and controls
27 lines (24 loc) · 887 Bytes
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
import java.io.File;
import java.io.FileInputStream;
import com.jogamp.opengl.*;
import com.jogamp.opengl.util.texture.*;
public final class TextureLibrary {
// mip-mapping is included
public static Texture loadTexture(GL3 gl3, String filename) {
Texture t = null;
try {
File f = new File(filename);
t = (Texture)TextureIO.newTexture(f, true);
t.bind(gl3);
t.setTexParameteri(gl3, GL3.GL_TEXTURE_WRAP_S, GL3.GL_REPEAT);
t.setTexParameteri(gl3, GL3.GL_TEXTURE_WRAP_T, GL3.GL_LINEAR);
t.setTexParameteri(gl3, GL3.GL_TEXTURE_MIN_FILTER, GL3.GL_LINEAR_MIPMAP_LINEAR);
t.setTexParameteri(gl3, GL3.GL_TEXTURE_MAG_FILTER, GL3.GL_LINEAR);
gl3.glGenerateMipmap(GL3.GL_TEXTURE_2D);
}
catch(Exception e) {
System.out.println("Error loading texture " + filename);
}
return t;
}
}