private void createTextureFromImage(BufferedImage image, int mipMapLevel) {
		int width = image.getWidth();
		int height = image.getHeight();
		boolean hasAlpha = image.getColorModel().hasAlpha();

		ByteBuffer buffer = ByteBuffer.allocateDirect((hasAlpha ? 4 : 3) * width * height);

		for (int y = 0; y < height; ++y) {
			for (int x = 0; x < width; ++x) {
				int argb = image.getRGB(x, y);
				buffer.put((byte) ((argb >> 16) & 0xff));
				buffer.put((byte) ((argb >> 8) & 0xff));
				buffer.put((byte) (argb & 0xff));
				if (hasAlpha) {
					buffer.put((byte) ((argb >> 24) & 0xff));
				}
			}
		}
		buffer.flip();

		if (mipMapLevel == 0) {
			id = glGenTextures();
		}
		glBindTexture(GL_TEXTURE_2D, id);

        glTexImage2D(GL_TEXTURE_2D, mipMapLevel, hasAlpha ? GL_RGBA : GL_RGB, width, height, 0, hasAlpha ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, buffer);

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    }