/** * Load (or reuse) a texture from a file to perform an action. */ public void withTexture(string textureFile, int textureType, TextureCallback action) { if (textureCache.ContainsKey(textureFile)) { textureCache[textureFile].withTexture(action); } else { // Create the texture state object TextureState newState = new TextureState(); newState.withTexture(action); textureCache[textureFile] = newState; bool createMipMaps = true; bool linear = false; bool isNormal = false; bool compress = true; switch (textureType) { case TYPE_SPECULAR: case TYPE_GLOSS: linear = true; break; case TYPE_NORMAL: linear = true; isNormal = true; compress = false; break; default: break; } // Begin loading the texture var img = new ImageLoaderThreaded.QueuedImage(); img.imgPath = textureFile; img.callback = qimg => newState.applyTexture(qimg); img.createMipMaps = createMipMaps; img.isNormalMap = isNormal; img.linear = linear; img.compress = compress; ImageLoaderThreaded.singleton.QueueImage(img); } }
/** * Load (or reuse) a texture from a file to perform an action. */ public void withTexture(string textureFile, TextureCallback action) { if (textureCache.ContainsKey(textureFile)) { textureCache[textureFile].withTexture(action); } else { // Create the texture state object TextureState newState = new TextureState(); newState.withTexture(action); textureCache[textureFile] = newState; // Begin loading the texture var img = new ImageLoaderThreaded.QueuedImage(); img.imgPath = textureFile; img.createMipMaps = true; img.callback = qimg => newState.applyTexture(qimg); ImageLoaderThreaded.singleton.QueueImage(img); } }