PageRenderTime 676ms CodeModel.GetById 534ms app.highlight 3ms RepoModel.GetById 138ms app.codeStats 0ms

/Graphics/Basics/RenderToTexture.cs

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