title: DirectX11 texture coordinates and vertices
body: <p>I am new to StackOverflow.</p>
  
  <p>I am studying DirectX11 from the book Beginning Directx11 and I am a complete beginner but I do have knowledge of C++. I have come across texture coordinates and how they are used but I don't understand the snippet of code that is used to specify the vertices. Below is the code:</p>
  
  <pre><code>// the structure used to store the vertices
  struct VertexPos
  {
      XMFLOAT3 pos;
      XMFLOAT2 tex0;
  };
  
  // some code before reaching this point
  ...
  VertexPos vertices[] =
  {
      { XMFLOAT3(  1.0f,  1.0f, 1.0f ), XMFLOAT2( 1.0f, 1.0f ) },
      { XMFLOAT3(  1.0f, -1.0f, 1.0f ), XMFLOAT2( 1.0f, 0.0f ) },
      { XMFLOAT3( -1.0f, -1.0f, 1.0f ), XMFLOAT2( 0.0f, 0.0f ) },
  
      { XMFLOAT3( -1.0f, -1.0f, 1.0f ), XMFLOAT2( 0.0f, 0.0f ) },
      { XMFLOAT3( -1.0f,  1.0f, 1.0f ), XMFLOAT2( 0.0f, 1.0f ) },
      { XMFLOAT3(  1.0f,  1.0f, 1.0f ), XMFLOAT2( 1.0f, 1.0f ) },
  };
  ...
  
  // shader file
  Texture2D colorMap_ : register( t0 );
  SamplerState colorSampler_ : register( s0 );
  
  
  struct VS_Input
  {
      float4 pos  : POSITION;
      float2 tex0 : TEXCOORD0;
  };
  
  struct PS_Input
  {
      float4 pos  : SV_POSITION;
      float2 tex0 : TEXCOORD0;
  };
  
  
  PS_Input VS_Main( VS_Input vertex )
  {
      PS_Input vsOut = ( PS_Input )0;
      vsOut.pos = vertex.pos;
      vsOut.tex0 = vertex.tex0;
  
      return vsOut;
  }
  </code></pre>
  
  <p>I don't understand why there are 6 positions specified. If it is to make a rectangle, is it not possible to specify 4 values and make a rectangle from two triangles? This loads a texture image and displays it, I would like to know how the vertices work (if possible with a drawing specifying the position of each vertex).</p>