/// <summary> /// Load an effect from an hlsl .fx file /// </summary> public static BasicShader LoadFromFXFile(IXNAGame game, IGameFile file) { BasicShader shader = new BasicShader(game); //obs? // Dispose old shader if (shader.effect != null) { shader.effect.Dispose(); shader.effect = null; } CompiledEffect compiledEffect; try { compiledEffect = Effect.CompileEffectFromFile(file.GetFullFilename(), null, null, CompilerOptions.None, TargetPlatform.Windows); shader.effect = new Effect(game.GraphicsDevice, compiledEffect.GetEffectCode(), CompilerOptions.None, null); } // try catch (Exception ex) { /*Log.Write( "Failed to load shader " + shaderContentName + ". " + * "Error: " + ex.ToString() );*/ // Rethrow error, app can't continue! throw ex; } shader.LoadParameters(); return(shader); } // Load()
public static TWTexture FromImageFile(IXNAGame game, IGameFile imageFile, TextureCreationParameters parameters) { TWTexture tex = new TWTexture(); try { tex.xnaTexture = Texture2D.FromFile(game.GraphicsDevice, imageFile.GetFullFilename(), parameters); } catch { System.Diagnostics.Debug.WriteLine("Couldn't load texture at path '" + imageFile.GetFullFilename() + "' in TWTexture."); tex.xnaTexture = null; } return(tex); }
protected void LoadFromFXFile(IGameFile file, EffectPool pool) { //BasicShader shader = new BasicShader( game ); //obs? // Dispose old shader if (effect != null) { effect.Dispose(); effect = null; } CompiledEffect compiledEffect; try { compiledEffect = Effect.CompileEffectFromFile(file.GetFullFilename(), null, null, CompilerOptions.None, TargetPlatform.Windows); if (compiledEffect.Success == false) { Console.WriteLine("Shader compile error in BasicShader. Error message is as follows:\n" + compiledEffect.ErrorsAndWarnings); throw new Exception("Failed to compile shader. Error message is as follows:\n" + compiledEffect.ErrorsAndWarnings); } effect = new Effect(game.GraphicsDevice, compiledEffect.GetEffectCode(), CompilerOptions.None, pool); } // try catch (Exception ex) { /*Log.Write( "Failed to load shader " + shaderContentName + ". " + * "Error: " + ex.ToString() );*/ // Rethrow error, app can't continue! throw ex; } LoadParameters(); //return shader; } // Load()