Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
VertexPosition2.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.Runtime.InteropServices;
5 
6 using SiliconStudio.Core.Mathematics;
7 
8 namespace SiliconStudio.Paradox.Graphics
9 {
10  /// <summary>
11  /// Describes a custom vertex format structure that contains position as a Vector2.
12  /// </summary>
13  [StructLayout(LayoutKind.Sequential)]
14  public struct VertexPosition2 : IEquatable<VertexPosition2>
15  {
16  /// <summary>
17  /// Initializes a new <see cref="VertexPositionTexture"/> instance.
18  /// </summary>
19  /// <param name="position">The position of this vertex.</param>
20  public VertexPosition2(Vector2 position)
21  : this()
22  {
23  Position = position;
24  }
25 
26  /// <summary>
27  /// XY position.
28  /// </summary>
29  public Vector2 Position;
30 
31  /// <summary>
32  /// Defines structure byte size.
33  /// </summary>
34  public static readonly int Size = 8;
35 
36  /// <summary>
37  /// The vertex layout of this struct.
38  /// </summary>
39  public static readonly VertexDeclaration Layout = new VertexDeclaration(VertexElement.Position<Vector2>());
40 
41  public bool Equals(VertexPosition2 other)
42  {
43  return Position.Equals(other.Position);
44  }
45 
46  public override bool Equals(object obj)
47  {
48  if (ReferenceEquals(null, obj)) return false;
49  return obj is VertexPosition2 && Equals((VertexPosition2)obj);
50  }
51 
52  public override int GetHashCode()
53  {
54  unchecked
55  {
56  return Position.GetHashCode();
57  }
58  }
59 
60  public static bool operator ==(VertexPosition2 left, VertexPosition2 right)
61  {
62  return left.Equals(right);
63  }
64 
65  public static bool operator !=(VertexPosition2 left, VertexPosition2 right)
66  {
67  return !left.Equals(right);
68  }
69 
70  public override string ToString()
71  {
72  return string.Format("Position: {0}", Position);
73  }
74  }
75 }
The layout of a vertex buffer with a set of VertexElement.
Represents a two dimensional mathematical vector.
Definition: Vector2.cs:42
Describes a custom vertex format structure that contains position as a Vector2.
static VertexElement Position(PixelFormat format, int offsetInBytes=AppendAligned)
Declares a VertexElement with the semantic "POSITION".
VertexPosition2(Vector2 position)
Initializes a new VertexPositionTexture instance.
A description of a single element for the input-assembler stage. This structure is related to Direct3...