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


Java Texture類代碼示例

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


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

示例1: init

import org.newdawn.slick.opengl.Texture; //導入依賴的package包/類
/**
 * Initialise the PBuffer that will be used to render to
 * 
 * @throws SlickException
 */
private void init() throws SlickException {
	try {
		Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter());
		
		final RenderTexture rt = new RenderTexture(false, true, false, false, RenderTexture.RENDER_TEXTURE_2D, 0);
		pbuffer = new Pbuffer(screenWidth, screenHeight, new PixelFormat(8, 0, 0), rt, null);

		// Initialise state of the pbuffer context.
		pbuffer.makeCurrent();

		initGL();
		GL.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
		pbuffer.releaseTexImage(Pbuffer.FRONT_LEFT_BUFFER);
		image.draw(0,0);
		image.setTexture(tex);
		
		Display.makeCurrent();
	} catch (Exception e) {
		Log.error(e);
		throw new SlickException("Failed to create PBuffer for dynamic image. OpenGL driver failure?");
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:28,代碼來源:PBufferGraphics.java

示例2: init

import org.newdawn.slick.opengl.Texture; //導入依賴的package包/類
/**
 * Initialise the PBuffer that will be used to render to
 * 
 * @throws SlickException
 */
private void init() throws SlickException {
	try {
		Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter());

		pbuffer = new Pbuffer(screenWidth, screenHeight, new PixelFormat(8, 0, 0), null, null);
		// Initialise state of the pbuffer context.
		pbuffer.makeCurrent();

		initGL();
		image.draw(0,0);
		GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
		GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 0, 0, 
							  tex.getTextureWidth(), 
							  tex.getTextureHeight(), 0);
		image.setTexture(tex);
		
		Display.makeCurrent();
	} catch (Exception e) {
		Log.error(e);
		throw new SlickException("Failed to create PBuffer for dynamic image. OpenGL driver failure?");
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:28,代碼來源:PBufferUniqueGraphics.java

示例3: draw

import org.newdawn.slick.opengl.Texture; //導入依賴的package包/類
/**
 * Draw the outline of the given shape.  Only the vertices are set.  
 * The colour has to be set independently of this method.
 * 
 * @param shape The shape to draw.
 */
public static final void draw(Shape shape) {
    Texture t = TextureImpl.getLastBind();
    TextureImpl.bindNone();
    
    float points[] = shape.getPoints();
    
    LSR.start();
    for(int i=0;i<points.length;i+=2) {
    	LSR.vertex(points[i], points[i + 1]);
    }
    
    if (shape.closed()) {
    	LSR.vertex(points[0], points[1]);
    }
    
    LSR.end();
    
    if (t == null) {
    	TextureImpl.bindNone();
    } else {
    	t.bind();
    }
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:30,代碼來源:ShapeRenderer.java

示例4: getTextureImage

import org.newdawn.slick.opengl.Texture; //導入依賴的package包/類
/**
 * get the texture of all image ghost 
 * @return a vector with a texture:
 * [0] = Im1up, [1] = Im2up
 * [2] = Im1down, [3] = Im2down
 * [4] = Im1left, [5] = Im2left
 * [6] = Im1right, [7] = Im2right
 * @throws SlickException 
 */
private Texture[] getTextureImage() throws SlickException{        
    Image Im1up = new Image(PATH_IMAGE.concat(nameGhost).concat("_up1.png"));
    Image Im2up = new Image(PATH_IMAGE.concat(nameGhost).concat("_up2.png"));
    Image Im1down = new Image(PATH_IMAGE.concat(nameGhost).concat("_down1.png"));
    Image Im2down = new Image(PATH_IMAGE.concat(nameGhost).concat("_down2.png"));
    Image Im1left = new Image(PATH_IMAGE.concat(nameGhost).concat("_left1.png"));
    Image Im2left = new Image(PATH_IMAGE.concat(nameGhost).concat("_left2.png"));
    Image Im1right = new Image(PATH_IMAGE.concat(nameGhost).concat("_right1.png"));
    Image Im2right = new Image(PATH_IMAGE.concat(nameGhost).concat("_right2.png"));
    
    Texture []t = new Texture[8];
    t[0] = Im1up.getTexture();
    t[1] = Im2up.getTexture();
    t[2] = Im1down.getTexture();
    t[3] = Im2down.getTexture();
    t[4] = Im1left.getTexture();
    t[5] = Im2left.getTexture();
    t[6] = Im1right.getTexture();
    t[7] = Im2right.getTexture();
    
    return t;
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-C,代碼行數:32,代碼來源:GhostAnimation.java

示例5: loadTexture

import org.newdawn.slick.opengl.Texture; //導入依賴的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

示例6: loadTexture

import org.newdawn.slick.opengl.Texture; //導入依賴的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

示例7: setup

import org.newdawn.slick.opengl.Texture; //導入依賴的package包/類
/**
 * Setup.
 *
 * @param u the u
 * @return the shader args
 */
public static ShaderArgs setup(FightUnit u) {
	Unit unit = u.getUnit();
	ShaderArgs args = new ShaderArgs();
	if(unit.getTheClass().name.equals("Lord")) return args;
	String c = unit.functionalClassName();
	
	Texture t = palettes.get(c);
	if(t == null) return args;
	if(lookup.get(c) == null) return args;
	int offset = lookup.get(c).indexOf(unit.name);
	if(offset < 0) return args;
	args.programName = "paletteSwap";
	args.args = new float[] {t.getTextureWidth(), t.getTextureHeight(), offset, t.getImageWidth()};
	GL13.glActiveTexture(GL13.GL_TEXTURE8);
	t.bind();
	GL13.glActiveTexture(GL13.GL_TEXTURE0);
	return args;
}
 
開發者ID:eliatlarge,項目名稱:FEMultiPlayer-V2,代碼行數:25,代碼來源:PaletteSwapper.java

示例8: render

import org.newdawn.slick.opengl.Texture; //導入依賴的package包/類
public void render(){
	Renderer.drawRectangle(x-24, y-6, x+85, y+20, renderDepth, FightStage.BORDER_DARK);
	Renderer.drawRectangle(x-23, y-5, x+84, y+19, renderDepth, FightStage.BORDER_LIGHT);
	Renderer.drawRectangle(x-22, y-4, x+83, y+18, renderDepth, color);
	int offY = 0;
	int offX = 0;
	int width = FEResources.getBitmapFont("stat_numbers").getStringWidth((int)displayedHealth + "");
	if(totalHealth <= 40) {
		Renderer.drawString("stat_numbers", (int)displayedHealth + "", x-5-width, y-2, renderDepth);
	} else {
		Renderer.drawString("stat_numbers", (int)displayedHealth + "", x-5-width, y+2, renderDepth);
	}
	for (int hp = 1; hp <= totalHealth; hp++) {
		Texture t = hp <= displayedHealth ? tickFilled : tickEmpty;
		Renderer.render(t, 0, 0, 1, 1, x + offX, y + offY, x + offX + 2, y
				+ offY + 6, renderDepth);
		
		if(hp == 40){
			offY = 8;
			offX = 0;
		} else {
			offX +=2;
		}
	}
}
 
開發者ID:eliatlarge,項目名稱:FEMultiPlayer-V2,代碼行數:26,代碼來源:Healthbar.java

示例9: render

import org.newdawn.slick.opengl.Texture; //導入依賴的package包/類
public void render() {
	int offY = 0;
	int offX = 0;
	int width = FEResources.getBitmapFont("stat_numbers").getStringWidth((int)displayedHealth + "");
	if(totalHealth <= 40) {
		Renderer.drawString("stat_numbers", (int)displayedHealth + "", x-5-width, y-2, renderDepth);
	} else {
		Renderer.drawString("stat_numbers", (int)displayedHealth + "", x-5-width, y+2, renderDepth);
	}
	for (int hp = 1; hp <= totalHealth; hp++) {
		Texture t = hp <= displayedHealth? filled: empty;
		Renderer.render(t, 0, 0, 1, 1, x + offX, y + offY, x + offX + 2, y
				+ offY + 6, renderDepth);
		
		if(hp == 40){
			offY = 8;
			offX = 0;
		} else {
			offX +=2;
		}
	}
}
 
開發者ID:eliatlarge,項目名稱:FEMultiPlayer-V2,代碼行數:23,代碼來源:Healthbar.java

示例10: render

import org.newdawn.slick.opengl.Texture; //導入依賴的package包/類
/**
 * Draws the sprite .
 *
 * @param x the x
 * @param y the y
 * @param depth the depth
 * @param transform the transform
 * @param shader the shader
 */
public void render(float x, float y, float depth, Transform transform, ShaderArgs shader) {
	if(currentAnimation == null) return;
	
	int width = currentAnimation.getWidth();
	int height = currentAnimation.getHeight();
	int frameX = currentAnimation.getFrame() % currentAnimation.getColumns();
	int frameY = currentAnimation.getFrame() / currentAnimation.getColumns();
	int offX = currentAnimation.getOffsetX();
	int offY = currentAnimation.getOffsetY();;
	if(transform != null) {
		if(transform.flipHorizontal) {
			offX = -offX + width;
		}
		if(transform.flipVertical) {
			offY = -offY + height;
		}
	}
	float x0 = ((float)frameX * width)/currentAnimation.getImageWidth();
	float x1 = ((float)(frameX+1) * width)/currentAnimation.getImageWidth();
	float y0 = ((float)frameY * height)/currentAnimation.getImageHeight();
	float y1 = ((float)(frameY+1) * height)/currentAnimation.getImageHeight();
	Texture texture = currentAnimation.getTexture();
	Renderer.render(texture, x0, y0, x1, y1, x - offX, y - offY,
			x + width - offX, y + height - offY, depth, transform, shader, currentAnimation.getBlendMode());
}
 
開發者ID:eliatlarge,項目名稱:FEMultiPlayer-V2,代碼行數:35,代碼來源:Sprite.java

示例11: loadTexture

import org.newdawn.slick.opengl.Texture; //導入依賴的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

示例12: loadTexture

import org.newdawn.slick.opengl.Texture; //導入依賴的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

示例13: Init

import org.newdawn.slick.opengl.Texture; //導入依賴的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

示例14: GUI_Button

import org.newdawn.slick.opengl.Texture; //導入依賴的package包/類
public GUI_Button(int startX, int startY, int width, int height, Texture t){
	int displayWidth = NextPowerOf2(Game.Width);
	int displayHeight = NextPowerOf2(Game.Height);
	int gameWidth = Game.Width;
	int gameHeight = Game.Height;
	//System.out.println(startX);
	//System.out.println(gameWidth);
	//System.out.println(displayWidth);
	ScreenX=startX;
	ScreenY=startY;
	ScreenButtonWidth=width;
	ScreenButtonHeight=height;
	StartX=(int) (((float)startX/(float)gameWidth)*(float)displayWidth);
	StartY=(int) (((float)startY/(float)gameHeight)*(float)displayHeight);
	Width = (int) (((float)width/(float)gameWidth)*(float)displayWidth);
	Height=(int) (((float)height/(float)gameHeight)*(float)displayHeight);
	ScreenWidth=gameWidth;
	ScreenHeight=gameHeight;
	texture=t;
	
}
 
開發者ID:Glynn-Taylor,項目名稱:Heightmap-Renderer,代碼行數:22,代碼來源:GUI_Button.java

示例15: init

import org.newdawn.slick.opengl.Texture; //導入依賴的package包/類
/**
 * Initialise the PBuffer that will be used to render to
 *
 * @throws SlickException
 */
private void init() throws SlickException {
    try {
        Texture tex = InternalTextureLoader.get().createTexture(image.getWidth(), image.getHeight(), image.getFilter());

        final RenderTexture rt = new RenderTexture(false, true, false, false, RenderTexture.RENDER_TEXTURE_2D, 0);
        pbuffer = new Pbuffer(screenWidth, screenHeight, new PixelFormat(8, 0, 0), rt, null);

        // Initialise state of the pbuffer context.
        pbuffer.makeCurrent();

        initGL();
        GL.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureID());
        pbuffer.releaseTexImage(Pbuffer.FRONT_LEFT_BUFFER);

        if (image.getTexture()!=null)
            image.draw(0,0);
        Graphics.setCurrent(this); //this means you need to call flush() after getGraphics()
        image.setTexture(tex);

        Display.makeCurrent();
    } catch (Exception e) {
        Log.error(e);
        throw new SlickException("Failed to create PBuffer for dynamic image. OpenGL driver failure?");
    }
}
 
開發者ID:FOShameDotOrg,項目名稱:fuzzy-octo-shame,代碼行數:31,代碼來源:PBufferGraphics.java


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