private TextureManager loadTexture(String path, String root) {

        //        String[] splitArray = path.split("\\.");
        //        String extension = splitArray[splitArray.length - 1];
        File file = null;
        BufferedImage image = null;
        System.out.println("Attempting to load a new texture: <" + root + "/" + path + ">");
        file = new File(root + "/" + path + ".png");
        try {
            image = ImageIO.read(file);
        } catch (IOException e) {
            System.err.println("Could not find texture: <" + root + "/" + path + ">");
            return textures.get(MISSING_TEXTURE_FILE);
        }
        try {
            int[] pixels = image.getRGB(0, 0, image.getWidth(), image.getHeight(), null, 0, image.getWidth());
            ByteBuffer buffer = Util.createByteBuffer(image.getWidth() * image.getHeight() * 4);
            boolean hasAlpha = image.getColorModel().hasAlpha();
            for (int y = 0; y < image.getHeight(); y++) {
                for (int x = 0; x < image.getWidth(); x++) {
                    int pixel = pixels[y * image.getWidth() + x];
                    buffer.put((byte) ((pixel >> 16) & 0xFF));
                    buffer.put((byte) ((pixel >> 8) & 0xFF));
                    buffer.put((byte) ((pixel) & 0xFF));
                    if (hasAlpha) buffer.put((byte) ((pixel >> 24) & 0xFF));
                    else buffer.put((byte) 0xFF);
                }
            }
            buffer.flip();
            this.data = new TextureData(image.getWidth(), image.getHeight(), buffer);
            System.out.println("Succesfully loaded texture from file: <" + file.getPath() + ">");

            TextureManager result = new TextureManager();
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, result.getID());

            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);

            GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, image.getWidth(), image.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer);
            return result;
        } catch (Exception e) {
            System.err.println("Could not load texture: <" + path + ".png>");
            System.exit(1);
        }
        return null;

    }