All pastes #38969 Raw Edit

Untitled

public java v1 · immutable
#38969 ·published 2006-01-29 01:44 UTC
rendered paste body
/**	 * Draw the sprite at the specified location	 * 	 * @param x The x location at which to draw this sprite	 * @param y The y location at which to draw this sprite	 */	public void draw(int x, int y) {		GL11.glPushMatrix();				// bind to the appropriate texture for this sprite		texture.bind();    		// translate to the right location and prepare to draw		GL11.glTranslatef(x, y, 0);		    	GL11.glColor3f(red, green, blue);    	    	// Translate before and after Rotate to rotate from center and not the corner    	GL11.glTranslatef(width/2, height/2, 0);    	GL11.glRotatef(rotate, 0, 0, 1.0f);    	GL11.glTranslatef(-(width/2), -(height/2), 0);    	    	    	//the rectangle should be blended with the background. (transparent)    	GL11.glEnable(GL11.GL_BLEND);		GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);						// draw a quad textured to match the sprite    	GL11.glBegin(GL11.GL_QUADS);		{	      			GL11.glTexCoord2f(0, texture.getHeight()); 	 			GL11.glVertex2f(0, 0);		     			GL11.glTexCoord2f(0, 0); 			GL11.glVertex2f(0, height);		    			GL11.glTexCoord2f(texture.getWidth(), 0);					GL11.glVertex2f(width,height);		    			  			GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());			      			GL11.glVertex2f(width,0);      		}		GL11.glEnd();					// restore the model view matrix to prevent contamination		GL11.glPopMatrix();	}