anchor.diff:               "#define VERTS 6"
                "uniform mat4 viewProjection;"
                "uniform vec2 positions[" + string Constants.Render.SpriteBatchSize + " * VERTS];"
  -             "uniform vec2 texCoordses[" + string Constants.Render.SpriteBatchSize + " * VERTS];"
  +             "uniform vec4 texCoordses[" + string Constants.Render.SpriteBatchSize + "];"
                "uniform vec4 colors[" + string Constants.Render.SpriteBatchSize + "];"
                "out vec2 texCoords;"
                "out vec4 color;"
                "void main()"
                "{"
                "  int spriteId = gl_VertexID / VERTS;"
  +             "  int vertexId = gl_VertexID % VERTS;"
                "  vec2 position = positions[gl_VertexID];"
                "  gl_Position = viewProjection * vec4(position.x, position.y, 0, 1);"
  -             "  texCoords = texCoordses[gl_VertexID];"
  +             "  vec4 texCoords4 = texCoordses[spriteId];"
  +             "  switch (vertexId)"
  +             "  {"
  +             "      case 0: case 4: texCoords = vec2(texCoords4.x, texCoords4.y); break;"
  +             "      case 1:         texCoords = vec2(texCoords4.x + texCoords4.z, texCoords4.y); break;"
  +             "      case 2: case 5: texCoords = vec2(texCoords4.x + texCoords4.z, texCoords4.y + texCoords4.w); break;"
  +             "      case 3:         texCoords = vec2(texCoords4.x, texCoords4.y + texCoords4.w); break;"
  +             "  }"
                "  color = colors[spriteId];"
                "}"] |> String.join "\n"
   
  
positive.code:         OpenGL.Hl.Assert (fn ())
          BeginBatch state env
  
      let inline private PopulateVertex vertexId (position : Vector2) (texCoords : Vector2) (color : Color) env =
          let positionOffset = env.SpriteIndex * 6 * 2 + vertexId * 2
          env.Positions.[positionOffset] <- position.X
          env.Positions.[positionOffset + 1] <- position.Y
          let texCoordsOffset = positionOffset
          env.TexCoordses.[texCoordsOffset] <- texCoords.X
          env.TexCoordses.[texCoordsOffset + 1] <- texCoords.Y
          if positionOffset % (6 * 2) = 0 then
              let colorOffset = env.SpriteIndex * 4
              env.Colors.[colorOffset] <- color.R
              env.Colors.[colorOffset + 1] <- color.G
              env.Colors.[colorOffset + 2] <- color.B
              env.Colors.[colorOffset + 3] <- color.A
  
      let SubmitSprite (absolute, position : Vector2, size : Vector2, pivot : Vector2, rotation, texCoords : Box2, color : Color, flip, bfs, bfd, beq, texture, env) =
  
  
negative.code:         // compute vertex positions
          let center = position + pivot
          let position0 = (position - center).Rotate rotation + center
          let position1Unrotated = v2 (position.X + size.X) position.Y
          let position1 = (position1Unrotated - center).Rotate rotation + center
          let position2Unrotated = v2 (position.X + size.X) (position.Y + size.Y)
          let position2 = (position2Unrotated - center).Rotate rotation + center
          let position3Unrotated = v2 position.X (position.Y + size.Y)
          let position3 = (position3Unrotated - center).Rotate rotation + center
  
          // populate vertices
          PopulatePosition 0 position0 env
          PopulatePosition 1 position1 env
          PopulatePosition 2 position2 env
          PopulatePosition 3 position3 env
          PopulatePosition 4 position0 env
          PopulatePosition 5 position2 env
          PopulateVertex texCoords color env
  
          // advance sprite index
          env.SpriteIndex <- inc env.SpriteIndex
  