public static Image New(string filename, bool flip, Loader.LoadedCallbackMethod loadedCallback) { string ext = Streams.GetFileExt(filename); switch (ext.ToLower()) { case ".dds": return(new ImageDDS(filename, flip, loadedCallback)); case ".atc": return(new ImageDDS(filename, flip, loadedCallback)); case ".pvr": return(new ImagePVR(filename, flip, loadedCallback)); #if !XNA && NaCl case ".bmpc": return(new ImageBMPC(filename, flip, loadedCallback)); #endif #if (!XNA && !NaCl && !VITA) || SILVERLIGHT #if !WP8 case ".bmpc": return(new ImageBMPC(filename, flip, loadedCallback)); #endif case ".png": return(new ImagePNG(filename, flip, loadedCallback)); case ".jpg": return(new ImageJPG(filename, flip, loadedCallback)); case ".jpeg": return(new ImageJPG(filename, flip, loadedCallback)); #if !iOS && !ANDROID case ".bmp": return(new ImageBMP(filename, flip, loadedCallback)); #endif #endif default: Debug.ThrowError("Image", string.Format("File 'ext' {0} not supported.", ext)); return(null); } }
public SoftwareModel(string filename, Loader.LoadedCallbackMethod loadedCallback) { string fileType = Streams.GetFileExt(filename).ToLower(); if (fileType != ".rmx") { Debug.ThrowError("SoftwareModel", "Unsuported file type: " + fileType); } new StreamLoader(filename, delegate(object sender, bool succeeded) { if (succeeded) { init(((StreamLoader)sender).LoadedStream, loadedCallback); } else { FailedToLoad = true; if (loadedCallback != null) { loadedCallback(this, false); } } }); }
private void handleFoundTextureBinder(MaterialI material, FieldInfo materialField, IDictionary values, MaterialFieldBinder binder, string contentDirectory, Dictionary <string, string> fileExtOverrides) { var textureFileName = ((Dictionary <string, string>)values)[binder.InputID]; if (fileExtOverrides != null) { string ext = Streams.GetFileExt(textureFileName); if (fileExtOverrides.ContainsKey(ext)) { textureFileName = Streams.GetFileNameWithoutExt(textureFileName) + fileExtOverrides[ext]; } else { textureFileName = Streams.GetFileNameWithExt(textureFileName); } } else { textureFileName = Streams.GetFileNameWithExt(textureFileName); } // TODO load texture unless already loaded... //texture = parent.FindChild<Texture2D> //( // "NewReference", // new ConstructorParam(typeof(IDisposableResource), parent), // new ConstructorParam(typeof(string), filename), // new ConstructorParam(typeof(Loader.LoadedCallbackMethod), null) //); //if (texture != null) //{ // ++texture.referenceCount; // return texture; //} //return new Texture2D(parent, filename, loadedCallback); //var texture = Texture2DAPI.New(Parent, contentDirectory + textureFileName, null); //texture.AddReference(); ITexture2D texture = null; if (!Textures.Contains(texture)) { Textures.Add(texture); } materialField.SetValue(material, texture); }
public static ISound New(AudioTypes audioType, IDisposableResource parent, string filename, int instanceCount, bool looped, Loader.LoadedCallbackMethod loadedCallback) { ISound api = null; var soundFormat = SoundFormats.None; string ext = Streams.GetFileExt(filename); switch (ext.ToLower()) { case ".wav": soundFormat = SoundFormats.WAV; break; default: Debug.ThrowError("SoundAPI", string.Format("File 'ext' {0} not supported.", ext)); return(null); } #if WIN32 || WINRT if (soundFormat == SoundFormats.WAV) { if (audioType == AudioTypes.XAudio) { api = new XAudio.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } } #endif #if XNA if (soundFormat == SoundFormats.WAV) { if (audioType == AudioTypes.XNA) { api = new XNA.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } } #endif #if OSX || iOS if (soundFormat == SoundFormats.WAV) { if (audioType == AudioTypes.Cocoa) { api = new Cocoa.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } } #endif #if LINUX if (soundFormat == SoundFormats.WAV) { if (audioType == AudioTypes.OpenAL) { api = new OpenAL.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } } #endif #if ANDROID if (soundFormat == SoundFormats.WAV) { if (audioType == AudioTypes.Android) { api = new Android.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } } #endif if (audioType == AudioTypes.Dumby) { api = new Dumby.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } if (api == null) { Debug.ThrowError("SoundAPI", "Unsuported InputType: " + audioType); } return(api); }