Java 类org.newdawn.slick.opengl.TextureLoader 实例源码

项目:bia-engine    文件:Loader.java   
public int loadTexture(final String fileName) {
    Texture texture = null;
    try (final FileInputStream inputStream = new FileInputStream(getResourcePath("textures/" + fileName + ".png"))) {
        texture = TextureLoader.getTexture("PNG", inputStream);
    } catch (final IOException ex) {
        LOGGER.error("Exception occurred - {} while loading texture file - {}", ex, fileName);
    }
    assertTextureNotNullForFileName(texture, fileName);
    final int textureId = texture.getTextureID();
    textures.add(textureId);
    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 textureId;
}
项目:3d-Engine    文件:Loader.java   
public int loadTexture(String fileName) {
    Texture texture = null;
    try {
        texture = TextureLoader.getTexture("PNG", new FileInputStream(Primary.fileHandler.getTexture(fileName)));
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER,
                GL11.GL_LINEAR_MIPMAP_LINEAR);
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0f);
    } catch (Exception e) {
        e.printStackTrace();
        System.err.println("Tried to load texture " + fileName + ".png , didn't work");
        System.exit(-1);
    }
    textures.add(texture.getTextureID());
    return texture.getTextureID();
}
项目:3D-game-engine    文件:Loader.java   
public int loadTexture(String fileName) {
    Texture texture = null;
    try {
        texture = TextureLoader.getTexture("PNG", new FileInputStream("res/"+fileName +".png"));

        // Mipmapping to lower resolution of distance textures
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);

        // Changes the level of detail to change the mipmapping to a slightly higher resolution
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, -0.4f);
    } catch (IOException e) {
        e.printStackTrace();
    }
    //TODO fix null assertion
    int textureID = texture.getTextureID();
    textures.add(textureID);
    return textureID;
}
项目:Mystic-Bastion    文件:Loader.java   
public int loadTexture(String fileName) {
    Texture texture = null;
    try {
        texture = TextureLoader.getTexture("PNG",
                new FileInputStream(MainGameLoop.fileManager.getTextureFile(fileName)));
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0);
        if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
            float amount = Math.min(4f,
                    GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT,
                    amount);
        } else {
            System.out.println("Filter Anisotropic Not Supported");
        }
    } catch (Exception e) {
        e.printStackTrace();
        System.err.println("Tried to load texture " + fileName + ".png , didn't work");
        System.exit(-1);
    }
    textures.add(texture.getTextureID());
    return texture.getTextureID();
}
项目:Heightmap-Renderer    文件:State_HEIGHTMAP_MENU.java   
@Override
protected void Init() {

    try {
         GL11.glEnable(GL11.GL_TEXTURE_2D);
         Texture button1 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Buttons/HMButton1.png"), false, GL11.GL_NEAREST);
         GUI.AddButton(460, 154, button1.getImageWidth(), button1.getImageHeight(), button1);
         Texture button2 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Buttons/HMButton2.png"), false, GL11.GL_NEAREST);
         GUI.AddButton(460, 214, button2.getImageWidth(), button2.getImageHeight(), button2);
         Texture button3 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Buttons/HMButton3.png"), false, GL11.GL_NEAREST);
         GUI.AddButton(460, 274, button3.getImageWidth(), button3.getImageHeight(), button3);
         Texture button4 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Buttons/HMButton4.png"), false, GL11.GL_NEAREST);
         GUI.AddButton(460, 334, button4.getImageWidth(), button4.getImageHeight(), button4);
         Texture button5 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Buttons/Back.png"), false, GL11.GL_NEAREST);
         GUI.AddButton(460, 394, button5.getImageWidth(), button5.getImageHeight(), button5);
        BackGroundImage = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Menus/HMMenu.png"), false, GL11.GL_NEAREST);
        HeightMap1 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/images/Heightmap1.png"));
        HeightMap2 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/images/Heightmap2.png"));
        HeightMap3 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/images/Heightmap3.png"));
    } catch (IOException e) {

        System.out.println("ERROR: Failed to load image @ Menu");
        e.printStackTrace();
    }

}
项目:Voxel-Based-Game-Engine-Java    文件:Texture.java   
private static int loadTexture(String fileName, boolean flipped)
{
    String[] splitArray = fileName.split("\\.");
    String ext = splitArray[splitArray.length - 1];

    try
    {       
        return TextureLoader.getTexture(ext, new FileInputStream(new File("./res/textures/" + fileName)), flipped, GL_NEAREST).getTextureID();
    }
    catch(Exception e)
    {
        e.printStackTrace();
        System.exit(1);
    }

    return 0;
}
项目:KatamaEngine    文件:Texture.java   
@Override
public void load() {

    if (img != null) {
        id = TextureUtil.loadTexture(img);
    } else {
        String[] splitArray = location.getPath().split("\\.");
        String extension = splitArray[splitArray.length - 1];

        try {
            InputStream is = getLocation().getUrl().openStream();
            id = TextureLoader.getTexture(extension, is).getTextureID();
        } catch (Exception e) {
            e.printStackTrace();
            new KatamaException("Could not load texture: " + location).printStackTrace();
            System.exit(1);
        }
    }
}
项目:GPVM    文件:NinePatch.java   
@Override
public void load() {
  if(texture != null) {
    texture.release();
  }

  if(texfile == null || !texfile.canRead()) {
    log.log(Level.SEVERE, BAD_TEX_FILE);
    return;
  }

  String filename = texfile.getName();
  try {
    texture = TextureLoader.getTexture(filename.substring(filename.lastIndexOf('.')), new FileInputStream(texfile));
  } catch (IOException ex) {
    //this should never happen probably
    log.log(Level.SEVERE, null, ex);
  }

  createTexCoords();
}
项目:TeacherSmash    文件:Draw.java   
public static void drawBackGround(){
    initGL(Display.getWidth(),Display.getHeight());
    try {
        Texture background =  TextureLoader.getTexture("JPG", ResourceLoader.getResourceAsStream("imgs/Map_test_1.jpg"));
        background.bind();
        glBegin(GL_QUADS);
        GL11.glTexCoord2f(0,0);
        GL11.glVertex2f(0,0);
        GL11.glTexCoord2f(1,0);
        GL11.glVertex2f(background.getTextureWidth(),0);
        GL11.glTexCoord2f(1,1);
        GL11.glVertex2f(background.getTextureWidth(),background.getTextureHeight());
        GL11.glTexCoord2f(0,1);
        GL11.glVertex2f(0,background.getTextureHeight());
        GL11.glBindTexture(GL_TEXTURE_2D,0);
        glEnd();

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:TeacherSmash    文件:Draw.java   
public static void drawSprites(String spriteLoc) {
    initGL(Display.getWidth(),Display.getHeight());
    try {
        Texture sprite = TextureLoader.getTexture("JPG", ResourceLoader.getResourceAsStream("imgs/"+spriteLoc));
        sprite.bind();
        glBegin(GL_QUADS);
        GL11.glTexCoord2f(0,0);
        GL11.glVertex2f(0,0);
        GL11.glTexCoord2f(1,0);
        GL11.glVertex2f(sprite.getTextureWidth(),0);
        GL11.glTexCoord2f(1,1);
        GL11.glVertex2f(sprite.getTextureWidth(),sprite.getTextureHeight());
        GL11.glTexCoord2f(0,1);
        GL11.glVertex2f(0,sprite.getTextureHeight());
        GL11.glBindTexture(GL_TEXTURE_2D,0);
        glEnd();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
项目:9-Gates    文件:GUI_Console.java   
public GUI_Console(int startX, int startY, int width, int height,
        String fontName, TileMap t, Player p) {

    ScreenX = startX;
    ScreenY = startY;
    ScreenButtonWidth = width;
    ScreenButtonHeight = height;

    player = p;
    map = t;
    try {
        texture = TextureLoader.getTexture("PNG", ResourceLoader
                .getResourceAsStream("res/Materials/GUI/UI/Console.png"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    font = LoadFont(fontName);
    CharacterWidth = width / 15;
    LineHeight = height / 19;
}
项目:3d-Demo    文件:Texture.java   
private void loadTexture()
{
    Pattern regex = Pattern.compile("(\\..+)");
    Matcher match = regex.matcher(filePath);

    match.find();

    String extension = match.group();

    try
    {
        texture = TextureLoader.getTexture(extension, ResourceLoader.getResourceAsStream(filePath));
    }
    catch (IOException e)
    {
        System.out.println("Failed to load texture at: " + filePath);
        e.printStackTrace();
    }

    glBindTexture(GL_TEXTURE_2D, this.getTextureID());
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glBindTexture(GL_TEXTURE_2D, 0);
}
项目:brevis    文件:BrObject.java   
public void setTexture( String filename ) {
//public void setTexture( URL filename ) {

    try {
        // load texture from PNG file
        //texture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(filename));
        //ResourceLoader.addResourceLocation( new ClasspathLocation() );// this should probably be a 1x thing
        //texture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream( filename.getPath() ) );
        //texture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream( filename.getFile() ) );
        //texture = TextureLoader.getTexture("PNG", filename.openStream() );

        texture = TextureLoader.getTexture("PNG", Thread.currentThread().getContextClassLoader().getResourceAsStream( filename ) );


        /*System.out.println("Texture loaded: "+texture);
        System.out.println(">> Image width: "+texture.getImageWidth());
        System.out.println(">> Image height: "+texture.getImageHeight());
        System.out.println(">> Texture width: "+texture.getTextureWidth());
        System.out.println(">> Texture height: "+texture.getTextureHeight());
        System.out.println(">> Texture ID: "+texture.getTextureID());*/
    } catch (IOException e) {
        System.out.println( "Error loading texture: " + filename );
        e.printStackTrace();
    }       

}
项目:APFG    文件:MemoryTest.java   
@Override
public void init(GameContainer container, StateBasedGame game)
        throws SlickException {
    this.game = game;
    imageFolder = new File("assets/memorytest");
    displayImage = new Image(20,20);
    displayImage2 = new Image(20,20);
    fileNames = imageFolder.listFiles();

    try {
        tempTexture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(fileNames[fileCounter].getPath()));
        displayTexture = tempTexture;
        displayImage.setTexture(displayTexture);

        tempTexture2 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(fileNames[fileCounter2].getPath()));
        displayTexture2 = tempTexture2;
        displayImage2.setTexture(displayTexture2);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:Elgin-Plant-Game    文件:Loader.java   
/**
 * Loads a texture from file, under resources/assets/ folder type / file name.png
 * @param fileName - Name of the texture
 * @param folderType - Used to find the texture since it's organized.
 * @return - TextureID used for program
 */
public int loadTexture(String fileName, int folderType) {
    Texture texture = null;

    String folderName = "textures";
    if(folderType == Reference.LOADER_MAPS_FOLDER) folderName = "maps";
    if(folderType == Reference.LOADER_NORMALS_FOLDER) folderName = "normals";
    if(folderType == Reference.LOADER_FONTS_FOLDER) folderName = "fonts";
    if(folderType == Reference.LOADER_PARTICLES_FOLDER) folderName = "particles";
    if(folderType == Reference.LOADER_SPECULARS_FOLDER) folderName = "speculars";

    try {
        texture = TextureLoader.getTexture("PNG", Class.class.getResourceAsStream("/assets/" + folderName + "/" + fileName + ".png"));
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0);

        if(GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
            float amount = Math.min(4f, GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, amount);
        } else {
            System.err.println("Anisotropic filtering not supported.");
        }
    } catch (IOException e) {
        System.err.println("Failed to load texture: " + "/assets/" + folderName + "/" + fileName + ".png");
    }

    int textureID = texture.getTextureID();
    textures.add(textureID);
    return textureID;
}
项目:Terrain    文件:Loader.java   
public int loadTexture(String fileName) {
    Texture texture = null;
    try {
        texture = TextureLoader.getTexture("PNG", Class.class.getResourceAsStream("/res/textures/" + fileName + ".png"));
    } catch (Exception e) {
        e.printStackTrace();
    }
    textures.add(texture.getTextureID());
    return texture.getTextureID();
}
项目:SMBLevelWorkshop    文件:ResourceTexture.java   
public ResourceTexture(String type, File file) throws Exception {
    Window.drawable.makeCurrent();
    GL11.glFinish();
    FileInputStream fis = new FileInputStream(file);
    try {
        texture = TextureLoader.getTexture(type, fis);
    } catch (Exception e) {
        throw new Exception(e);
    }
    fis.close();
    GL11.glFlush();
    Window.drawable.releaseContext();
}
项目:FEMultiPlayer-V2    文件:FEMultiplayer.java   
public void init(int width, int height, String name) {
    super.init(width, height, name);
    Player p1 = new Player("Player", (byte) 0);
    localPlayer = p1;
    ByteBuffer icon16, icon32;
    icon16 = icon32 = null;
    try {
        icon16 = ByteBuffer.wrap(TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/gui/icon16.png")).getTextureData());
        icon32 = ByteBuffer.wrap(TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/gui/icon32.png")).getTextureData());
    } catch (IOException e) {
        e.printStackTrace();
    }
    Display.setIcon(new ByteBuffer[]{icon16, icon32});
    FEResources.loadResources();
    FEResources.loadBitmapFonts();
    WeaponFactory.loadWeapons();
    UnitFactory.loadUnits();
    p1.getParty().setColor(Party.TEAM_BLUE);

    /* OpenGL final setup */
    glEnable(GL_LINE_SMOOTH);

    UnitFactory.getUnit("Lyn");
    connect = new ConnectStage();
    setCurrentStage(new TitleStage());
    SoundTrack.loop("main");

}
项目:FEMultiPlayer-V2    文件:AnimationData.java   
/**
 * Gets the texture.
 *
 * @return the texture
 */
public Texture getTexture() {
    try {
        Texture t = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(path));
        System.out.println("Loaded "+path);
        return t;
    } catch (IOException e) {
        System.err.println("Texture not found: "+path);
        e.printStackTrace();
        return null;
    }
}
项目:FEMultiPlayer-V2    文件:Tileset.java   
/**
 * Instantiates a new tileset.
 *
 * @param path the path
 * @param tileWidth the tile width
 * @param tileHeight the tile height
 */
public Tileset(String path, int tileWidth, int tileHeight) {
    try {
        tileset = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream(path));
        System.out.println("Loaded: "+path);
    } catch (IOException e) {
        e.printStackTrace();
    }
    this.tileWidth = tileWidth;
    this.tileHeight = tileHeight;
    width = tileset.getImageWidth();
    height = tileset.getImageHeight();
}
项目:FEMultiPlayer-V2    文件:BitmapFont.java   
/**
 * Instantiates a new bitmap font.
 *
 * @param texName the tex name
 */
public BitmapFont(String texName) {
    try {
        texture = TextureLoader.getTexture("PNG", 
                ResourceLoader.getResourceAsStream("res/fonts/"+texName+".png"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    glyphs = new HashMap<Character, Glyph>();
}
项目:sandbox    文件:Loader.java   
public int loadTexture(boolean root, String directory, String file, float bias) {
    Texture texture = null;
    if (!file.toLowerCase().endsWith(".png")) file += ".png";
    try {
        String path = directory + "/" + file;
        if (!root) path = "assets/" + path;
        texture = TextureLoader.getTexture("PNG", net.gogo98901.util.Loader.getResourceAsStream(path));
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, bias);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_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);
        if (directory != "fonts") {
            if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
                if (Config.anisotropic.get()) {
                    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0F);

                    float amount = Math.min(4F, GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
                    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, amount);
                } else {
                    Log.info("GL: Anisotropic filtering disabled by config");
                }
            } else {
                Log.warn("GL: Anisotropic filtering not supported");
            }
        }
    } catch (IOException e) {
        Log.warn("Could not read texture '" + file + "'");
        Log.stackTrace(e);
    }
    textures.add(texture.getTextureID());
    return texture.getTextureID();
}
项目:tprogersMinesweeper    文件:LwjglSpriteSystem.java   
LwjglSprite(String texturename) {
    try {
        this.texture = TextureLoader.getTexture("PNG", new FileInputStream(new File("res/" + texturename + ".png")));
    } catch (IOException e) {
        e.printStackTrace();
    }

}
项目:SRPG    文件:Artist.java   
public static Texture LoadTexture(String path, String fileType) {
    Texture tex = null;
    InputStream in = ResourceLoader.getResourceAsStream(path);
    try {
        tex = TextureLoader.getTexture(fileType, in);
    }
    catch (IOException e) {
        e.printStackTrace();
    }
    return tex;
}
项目:SRPG    文件:Artist.java   
public static Texture LoadPNG(String fileName) {
    Texture tex = null;
    InputStream in = ResourceLoader.getResourceAsStream("res/" + fileName + ".png");
    try {
        tex = TextureLoader.getTexture("PNG", in);
    }
    catch (IOException e) {
        e.printStackTrace();
    }
    return tex;
}
项目:Save-The-Ball    文件:Score.java   
public void loadPlayImage(String image1, String image2) {
    try {
        texture1 = TextureLoader.getTexture("PNG", new FileInputStream(image1));
        texture2 = TextureLoader.getTexture("PNG", new FileInputStream(image2));
       } catch (IOException e) {
           e.printStackTrace();
       }
}
项目:Save-The-Ball    文件:GuiRenderer.java   
public GuiRenderer(String fileSrc, String ext) {
    try {
        texture = TextureLoader.getTexture(ext, new FileInputStream(new File(fileSrc)));
       } catch (IOException e) {
           e.printStackTrace();
       }
}
项目:redrun    文件:Tools.java   
/**
 * Loads a texture from a file for OpenGL.
 * 
 * @param filename the name of the file located in the res (resources) directory
 * @return the loaded texture
 */
public static Texture loadTexture(String filename, String filetype)
{
  try
  {
    return TextureLoader.getTexture(filetype, ResourceLoader.getResourceAsStream("res/textures/" + filename + "." + filetype), GL_LINEAR);
  }
  catch (IOException ex)
  {
    Logger.getLogger(Tools.class.getName()).log(Level.SEVERE, null, ex);
  }

  return null;
}
项目:RobustEngine    文件:GameObject.java   
/**
 * This method creates a texture object from a file location. 
 * @param path The path of the file location
 * @return The Texture generated. 
 */
public static Texture loadTexture(String path){
    try {
        return TextureLoader.getTexture("PNG", new FileInputStream(new File(path)));
    }
    catch (Exception e){
        e.printStackTrace();
        System.exit(0);
    }

    return null;
}
项目:RobustEngine    文件:GameObject.java   
/**
 * This method creates a texture object from an object 
 * @param obj The object with the texture path.
 * @return The Texture generated. 
 */
public static Texture loadTexture(GameObject obj){
    try {
        return TextureLoader.getTexture("PNG", new FileInputStream(new File(obj.getTexturePath())));
    }
    catch (Exception e){
        e.printStackTrace();
        System.exit(0);
    }

    return null;
}
项目:Heightmap-Renderer    文件:State_MENU.java   
@Override
protected void Init() {

    try {
         GL11.glEnable(GL11.GL_TEXTURE_2D);
         Texture button1 = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Buttons/Button1.png"), false, GL11.GL_NEAREST);
         GUI.AddButton(460, 154, button1.getImageWidth(), button1.getImageHeight(), button1);
        BackGroundImage = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/Menus/Menu.png"), false, GL11.GL_NEAREST);
        TextureImpl.unbind();
    } catch (IOException e) {

        System.out.println("ERROR: Failed to load image @ Menu");
        e.printStackTrace();
    }   
}
项目:fuzzy-octo-shame    文件:Util.java   
/**
 * 
 * @param path path to texture file
 * @return texture object loaded from file
 */
@Nonnull
public static Texture loadTexture(@Nonnull String path) {
    Texture texture = null;

    String type = path.substring(path.lastIndexOf('.') + 1).toUpperCase();

    try (final InputStream resourceAsStream = ResourceLoader.getResourceAsStream(path)) {
        if(resourceAsStream == null) {
            throw new IOException("");//FIXME
        }
        texture = TextureLoader.getTexture(type, resourceAsStream);
        if(texture == null) {
            throw new IOException("");//FIXME
        }
        LOGGER.debug("Texture loaded: " + texture);
        LOGGER.debug(">> Image width: " + texture.getImageWidth());
        LOGGER.debug(">> Image height: " + texture.getImageHeight());
        LOGGER.debug(">> Texture width: " + texture.getTextureWidth());
        LOGGER.debug(">> Texture height: " + texture.getTextureHeight());
        LOGGER.debug(">> Texture ID: " + texture.getTextureID());
        LOGGER.debug(">> Texture Alpha: " + texture.hasAlpha());
    } catch (IOException e) {
        LOGGER.error("An error occurred while loading texture", e);
        System.exit(ExitStatusCode.ERROR.getStatusCode());
    }
    return texture;
}
项目:GameCo    文件:Button.java   
public void addButton(int x, int y , String TEXPATH){
    X=x;
    Y=y;
    try {
        buttonTexture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(TEXPATH));
        System.out.println(buttonTexture.getTextureID());
    } catch (IOException e) {
        e.printStackTrace();
    }
    bounds.x=X;
    bounds.y=Y;
    bounds.height=buttonTexture.getImageHeight();
    bounds.width=buttonTexture.getImageWidth();
    System.out.println("[BUTTON CREATE]"+bounds.x+" "+bounds.y+" "+bounds.width+" "+bounds.height);
}
项目:java-danmaku-engine    文件:SpriteSheet.java   
/**
 * This method loads the spritesheet into OpenGL as a texture from the PNG
 * file
 */
public void preload() {
    try {
        texture = TextureLoader.getTexture("PNG",
                ResourceLoader.getResourceAsStream(file));
    } catch (IOException e) {
        e.printStackTrace();
    }

    loaded = true;
}
项目:OpenLauncher-StandAlone    文件:Footer.java   
public Footer() {
    try {
        settingTEX = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("img/wrench.png"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    Font awtFont = new Font("Latha", Font.BOLD, 24);
    font = new TrueTypeFont(awtFont, false);
}
项目:OpenLauncher-StandAlone    文件:LoadingComponet.java   
public void setupTextures(){
    try {
        panelBackGroundTEX = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("img/packPanel.png"));
        System.out.println(panelBackGroundTEX.getHeight());
    } catch (IOException e) {
        e.printStackTrace();
    }
    Font awtFont = new Font("Latha", Font.BOLD, 24);
    font = new TrueTypeFont(awtFont, false);
}
项目:OpenLauncher-StandAlone    文件:Wallpaper.java   
public Wallpaper() {
    try {
        texture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("img/back" + OpenLauncherGui.WIDTH + ".png"));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:Pixel-Planet    文件:GameResourceLoader.java   
public static Texture loadTexture(String filename){
        String[] splat = filename.split("\\.");
        String format = splat[splat.length-1];
        try {
//            return TextureLoader.getTexture(format, new FileInputStream(new File("res/textures/"+filename)));
            return TextureLoader.getTexture(format, ResourceLoader.getResourceAsStream("res/textures/" + filename));
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
项目:GPVM    文件:TextureResource.java   
@Override
public void load() {
  try (InputStream input = tfile.openStream()) {
    texture = TextureLoader.getTexture(type, input);
  } catch (IOException ex) {
    log.log(Level.SEVERE, "Unable to load texture from " + tfile, ex);
  }
}
项目:Sivx-3DDesktop    文件:engine - Copy.java   
public t(String fileType, String fileName){
    try{
        texture = TextureLoader.getTexture(fileType, new FileInputStream(fileName));
        id=tCounter++;
        t.add(this);
    }catch(Exception e){System.out.println("texture = textureLoader... failed");}
}