title: SpriteBatch with DrawIndexedPrimitives
body: <p>This is my first 3D application that I have created so sorry if this seems like such a simple question but I have searched the internet and these forums to try and find an answer. </p>
  
  <p>I am attempting to draw a simple string to the screen using the spriteBatch.DrawString command.</p>
  
  <p>The application is similar to Minecraft with a large quantity of cubes on the screen. To sort out lag issues all the cubes are created via vertices and hardware instancing has been implemented. </p>
  
  <p>The issue is when ever I call spriteBatch.Begin() all the other cubes appear differently. I am aware that spritebatch changes some states so the following lines have been added </p>
  
  <pre><code>GraphicsDevice.BlendState = BlendState.Opaque;
  GraphicsDevice.DepthStencilState = DepthStencilState.Default;
  </code></pre>
  
  <p>Bellow is the code used to draw the player</p>
  
  <pre><code>public void Draw(Matrix view, Matrix projection)
      {
          effect.CurrentTechnique = effect.Techniques["TexturedNoShading"];
          effect.Parameters["xView"].SetValue(view);
          effect.Parameters["xProjection"].SetValue(projection);
          effect.Parameters["xWorld"].SetValue(world);
          effect.Parameters["xTexture"].SetValue(texture);
  
          device.SetVertexBuffer(myVertexBuffer);
          foreach (EffectPass pass in effect.CurrentTechnique.Passes)
          {
              pass.Apply();
              device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertices.Length, 0, indices.Length / 3);
          }
      }
  </code></pre>
  
  <p>This is the code used in the main class to draw everything</p>
  
  <pre><code>        RasterizerState rs = new RasterizerState();  
          rs.CullMode = CullMode.None;
          rs.FillMode = FillMode.Solid;
          device.RasterizerState = rs;
  
          GraphicsDevice.BlendState = BlendState.Opaque;
          GraphicsDevice.DepthStencilState = DepthStencilState.Default;
          _map.Draw(_camera.GetCamera(), projection);
          _player.Draw(_camera.GetCamera(), projection);
  
  
          spriteBatch.Begin();
          spriteBatch.DrawString(Text, "test", new Vector2(100, 100), Color.White);
          spriteBatch.End();
  </code></pre>
  
  <p>I would like to post screenshots of the problem to show it more clearly but as this is my first post I do not have the rights to post images. I'm happy to email the images to people. </p>
  
  <p>I'm happy to include any other information but it seems like such a simple problem.</p>
  
  <p>Thanks for any help that you may be able to provide.</p>
  
  <p>Sam Vickery</p>