Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epoxy
GitHub Repository: epoxy/proj11
Path: blob/master/SLICK_HOME/src/org/newdawn/slick/opengl/TextureLoader.java
1461 views
1
package org.newdawn.slick.opengl;
2
3
import java.io.IOException;
4
import java.io.InputStream;
5
6
import org.lwjgl.opengl.GL11;
7
8
/**
9
* A utility class to wrap the Slick internal texture loader and present a
10
* rational interface.
11
*
12
* @author kevin
13
*/
14
public class TextureLoader {
15
/**
16
* Load a texture with a given format from the supplied input stream
17
*
18
* @param format The format of the texture to be loaded (something like "PNG" or "TGA")
19
* @param in The input stream from which the image data will be read
20
* @return The newly created texture
21
* @throws IOException Indicates a failure to read the image data
22
*/
23
public static Texture getTexture(String format, InputStream in) throws IOException {
24
return getTexture(format, in, false, GL11.GL_LINEAR);
25
}
26
27
/**
28
* Load a texture with a given format from the supplied input stream
29
*
30
* @param format The format of the texture to be loaded (something like "PNG" or "TGA")
31
* @param in The input stream from which the image data will be read
32
* @param flipped True if the image should be flipped vertically on loading
33
* @return The newly created texture
34
* @throws IOException Indicates a failure to read the image data
35
*/
36
public static Texture getTexture(String format, InputStream in, boolean flipped) throws IOException {
37
return getTexture(format, in, flipped, GL11.GL_LINEAR);
38
}
39
40
/**
41
* Load a texture with a given format from the supplied input stream
42
*
43
* @param format The format of the texture to be loaded (something like "PNG" or "TGA")
44
* @param in The input stream from which the image data will be read
45
* @param filter The GL texture filter to use for scaling up and down
46
* @return The newly created texture
47
* @throws IOException Indicates a failure to read the image data
48
*/
49
public static Texture getTexture(String format, InputStream in, int filter) throws IOException {
50
return getTexture(format, in, false, filter);
51
}
52
53
/**
54
* Load a texture with a given format from the supplied input stream
55
*
56
* @param format The format of the texture to be loaded (something like "PNG" or "TGA")
57
* @param in The input stream from which the image data will be read
58
* @param flipped True if the image should be flipped vertically on loading
59
* @param filter The GL texture filter to use for scaling up and down
60
* @return The newly created texture
61
* @throws IOException Indicates a failure to read the image data
62
*/
63
public static Texture getTexture(String format, InputStream in, boolean flipped, int filter) throws IOException {
64
return InternalTextureLoader.get().getTexture(in, in.toString()+"."+format, flipped, filter);
65
}
66
}
67
68