Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
TexturingKeys.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 
4 using System;
5 
6 using SiliconStudio.Core.Mathematics;
7 using SiliconStudio.Paradox.Graphics;
8 
9 namespace SiliconStudio.Paradox.Effects.Modules
10 {
11  public partial class TexturingKeys
12  {
13  static TexturingKeys()
14  {
15  Texture0TexelSize = CreateDynamicTexelSizeParameterKey(Texture0);
16  Texture1TexelSize = CreateDynamicTexelSizeParameterKey(Texture1);
17  Texture2TexelSize = CreateDynamicTexelSizeParameterKey(Texture2);
18  Texture3TexelSize = CreateDynamicTexelSizeParameterKey(Texture3);
19  Texture4TexelSize = CreateDynamicTexelSizeParameterKey(Texture4);
20  Texture5TexelSize = CreateDynamicTexelSizeParameterKey(Texture5);
21  Texture6TexelSize = CreateDynamicTexelSizeParameterKey(Texture6);
22  Texture7TexelSize = CreateDynamicTexelSizeParameterKey(Texture7);
23  Texture8TexelSize = CreateDynamicTexelSizeParameterKey(Texture8);
24  Texture9TexelSize = CreateDynamicTexelSizeParameterKey(Texture9);
25  }
26 
27  /// <summary>
28  /// Creates a dynamic parameter key for texel size updated from the texture size.
29  /// </summary>
30  /// <param name="textureKey">Key of the texture to take the size from</param>
31  /// <returns>A dynamic TexelSize parameter key updated according to the specified texture</returns>
33  {
34  if (textureKey == null) throw new ArgumentNullException("textureKey");
35  return ParameterKeys.NewDynamic(ParameterDynamicValue.New<Vector2, Texture>(textureKey, UpdateTexelSize));
36  }
37 
38  /// <summary>
39  /// Updates the size of the texel from a texture.
40  /// </summary>
41  /// <param name="param1">The param1.</param>
42  /// <param name="output">The output.</param>
43  private static void UpdateTexelSize(ref Texture param1, ref Vector2 output)
44  {
45  output = (param1 != null) ? new Vector2(param1.Width, param1.Height) : Vector2.Zero;
46  }
47  }
48 }
Key of an effect parameter.
Definition: ParameterKey.cs:15
SiliconStudio.Paradox.Games.Mathematics.Vector2 Vector2
static ParameterKey< Vector2 > CreateDynamicTexelSizeParameterKey(ParameterKey< Texture > textureKey)
Creates a dynamic parameter key for texel size updated from the texture size.
Represents a two dimensional mathematical vector.
Definition: Vector2.cs:42
Base class for texture resources.
Definition: Texture.cs:38