use of org.newdawn.slick.opengl.Texture in project j6dof-flight-sim by chris-ali.
the class Loader method loadAndGetTexture.
/**
* Loads a texture into memory using SlikUtils png loader using a specific directory stemming from the rootDirectory
* argument. Sets anisotropic filtering for textures as well in this method. Returns the Texture obect directly so that
* the file's properties can be used elsewhere
*
* @param rootDirectory
* @param fileName
* @param directory
* @return Texture object
*/
public Texture loadAndGetTexture(String rootDirectory, String fileName, String directory) {
Texture texture = null;
try {
texture = TextureLoader.getTexture("PNG", new FileInputStream(rootDirectory + File.separator + directory + File.separator + fileName + OTWFiles.TEXTURE_EXT.toString()));
GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
// Set Anisotropic Filtering
if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic && useAnisotropicFiltering) {
float value = Math.min(4f, GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, value);
}
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, -0.4f);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
return texture;
} catch (IOException e) {
logger.error("Could not load texture: " + fileName + OTWFiles.TEXTURE_EXT.toString(), e);
}
return texture;
}
use of org.newdawn.slick.opengl.Texture in project j6dof-flight-sim by chris-ali.
the class AbstractGauge method loadTextures.
/**
* After the gauge has been deserialized, call this method to load all textures in to memory
* in the textureNames list
*
* @param loader
*/
public void loadTextures(Loader loader) {
if (gaugeTextures == null || gaugeTextures.size() == 0) {
logger.error("No texture information stored in class!");
return;
}
logger.debug("Loading " + getClass().getSimpleName() + "'s associated textures...");
for (Map.Entry<String, InterfaceTexture> entry : gaugeTextures.entrySet()) {
Texture texture = loader.loadAndGetTexture(entry.getKey(), OTWDirectories.GAUGES.toString());
entry.getValue().setTexture(texture.getTextureID());
}
}
Aggregations