@Override
    public void setTextureImage(int unit, TextureImage tex) throws TextureUnitException {
        if (unit < 0 || unit >= RenderContext.maxTextureUnits) {
            throw new TextureUnitException();
        }
        WeakReference<Image> ref = context.boundTextures[unit];
        boolean bindRequired = tex.clearUpdateNeeded() || ref == null || ref.get() != tex.getImage().getWeakRef().get();
        setTexture(unit, tex.getTexture());
        if (gl4 != null && bindRequired) {
            tex.bindImage(gl4, texUtil, unit);
        }
    }
Uploads the given image to the GL driver.

@param img The image to upload
@param type How the data in the image argument should be interpreted.
@param unit The texture slot to be used to upload the image, not important
@param scaleToPot If true, the image will be scaled to power-of-2 dimensions
before being uploaded.
jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java