當前位置: 首頁>>代碼示例>>Java>>正文


Java TextureLoader.getTexture方法代碼示例

本文整理匯總了Java中org.newdawn.slick.opengl.TextureLoader.getTexture方法的典型用法代碼示例。如果您正苦於以下問題:Java TextureLoader.getTexture方法的具體用法?Java TextureLoader.getTexture怎麽用?Java TextureLoader.getTexture使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.newdawn.slick.opengl.TextureLoader的用法示例。


在下文中一共展示了TextureLoader.getTexture方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadTexture

import org.newdawn.slick.opengl.TextureLoader; //導入方法依賴的package包/類
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;
}
 
開發者ID:Biacode,項目名稱:bia-engine,代碼行數:17,代碼來源:Loader.java

示例2: loadTexture

import org.newdawn.slick.opengl.TextureLoader; //導入方法依賴的package包/類
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();
}
 
開發者ID:MrManiacc,項目名稱:3d-Engine,代碼行數:17,代碼來源:Loader.java

示例3: loadTexture

import org.newdawn.slick.opengl.TextureLoader; //導入方法依賴的package包/類
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;
}
 
開發者ID:marcelvanworkum,項目名稱:3D-game-engine,代碼行數:20,代碼來源:Loader.java

示例4: loadTexture

import org.newdawn.slick.opengl.TextureLoader; //導入方法依賴的package包/類
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();
}
 
開發者ID:Radseq,項目名稱:Mystic-Bastion,代碼行數:25,代碼來源:Loader.java

示例5: Init

import org.newdawn.slick.opengl.TextureLoader; //導入方法依賴的package包/類
@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();
	}
	
}
 
開發者ID:Glynn-Taylor,項目名稱:Heightmap-Renderer,代碼行數:27,代碼來源:State_HEIGHTMAP_MENU.java

示例6: drawSprites

import org.newdawn.slick.opengl.TextureLoader; //導入方法依賴的package包/類
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();
	}
	
}
 
開發者ID:CodeConglomerate,項目名稱:TeacherSmash,代碼行數:23,代碼來源:Draw.java

示例7: loadTexture

import org.newdawn.slick.opengl.TextureLoader; //導入方法依賴的package包/類
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);
}
 
開發者ID:apcragg,項目名稱:3d-Demo,代碼行數:25,代碼來源:Texture.java

示例8: setTexture

import org.newdawn.slick.opengl.TextureLoader; //導入方法依賴的package包/類
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();
	}		
	
}
 
開發者ID:kephale,項目名稱:brevis,代碼行數:27,代碼來源:BrObject.java

示例9: init

import org.newdawn.slick.opengl.TextureLoader; //導入方法依賴的package包/類
@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();
	}
}
 
開發者ID:jubilee145,項目名稱:APFG,代碼行數:22,代碼來源:MemoryTest.java

示例10: loadTexture

import org.newdawn.slick.opengl.TextureLoader; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:Essentria,項目名稱:Elgin-Plant-Game,代碼行數:37,代碼來源:Loader.java

示例11: loadTexture

import org.newdawn.slick.opengl.TextureLoader; //導入方法依賴的package包/類
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();
}
 
開發者ID:DevipriyaSarkar,項目名稱:Terrain,代碼行數:11,代碼來源:Loader.java

示例12: ResourceTexture

import org.newdawn.slick.opengl.TextureLoader; //導入方法依賴的package包/類
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();
}
 
開發者ID:CraftedCart,項目名稱:SMBLevelWorkshop,代碼行數:14,代碼來源:ResourceTexture.java

示例13: getTexture

import org.newdawn.slick.opengl.TextureLoader; //導入方法依賴的package包/類
/**
 * 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;
	}
}
 
開發者ID:eliatlarge,項目名稱:FEMultiPlayer-V2,代碼行數:17,代碼來源:AnimationData.java

示例14: Tileset

import org.newdawn.slick.opengl.TextureLoader; //導入方法依賴的package包/類
/**
 * 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();
}
 
開發者ID:eliatlarge,項目名稱:FEMultiPlayer-V2,代碼行數:21,代碼來源:Tileset.java

示例15: BitmapFont

import org.newdawn.slick.opengl.TextureLoader; //導入方法依賴的package包/類
/**
 * 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>();
}
 
開發者ID:eliatlarge,項目名稱:FEMultiPlayer-V2,代碼行數:15,代碼來源:BitmapFont.java


注:本文中的org.newdawn.slick.opengl.TextureLoader.getTexture方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。