Java Code Examples for org.newdawn.slick.opengl.TextureImpl#bindNone()

The following examples show how to use org.newdawn.slick.opengl.TextureImpl#bindNone() . 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: 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 2
Source File: Graphics.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Draw an oval to the canvas
 * 
 * @param x1
 *            The x coordinate of the top left corner of a box containing
 *            the arc
 * @param y1
 *            The y coordinate of the top left corner of a box containing
 *            the arc
 * @param width
 *            The width of the arc
 * @param height
 *            The height of the arc
 * @param segments
 *            The number of line segments to use when drawing the arc
 * @param start
 *            The angle the arc starts at
 * @param end
 *            The angle the arc ends at
 */
public void drawArc(float x1, float y1, float width, float height,
		int segments, float start, float end) {
	predraw();
	TextureImpl.bindNone();
	currentColor.bind();

	while (end < start) {
		end += 360;
	}

	float cx = x1 + (width / 2.0f);
	float cy = y1 + (height / 2.0f);

	LSR.start();
	int step = 360 / segments;

	for (int a = (int) start; a < (int) (end + step); a += step) {
		float ang = a;
		if (ang > end) {
			ang = end;
		}
		float x = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * width / 2.0f));
		float y = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * height / 2.0f));

		LSR.vertex(x,y);
	}
	LSR.end();
	postdraw();
}
 
Example 3
Source File: Graphics.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Fill a rectangle on the canvas in the current color
 * 
 * @param x1
 *            The x coordinate of the top left corner
 * @param y1
 *            The y coordinate of the top left corner
 * @param width
 *            The width of the rectangle to fill
 * @param height
 *            The height of the rectangle to fill
 */
public void fillRect(float x1, float y1, float width, float height) {
	predraw();
	TextureImpl.bindNone();
	currentColor.bind();

	GL.glBegin(SGL.GL_QUADS);
	GL.glVertex2f(x1, y1);
	GL.glVertex2f(x1 + width, y1);
	GL.glVertex2f(x1 + width, y1 + height);
	GL.glVertex2f(x1, y1 + height);
	GL.glEnd();
	postdraw();
}
 
Example 4
Source File: SimpleDiagramRenderer.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Render the diagram to the given graphics context
 * 
 * @param g The graphics context to which we should render the diagram
 */
public void render(Graphics g) {
	// last list generation
	if (list == -1) {
		list = GL.glGenLists(1);
		GL.glNewList(list, SGL.GL_COMPILE);
			render(g, diagram);
		GL.glEndList();
	}
	
	GL.glCallList(list);
	
	TextureImpl.bindNone();
}
 
Example 5
Source File: Graphics.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Draw the the given shape filled in with a texture
 * 
 * @param shape
 *            The shape to texture.
 * @param image
 *            The image to tile across the shape
 * @param scaleX
 *            The scale to apply on the x axis for texturing
 * @param scaleY
 *            The scale to apply on the y axis for texturing
 * @param fit
 *            True if we want to fit the image on to the shape
 */
public void texture(Shape shape, Image image, float scaleX, float scaleY,
		boolean fit) {
	predraw();
	TextureImpl.bindNone();
	currentColor.bind();

	if (fit) {
		ShapeRenderer.textureFit(shape, image, scaleX, scaleY);
	} else {
		ShapeRenderer.texture(shape, image, scaleX, scaleY);
	}
	
	postdraw();
}
 
Example 6
Source File: Graphics.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Draw the the given shape filled in.
 * 
 * @param shape
 *            The shape to fill.
 */
public void fill(Shape shape) {
	predraw();
	TextureImpl.bindNone();
	currentColor.bind();

	ShapeRenderer.fill(shape);

	postdraw();
}
 
Example 7
Source File: Graphics.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Draw the outline of the given shape.
 * 
 * @param shape
 *            The shape to draw.
 */
public void draw(Shape shape) {
	predraw();
	TextureImpl.bindNone();
	currentColor.bind();

	ShapeRenderer.draw(shape);

	postdraw();
}
 
Example 8
Source File: Particle.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Render this particle
 */
public void render() {
	if ((engine.usePoints() && (usePoints == INHERIT_POINTS))
			|| (usePoints == USE_POINTS)) {
		TextureImpl.bindNone();
		GL.glEnable(SGL.GL_POINT_SMOOTH);
		GL.glPointSize(size / 2);
		color.bind();
		GL.glBegin(SGL.GL_POINTS);
		GL.glVertex2f(x, y);
		GL.glEnd();
	} else if (oriented || scaleY != 1.0f) {
		GL.glPushMatrix();

		GL.glTranslatef(x, y, 0f);

		if (oriented) {
			float angle = (float) (Math.atan2(y, x) * 180 / Math.PI);
			GL.glRotatef(angle, 0f, 0f, 1.0f);
		}

		// scale
		GL.glScalef(1.0f, scaleY, 1.0f);

		image.draw((int) (-(size / 2)), (int) (-(size / 2)), (int) size,
				(int) size, color);
		GL.glPopMatrix();
	} else {
		color.bind();
		image.drawEmbedded((int) (x - (size / 2)), (int) (y - (size / 2)),
				(int) size, (int) size);
	}
}
 
Example 9
Source File: Graphics.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Draw the outline of the given shape.
 * 
 * @param shape
 *            The shape to draw.
 * @param fill
 *            The fill type to apply
 */
public void draw(Shape shape, ShapeFill fill) {
	predraw();
	TextureImpl.bindNone();

	ShapeRenderer.draw(shape, fill);

	currentColor.bind();
	postdraw();
}
 
Example 10
Source File: Graphics.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Draw a line with a gradient between the two points.
 * 
 * @param x1
 *            The starting x position to draw the line
 * @param y1
 *            The starting y position to draw the line
 * @param Color1
 *            The starting position's color
 * @param x2
 *            The ending x position to draw the line
 * @param y2
 *            The ending y position to draw the line
 * @param Color2
 *            The ending position's color
 */
public void drawGradientLine(float x1, float y1, Color Color1, float x2,
							 float y2, Color Color2) {
	predraw();

	TextureImpl.bindNone();

	GL.glBegin(SGL.GL_LINES);

	Color1.bind();
	GL.glVertex2f(x1, y1);

	Color2.bind();
	GL.glVertex2f(x2, y2);

	GL.glEnd();

	postdraw();
}
 
Example 11
Source File: Graphics.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Draw a line with a gradient between the two points.
 * 
 * @param x1
 *            The starting x position to draw the line
 * @param y1
 *            The starting y position to draw the line
 * @param red1
 *            The starting position's shade of red
 * @param green1
 *            The starting position's shade of green
 * @param blue1
 *            The starting position's shade of blue
 * @param alpha1
 *            The starting position's alpha value
 * @param x2
 *            The ending x position to draw the line
 * @param y2
 *            The ending y position to draw the line
 * @param red2
 *            The ending position's shade of red
 * @param green2
 *            The ending position's shade of green
 * @param blue2
 *            The ending position's shade of blue
 * @param alpha2
 *            The ending position's alpha value
 */
public void drawGradientLine(float x1, float y1, float red1, float green1,
								float blue1, float alpha1, float x2, float y2, float red2,
								float green2, float blue2, float alpha2) {
	predraw();

	TextureImpl.bindNone();

	GL.glBegin(SGL.GL_LINES);

	GL.glColor4f(red1, green1, blue1, alpha1);
	GL.glVertex2f(x1, y1);

	GL.glColor4f(red2, green2, blue2, alpha2);
	GL.glVertex2f(x2, y2);

	GL.glEnd();

	postdraw();
}
 
Example 12
Source File: ParticleSystem.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Render the particles in the system
 * 
 * @param x The x coordinate to render the particle system at (in the current coordinate space)
 * @param y The y coordinate to render the particle system at (in the current coordiante space)
 */
public void render(float x, float y) {
	if ((sprite == null) && (defaultImageName != null)) {
		loadSystemParticleImage();
	}
	
	if (!visible) {
		return;
	}
	
	GL.glTranslatef(x,y,0);
	
	if (blendingMode == BLEND_ADDITIVE) {
		GL.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE);
	}
	if (usePoints()) {
		GL.glEnable( SGL.GL_POINT_SMOOTH ); 
		TextureImpl.bindNone();
	}
	
	// iterate over all emitters
	for( int emitterIdx=0; emitterIdx<emitters.size(); emitterIdx++ )
	{
		// get emitter
		ParticleEmitter emitter = (ParticleEmitter) emitters.get(emitterIdx);
		
		if (!emitter.isEnabled()) {
			continue;
		}
		
		// check for additive override and enable when set
		if (emitter.useAdditive()) {
			GL.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE);
		}
		
		// now get the particle pool for this emitter and render all particles that are in use
		ParticlePool pool = (ParticlePool) particlesByEmitter.get(emitter);
		Image image = emitter.getImage();
		if (image == null) {
			image = this.sprite;
		}
		
		if (!emitter.isOriented() && !emitter.usePoints(this)) {
			image.startUse();
		}
		
		for (int i = 0; i < pool.particles.length; i++)
		{
			if (pool.particles[i].inUse())
				pool.particles[i].render();
		} 
		
		if (!emitter.isOriented() && !emitter.usePoints(this)) {
			image.endUse();
		}

		// reset additive blend mode
		if (emitter.useAdditive()) {
			GL.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE_MINUS_SRC_ALPHA);
		}
	}

	if (usePoints()) {
		GL.glDisable( SGL.GL_POINT_SMOOTH ); 
	}
	if (blendingMode == BLEND_ADDITIVE) {
		GL.glBlendFunc(SGL.GL_SRC_ALPHA, SGL.GL_ONE_MINUS_SRC_ALPHA);
	}
	
	Color.white.bind();
	GL.glTranslatef(-x,-y,0);
}
 
Example 13
Source File: Graphics.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Draw the the given shape filled in with a texture
 * 
 * @param shape
 *            The shape to texture.
 * @param image
 *            The image to tile across the shape
 * @param scaleX
 *            The scale to apply on the x axis for texturing
 * @param scaleY
 *            The scale to apply on the y axis for texturing
 * @param fill
 *            The shape fill to apply
 */
public void texture(Shape shape, Image image, float scaleX, float scaleY,
		ShapeFill fill) {
	predraw();
	TextureImpl.bindNone();
	currentColor.bind();

	ShapeRenderer.texture(shape, image, scaleX, scaleY, fill);

	postdraw();
}
 
Example 14
Source File: Image.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Create an image from a pixelData of pixels
 * 
 * @param buffer The pixelData to use to create the image
 * @param filter The filter to use when scaling this image
 */
Image(ImageBuffer buffer, int filter) {
	this((ImageData) buffer, filter);
       TextureImpl.bindNone();
}
 
Example 15
Source File: Image.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Create an image from a pixelData of pixels
 * 
 * @param buffer The pixelData to use to create the image
 */
Image(ImageBuffer buffer) {
	this(buffer, FILTER_LINEAR);
       TextureImpl.bindNone();
}
 
Example 16
Source File: Image.java    From opsu with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Create an image from a pixelData of pixels
 * 
 * @param buffer The pixelData to use to create the image
 * @param filter The filter to use when scaling this image
 */
Image(ImageBuffer buffer, int filter) {
	this((ImageData) buffer, filter);
       TextureImpl.bindNone();
}
 
Example 17
Source File: Image.java    From opsu with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Create an image from a pixelData of pixels
 * 
 * @param buffer The pixelData to use to create the image
 */
Image(ImageBuffer buffer) {
	this(buffer, FILTER_LINEAR);
       TextureImpl.bindNone();
}
 
Example 18
Source File: Image.java    From opsu-dance with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Create an image from a pixelData of pixels
 * 
 * @param buffer The pixelData to use to create the image
 * @param filter The filter to use when scaling this image
 */
Image(ImageBuffer buffer, int filter) {
	this((ImageData) buffer, filter);
       TextureImpl.bindNone();
}
 
Example 19
Source File: Image.java    From opsu-dance with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Create an image from a pixelData of pixels
 * 
 * @param buffer The pixelData to use to create the image
 */
Image(ImageBuffer buffer) {
	this(buffer, FILTER_LINEAR);
       TextureImpl.bindNone();
}