PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/Graphics/Basics/RenderToTexture.cs

#
C# | 87 lines | 39 code | 6 blank | 42 comment | 0 complexity | eab2ff8da2cf0e733643b5d311765511 MD5 | raw file
Possible License(s): Apache-2.0
  1. using Delta.Engine.Dynamic;
  2. using Delta.Utilities.Datatypes;
  3. namespace Delta.Graphics.Basics
  4. {
  5. /// <summary>
  6. /// Render To Texture class for rendering into textures. This is needed
  7. /// mostly for shadow mapping and post screen shader techniques.
  8. /// <para />
  9. /// You can use this class to extend render to texture functionality for all
  10. /// platforms. If you just change OpenTKRenderToTexture, your game will not
  11. /// be able to use that changes on any other graphic platform.
  12. /// </summary>
  13. public abstract class RenderToTexture : BaseRenderToTexture
  14. {
  15. #region Create (Static)
  16. /// <summary>
  17. /// Create render to texture instance dynamically.
  18. /// </summary>
  19. /// <param name="setPixelSize">Pixel size of the target texture</param>
  20. /// <param name="setIsDepthTexture">Should this be a depth texture?</param>
  21. /// <param name="setIsShadowProjected">
  22. /// Should this be used for projected shadow map texture techniques?
  23. /// </param>
  24. /// <param name="setUseStencilBuffer">
  25. /// Use the stencil flag for this RenderToTexture instance?
  26. /// </param>
  27. /// <returns>Created RenderToTexture instance</returns>
  28. public static RenderToTexture Create(Size setPixelSize,
  29. bool setIsDepthTexture = false, bool setIsShadowProjected = false,
  30. bool setUseStencilBuffer = false)
  31. {
  32. // Here we construct a string that will be send as parameter on
  33. // RenderTexture implementation.
  34. RenderToTexture renderToTexture = Factory.Create<RenderToTexture>(
  35. new object[]
  36. {
  37. "RenderToTexture_" + (instanceNumber++),
  38. setPixelSize,
  39. setIsDepthTexture,
  40. setIsShadowProjected,
  41. setUseStencilBuffer
  42. });
  43. return renderToTexture;
  44. }
  45. #endregion
  46. #region Private
  47. #region instanceNumber (Private)
  48. /// <summary>
  49. /// Static integer value for generating unique name of every created
  50. /// RenderToTexure.
  51. /// </summary>
  52. private static int instanceNumber;
  53. #endregion
  54. #endregion
  55. #region Constructors
  56. /// <summary>
  57. /// Creates an instance of render to texture. Please note that calling
  58. /// Render will initialize this instance (with the
  59. /// MakeSureRenderTargetIsInitialized helper method), this constructor
  60. /// does nothing here yet.
  61. /// </summary>
  62. /// <param name="setTextureName">Name for the RenderToTexture</param>
  63. /// <param name="setPixelSize">Pixel size of the target texture</param>
  64. /// <param name="setIsDepthTexture">If set to <c>true</c> the texture
  65. /// target is a depth texture</param>
  66. /// <param name="setIsShadowProjected">If set to <c>true</c> the texture
  67. /// target is projected shadow texture to be used in shadow mapping.
  68. /// </param>
  69. /// <param name="setUseStencilBuffer">
  70. /// Use the stencil flag for this RenderToTexture instance?
  71. /// </param>
  72. public RenderToTexture(string setTextureName, Size setPixelSize,
  73. bool setIsDepthTexture, bool setIsShadowProjected,
  74. bool setUseStencilBuffer)
  75. : base(setTextureName, setPixelSize, setIsDepthTexture,
  76. setIsShadowProjected, setUseStencilBuffer)
  77. {
  78. }
  79. #endregion
  80. }
  81. }