PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/Utilities/Graphics/ShaderFeatures/BasicShaderFeature.cs

#
C# | 100 lines | 59 code | 8 blank | 33 comment | 0 complexity | 9db2b7d279fe2f5200fb86cf342316bc MD5 | raw file
Possible License(s): Apache-2.0
  1. using System.Collections.Generic;
  2. using System.IO;
  3. namespace Delta.Utilities.Graphics.ShaderFeatures
  4. {
  5. /// <summary>
  6. /// Basic shader feature
  7. /// </summary>
  8. public class BasicShaderFeature : IShaderFeature
  9. {
  10. #region DiffuseMap (Public)
  11. /// <summary>
  12. /// Diffuse map, is always set except when ShaderFeatureFlags.NoTexturing
  13. /// is set (then we don't want a diffuse map and this setting is ignored).
  14. /// </summary>
  15. public string DiffuseMap = "";
  16. #endregion
  17. #region ShaderFeature (Public)
  18. /// <summary>
  19. /// Which shader feature flag is this ShaderFeature class using?
  20. /// Important for loading this file via ShaderData.LoadShaderFeature.
  21. /// Each flag should obviously only have one class for it!
  22. /// </summary>
  23. public ShaderFeatureFlags ShaderFeature
  24. {
  25. get
  26. {
  27. return ShaderFeatureFlags.Basic;
  28. }
  29. }
  30. #endregion
  31. #region RequiredShaderFeatures (Public)
  32. /// <summary>
  33. /// Which shader feature flags are required for this ShaderFeature.
  34. /// Very important for creating of a new ShaderFeature.
  35. /// </summary>
  36. public ShaderFeatureFlags RequiredShaderFeatures
  37. {
  38. get
  39. {
  40. return ShaderFeatureFlags.Basic;
  41. }
  42. }
  43. #endregion
  44. #region Parameters (Public)
  45. /// <summary>
  46. /// Parameters as a dictionary, will be generated on the fly when
  47. /// requested.
  48. /// </summary>
  49. public Dictionary<string, object> Parameters
  50. {
  51. get
  52. {
  53. Dictionary<string, object> ret = new Dictionary<string, object>();
  54. ret.Add("DiffuseMap", DiffuseMap);
  55. return ret;
  56. }
  57. }
  58. #endregion
  59. #region Constructors
  60. /// <summary>
  61. /// Create basic shader feature
  62. /// </summary>
  63. public BasicShaderFeature()
  64. {
  65. }
  66. /// <summary>
  67. /// Create basic shader feature and load automatically
  68. /// the ShaderFeatures from a binary data stream.
  69. /// </summary>
  70. public BasicShaderFeature(BinaryReader reader)
  71. {
  72. Load(reader);
  73. }
  74. #endregion
  75. #region ISaveLoadBinary Members
  76. /// <summary>
  77. /// Load this ShaderFeature from a binary data stream.
  78. /// </summary>
  79. public void Load(BinaryReader reader)
  80. {
  81. DiffuseMap = reader.ReadString();
  82. }
  83. /// <summary>
  84. /// Save this ShaderFeature to a binary data stream.
  85. /// </summary>
  86. public void Save(BinaryWriter writer)
  87. {
  88. writer.Write(DiffuseMap);
  89. }
  90. #endregion
  91. }
  92. }