Path: blob/master/SLICK_HOME/src/org/newdawn/slick/opengl/TextureLoader.java
1461 views
package org.newdawn.slick.opengl;12import java.io.IOException;3import java.io.InputStream;45import org.lwjgl.opengl.GL11;67/**8* A utility class to wrap the Slick internal texture loader and present a9* rational interface.10*11* @author kevin12*/13public class TextureLoader {14/**15* Load a texture with a given format from the supplied input stream16*17* @param format The format of the texture to be loaded (something like "PNG" or "TGA")18* @param in The input stream from which the image data will be read19* @return The newly created texture20* @throws IOException Indicates a failure to read the image data21*/22public static Texture getTexture(String format, InputStream in) throws IOException {23return getTexture(format, in, false, GL11.GL_LINEAR);24}2526/**27* Load a texture with a given format from the supplied input stream28*29* @param format The format of the texture to be loaded (something like "PNG" or "TGA")30* @param in The input stream from which the image data will be read31* @param flipped True if the image should be flipped vertically on loading32* @return The newly created texture33* @throws IOException Indicates a failure to read the image data34*/35public static Texture getTexture(String format, InputStream in, boolean flipped) throws IOException {36return getTexture(format, in, flipped, GL11.GL_LINEAR);37}3839/**40* Load a texture with a given format from the supplied input stream41*42* @param format The format of the texture to be loaded (something like "PNG" or "TGA")43* @param in The input stream from which the image data will be read44* @param filter The GL texture filter to use for scaling up and down45* @return The newly created texture46* @throws IOException Indicates a failure to read the image data47*/48public static Texture getTexture(String format, InputStream in, int filter) throws IOException {49return getTexture(format, in, false, filter);50}5152/**53* Load a texture with a given format from the supplied input stream54*55* @param format The format of the texture to be loaded (something like "PNG" or "TGA")56* @param in The input stream from which the image data will be read57* @param flipped True if the image should be flipped vertically on loading58* @param filter The GL texture filter to use for scaling up and down59* @return The newly created texture60* @throws IOException Indicates a failure to read the image data61*/62public static Texture getTexture(String format, InputStream in, boolean flipped, int filter) throws IOException {63return InternalTextureLoader.get().getTexture(in, in.toString()+"."+format, flipped, filter);64}65}666768