BloomCombineEffect.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.IO;
  3. using System.Text;
  4. using Microsoft.Xna.Framework.Graphics;
  5. using Microsoft.Xna.Framework;
  6. #if !LINUX
  7. using MonoMac.Foundation;
  8. using MonoMac.AppKit;
  9. #endif
  10. namespace NetRumble
  11. {
  12. public class BloomCombineEffect : Effect
  13. {
  14. public BloomCombineEffect (GraphicsDevice graphicsDevice) : base (graphicsDevice)
  15. {
  16. // We do not need this but here for test
  17. LoadShaderFromFile ("BloomPostprocess/Effects/BloomCombine.fsh");
  18. DefineTechnique ("BloomCombine", "Pass1", 0, 0);
  19. CurrentTechnique = Techniques ["BloomCombine"];
  20. }
  21. protected void LoadShaderFromFile (string sourceFile)
  22. {
  23. string path;
  24. #if !LINUX
  25. path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Content");
  26. #else
  27. path = "Content";
  28. #endif
  29. // Load the source into a string
  30. string shaderSource = LoadShaderSource (sourceFile);
  31. CreateFragmentShaderFromSource (shaderSource);
  32. }
  33. // Load the source code of a GLSL program from the content
  34. private string LoadShaderSource (string name)
  35. {
  36. StreamReader streamReader = new StreamReader (name);
  37. string text = streamReader.ReadToEnd ();
  38. streamReader.Close ();
  39. return text;
  40. }
  41. }
  42. }