int getTexture(BufferedImage bi)
	{
		try
		{
			GL11.glGenTextures(RenderEngine.intbuf);
			final int id = RenderEngine.intbuf.get(0);

			GL11.glBindTexture(GL11.GL_TEXTURE_2D, id);

			final int format = bi.getColorModel().hasAlpha() ? GL11.GL_RGBA : GL11.GL_RGB;

			ByteBuffer texData;
			WritableRaster raster;
			BufferedImage texImage;

			if (Math.log10(bi.getWidth()) / Math.log10(2) % 1 != 0 || Math.log10(bi.getHeight()) / Math.log10(2) % 1 != 0)
			{
				throw new RuntimeException();
			}

			final int texWidth = bi.getWidth();
			final int texHeight = bi.getHeight();

			if (bi.getColorModel().hasAlpha())
			{
				raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, texWidth, texHeight, 4, null);
				texImage = new BufferedImage(RenderEngine.glAlphaColorModel, raster, false, new Hashtable<String, Object>());
			}
			else
			{
				raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, texWidth, texHeight, 3, null);
				texImage = new BufferedImage(RenderEngine.glColorModel, raster, false, new Hashtable<String, Object>());
			}

			final Graphics g = texImage.getGraphics();
			g.setColor(new Color(0f, 0f, 0f, 0f));
			g.fillRect(0, 0, texWidth, texHeight);
			g.drawImage(bi, 0, 0, null);

			final byte[] data = ((DataBufferByte) texImage.getRaster().getDataBuffer()).getData();

			texData = ByteBuffer.allocateDirect(data.length);
			texData.order(ByteOrder.nativeOrder());
			texData.put(data, 0, data.length);
			texData.flip();

			GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
			GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);

			GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, bi.getWidth(), bi.getHeight(), 0, format, GL11.GL_UNSIGNED_BYTE, texData);

			return id;
		}
		catch (final Exception e)
		{
			e.printStackTrace();
			System.exit(0);
			return 0;
		}
	}