DisappearEffect.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System;
  2. using System.IO;
  3. using System.Text;
  4. using Microsoft.Xna.Framework.Graphics;
  5. using Microsoft.Xna.Framework;
  6. using MonoMac.Foundation;
  7. using MonoMac.AppKit;
  8. namespace SpriteEffects
  9. {
  10. public class DisappearEffect : Effect
  11. {
  12. public DisappearEffect (GraphicsDevice graphicsDevice) : base (graphicsDevice)
  13. {
  14. // We do not need this but here for test
  15. // CreateVertexShaderFromSource("void main(void) { " +
  16. // "gl_FrontColor = gl_Color; " +
  17. // "gl_TexCoord[0] = gl_MultiTexCoord0;" +
  18. // "gl_TexCoord[1] = gl_MultiTexCoord1;" +
  19. // "gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;" +
  20. // "}");
  21. LoadShaderFromFile ("disappear.fsh");
  22. DefineTechnique ("Disappear", "Pass1", 0, 0);
  23. CurrentTechnique = Techniques ["Disappear"];
  24. }
  25. protected void LoadShaderFromFile (string sourceFile)
  26. {
  27. var path = Path.Combine (NSBundle.MainBundle.ResourcePath, "Content");
  28. sourceFile = Path.Combine (path, sourceFile);
  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. //void main(void){
  42. // gl_TexCoord[0] = gl_MultiTexCoord0;
  43. // gl_TexCoord[1] = gl_MultiTexCoord1;
  44. // gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  45. //}
  46. //
  47. //uniform sampler2D keke;
  48. //uniform sampler2D smee;
  49. //
  50. //void main (void){
  51. //vec2 src = vec2(gl_TexCoord[0]);
  52. //vec4 dest = texture2D(keke, src);
  53. //vec2 src2 = vec2(gl_TexCoord[1]);
  54. //vec4 dest2 = texture2D(smee, src2);
  55. //gl_FragColor = 0.5 * (dest + dest2);
  56. //}
  57. //
  58. //ARBShaderObjects.glUseProgramObjectARB(shader.getProgramID());
  59. //int location = shader.getUniformLocation(shader.getProgramID(), "keke");
  60. //int location2 = shader.getUniformLocation(shader.getProgramID(), "smee");
  61. //ARBMultitexture.glActiveTextureARB(ARBMultitexture.GL_TEXTURE0_ARB);
  62. //GL11.glBindTexture(GL11.GL_TEXTURE_2D, TestEngine.cID);
  63. //GL11.glEnable(GL11.GL_TEXTURE_2D);
  64. //ARBShaderObjects.glUniform1iARB(location, 0);
  65. //ARBMultitexture.glActiveTextureARB(ARBMultitexture.GL_TEXTURE1_ARB);
  66. //GL11.glBindTexture(GL11.GL_TEXTURE_2D, sprite.getTextureID());
  67. //GL11.glEnable(GL11.GL_TEXTURE_2D);
  68. //ARBShaderObjects.glUniform1iARB(location2, 1);
  69. //EngineFunc.translate(origin.x, origin.y);
  70. //EngineFunc.drawQuads(sprite.getPoints());
  71. //ARBShaderObjects.glUseProgramObjectARB(0);
  72. //ARBMultitexture.glActiveTextureARB(ARBMultitexture.GL_TEXTURE1_ARB);
  73. //GL11.glDisable(GL11.GL_TEXTURE_2D);
  74. //ARBMultitexture.glActiveTextureARB(ARBMultitexture.GL_TEXTURE0_ARB);
  75. //GL11.glDisable(GL11.GL_TEXTURE_2D);
  76. }
  77. }