Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
TextureType.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 using System;
4 using System.Globalization;
5 using System.Linq;
6 
7 using Irony.Parsing;
8 
9 namespace SiliconStudio.Shaders.Ast.Hlsl
10 {
11  /// <summary>
12  /// A State type.
13  /// </summary>
14  public class TextureType : ObjectType
15  {
16  #region Constants and Fields
17 
18  /// <summary>
19  /// A Texture
20  /// </summary>
21  public static readonly TextureType Texture = new TextureType("texture");
22 
23  /// <summary>
24  /// A Texture1D.
25  /// </summary>
26  public static readonly TextureType Texture1D = new TextureType("Texture1D", "texture1D");
27 
28  /// <summary>
29  /// A Texture1DArray.
30  /// </summary>
31  public static readonly TextureType Texture1DArray = new TextureType("Texture1DArray", "texture1DArray");
32 
33  /// <summary>
34  /// A Texture2D
35  /// </summary>
36  public static readonly TextureType Texture2D = new TextureType("Texture2D", "texture2D");
37 
38  /// <summary>
39  /// A Texture2DArray.
40  /// </summary>
41  public static readonly TextureType Texture2DArray = new TextureType("Texture2DArray", "texture2DArray");
42 
43  /// <summary>
44  /// A Texture3D.
45  /// </summary>
46  public static readonly TextureType Texture3D = new TextureType("Texture3D", "texture3D");
47 
48  /// <summary>
49  /// An TextureCube.
50  /// </summary>
51  public static readonly TextureType TextureCube = new TextureType("TextureCube", "textureCube");
52 
53  private static readonly TextureType[] TextureTypes = new[] { Texture, Texture1D, Texture1DArray, Texture2D, Texture2DArray, Texture3D, TextureCube };
54 
55  #endregion
56 
57  /// <summary>
58  /// Initializes a new instance of the <see cref="TextureType"/> class.
59  /// </summary>
60  public TextureType()
61  {
62  IsBuiltIn = true;
63  }
64 
65  /// <summary>
66  /// Initializes a new instance of the <see cref="TextureType"/> class.
67  /// </summary>
68  /// <param name="name">
69  /// The name.
70  /// </param>
71  public TextureType(string name, params string[] altNames)
72  : base(name, altNames)
73  {
74  IsBuiltIn = true;
75  }
76 
77  /// <inheritdoc/>
78  public bool Equals(TextureType other)
79  {
80  return base.Equals(other);
81  }
82 
83  /// <inheritdoc/>
84  public override bool Equals(object obj)
85  {
86  if (ReferenceEquals(null, obj))
87  {
88  return false;
89  }
90  if (ReferenceEquals(this, obj))
91  {
92  return true;
93  }
94  return Equals(obj as TextureType);
95  }
96 
97  /// <inheritdoc/>
98  public override int GetHashCode()
99  {
100  return base.GetHashCode();
101  }
102 
103  /// <summary>
104  /// Implements the operator ==.
105  /// </summary>
106  /// <param name="left">The left.</param>
107  /// <param name="right">The right.</param>
108  /// <returns>
109  /// The result of the operator.
110  /// </returns>
111  public static bool operator ==(TextureType left, TextureType right)
112  {
113  return Equals(left, right);
114  }
115 
116  /// <summary>
117  /// Implements the operator !=.
118  /// </summary>
119  /// <param name="left">The left.</param>
120  /// <param name="right">The right.</param>
121  /// <returns>
122  /// The result of the operator.
123  /// </returns>
124  public static bool operator !=(TextureType left, TextureType right)
125  {
126  return !Equals(left, right);
127  }
128 
129  /// <summary>
130  /// Parses the specified name.
131  /// </summary>
132  /// <param name="name">The name.</param>
133  /// <returns></returns>
134  public static TextureType Parse(string name)
135  {
136  return TextureTypes.FirstOrDefault(textureType => string.Compare(name, textureType.Name.Text, true, CultureInfo.InvariantCulture) == 0);
137  }
138  }
139 }
static TextureType Parse(string name)
Parses the specified name.
Definition: TextureType.cs:134
override bool Equals(object obj)
Definition: TextureType.cs:84
TextureType()
Initializes a new instance of the TextureType class.
Definition: TextureType.cs:60
TextureType(string name, params string[] altNames)
Initializes a new instance of the TextureType class.
Definition: TextureType.cs:71