Java Code Examples for org.newdawn.slick.opengl.Texture#bind()

The following examples show how to use org.newdawn.slick.opengl.Texture#bind() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PaletteSwapper.java    From FEMultiPlayer-V2 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 2
Source File: PaletteSwapper.java    From FEMultiplayer with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: ShapeRenderer.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * 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();
    }
}
 
Example 4
Source File: MainMenu.java    From opsu-dance with GNU General Public License v3.0 5 votes vote down vote up
private void drawMenuButton(
	Image img,
	int x,
	int y,
	int clipxtop,
	int clipxbot,
	Color col)
{
	col.bind();
	final Texture t = img.getTexture();
	t.bind(); 
	
	final int width = img.getWidth();
	final int height = img.getHeight();
	final float twidth = t.getWidth();
	final float theight = t.getHeight();
	y -= height / 2;
	
	final float texXtop = clipxtop > 0 ? (float) clipxtop / width * twidth : 0f;
	final float texXbot = clipxbot > 0 ? (float) clipxbot / width * twidth : 0f;

	GL11.glBegin(SGL.GL_QUADS); 
	GL11.glTexCoord2f(texXtop, 0);
	GL11.glVertex3i(x + clipxtop, y, 0);
	GL11.glTexCoord2f(twidth, 0);
	GL11.glVertex3i(x + width, y, 0);
	GL11.glTexCoord2f(twidth, theight);
	GL11.glVertex3i(x + width, y + height, 0);
	GL11.glTexCoord2f(texXbot, theight);
	GL11.glVertex3i(x + clipxbot, y + height, 0);
	GL11.glEnd(); 
}
 
Example 5
Source File: PaletteSwapper.java    From FEMultiPlayer-V2 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Setup.
 *
 * @param u the u
 * @return the shader args
 */
public static ShaderArgs setup(Unit u) {
	ShaderArgs args = new ShaderArgs();
	int offset = u.getPartyColor().equals(Party.TEAM_BLUE) ? 0 : 1;
	if(offset == 0) return args;
	
	Texture t = palettes.get("overworld");
	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;
}
 
Example 6
Source File: PaletteSwapper.java    From FEMultiplayer with GNU General Public License v3.0 5 votes vote down vote up
public static ShaderArgs setup(Unit u) {
	ShaderArgs args = new ShaderArgs();
	int offset = u.getPartyColor().equals(Party.TEAM_BLUE) ? 0 : 1;
	if(offset == 0) return args;
	
	Texture t = palettes.get("overworld");
	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;
}
 
Example 7
Source File: TextureManager.java    From Slyther with MIT License 4 votes vote down vote up
public void bindTexture(String path) {
    Texture texture = getTexture(path);
    if (texture != null) {
        texture.bind();
    }
}