function createTexture(scene, cfg, onComplete) {
        var context = scene.canvas.context;
        var textureId = SceneJS._createUUID();
        var update;
        try {
            if (cfg.autoUpdate) {
                update = function() {

                    //TODO: fix this when minefield is upto spec
                    try {
                        context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, context.RGBA, context.UNSIGNED_BYTE, image);
                    }
                    catch(e) {
                        context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, context.RGBA, context.UNSIGNED_BYTE, image, null);
                    }
                    context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MAG_FILTER, context.LINEAR);
                    context.texParameteri(context.TEXTURE_2D, context.TEXTURE_MIN_FILTER, context.LINEAR);
                    //context.generateMipmap(context.TEXTURE_2D);
                };
            }
            return new SceneJS_webgl_Texture2D(context, {
                textureId : textureId,
                canvas: scene.canvas,
                image : cfg.image,
                url: cfg.uri,
                texels :cfg.texels,
                minFilter : getGLOption("minFilter", context, cfg, context.NEAREST_MIPMAP_NEAREST),
                magFilter :  getGLOption("magFilter", context, cfg, context.LINEAR),
                wrapS : getGLOption("wrapS", context, cfg, context.CLAMP_TO_EDGE),
                wrapT :   getGLOption("wrapT", context, cfg, context.CLAMP_TO_EDGE),
                isDepth :  getOption(cfg.isDepth, false),
                depthMode : getGLOption("depthMode", context, cfg, context.LUMINANCE),
                depthCompareMode : getGLOption("depthCompareMode", context, cfg, context.COMPARE_R_TO_TEXTURE),
                depthCompareFunc : getGLOption("depthCompareFunc", context, cfg, context.LEQUAL),
                flipY : getOption(cfg.flipY, true),
                width: getOption(cfg.width, 1),
                height: getOption(cfg.height, 1),
                internalFormat : getGLOption("internalFormat", context, cfg, context.LEQUAL),
                sourceFormat : getGLOption("sourceType", context, cfg, context.ALPHA),
                sourceType : getGLOption("sourceType", context, cfg, context.UNSIGNED_BYTE),
                logging: SceneJS_loggingModule ,
                update: update
            }, onComplete);
        } catch (e) {
            throw SceneJS_errorModule.fatalError(SceneJS.errors.ERROR, "Failed to create texture: " + e.message || e);
        }
    }
Creates texture from either image URL or image object