/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
- using Delta.Engine.Dynamic;
- using Delta.Utilities.Datatypes;
-
- namespace Delta.Graphics.Basics
- {
- /// <summary>
- /// Render To Texture class for rendering into textures. This is needed
- /// mostly for shadow mapping and post screen shader techniques.
- /// <para />
- /// You can use this class to extend render to texture functionality for all
- /// platforms. If you just change OpenTKRenderToTexture, your game will not
- /// be able to use that changes on any other graphic platform.
- /// </summary>
- public abstract class RenderToTexture : BaseRenderToTexture
- {
- #region Create (Static)
- /// <summary>
- /// Create render to texture instance dynamically.
- /// </summary>
- /// <param name="setPixelSize">Pixel size of the target texture</param>
- /// <param name="setIsDepthTexture">Should this be a depth texture?</param>
- /// <param name="setIsShadowProjected">
- /// Should this be used for projected shadow map texture techniques?
- /// </param>
- /// <param name="setUseStencilBuffer">
- /// Use the stencil flag for this RenderToTexture instance?
- /// </param>
- /// <returns>Created RenderToTexture instance</returns>
- public static RenderToTexture Create(Size setPixelSize,
- bool setIsDepthTexture = false, bool setIsShadowProjected = false,
- bool setUseStencilBuffer = false)
- {
- // Here we construct a string that will be send as parameter on
- // RenderTexture implementation.
- RenderToTexture renderToTexture = Factory.Create<RenderToTexture>(
- new object[]
- {
- "RenderToTexture_" + (instanceNumber++),
- setPixelSize,
- setIsDepthTexture,
- setIsShadowProjected,
- setUseStencilBuffer
- });
-
- return renderToTexture;
- }
- #endregion
-
- #region Private
-
- #region instanceNumber (Private)
- /// <summary>
- /// Static integer value for generating unique name of every created
- /// RenderToTexure.
- /// </summary>
- private static int instanceNumber;
- #endregion
-
- #endregion
-
- #region Constructors
- /// <summary>
- /// Creates an instance of render to texture. Please note that calling
- /// Render will initialize this instance (with the
- /// MakeSureRenderTargetIsInitialized helper method), this constructor
- /// does nothing here yet.
- /// </summary>
- /// <param name="setTextureName">Name for the RenderToTexture</param>
- /// <param name="setPixelSize">Pixel size of the target texture</param>
- /// <param name="setIsDepthTexture">If set to <c>true</c> the texture
- /// target is a depth texture</param>
- /// <param name="setIsShadowProjected">If set to <c>true</c> the texture
- /// target is projected shadow texture to be used in shadow mapping.
- /// </param>
- /// <param name="setUseStencilBuffer">
- /// Use the stencil flag for this RenderToTexture instance?
- /// </param>
- public RenderToTexture(string setTextureName, Size setPixelSize,
- bool setIsDepthTexture, bool setIsShadowProjected,
- bool setUseStencilBuffer)
- : base(setTextureName, setPixelSize, setIsDepthTexture,
- setIsShadowProjected, setUseStencilBuffer)
- {
- }
- #endregion
- }
- }