Package de.nameless.graphicEngine.texture

Source Code of de.nameless.graphicEngine.texture.TextureLoader

package de.nameless.graphicEngine.texture;



import java.io.File;

import javax.media.opengl.GL;

import sun.util.logging.resources.logging;

import com.sun.opengl.util.texture.Texture;
import com.sun.opengl.util.texture.TextureIO;

import static de.nameless.gameEngine.util.Logger.*;
public class TextureLoader{
  /**
  * l�dt die in dem pfad angegebene bilddatei als texture und gibt sie als jogl Textur zur�ck
  *
  * @param fileName relative filename from execution point
  * @return a texture binded to the OpenGL context
  */
  public static Texture load(String fileName){
    Texture text = null;
    try{
      text = TextureIO.newTexture(new File(fileName), true);
      text.setTexParameteri(GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
      text.setTexParameteri(GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
      //text.setTexParameteri(GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR_MIPMAP_NEAREST);
    }catch(Exception e){         
      try {
        System.out.println(fileName);
        text = TextureIO.newTexture(new File("resources/Images/Error.JPG"), true);
        text.setTexParameteri(GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
        text.setTexParameteri(GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST)
      } catch (Exception e1) {       
        System.out.println(e1.getMessage());
      }
     
   
    }
    return text;
  }
}
TOP

Related Classes of de.nameless.graphicEngine.texture.TextureLoader

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.