title: opengl 3.3 z-fighting ortho 2d view
body: <p>I'm having some issues with z fighting while drawing simple 2d textured quads using opengl. The symptoms are both objects moving at the same speed and one on top of another but periodically one can see through the other and vice versa - sort of like a "flickering". I assume this is indeed z fighting.  </p>
  
  <p>I have turned off Depth Testing and have the following as well:</p>
  
  <pre><code>gl.Disable(gl.DEPTH_TEST)
  gl.DepthFunc(gl.LESS)
  gl.Enable(gl.BLEND)
  gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
  </code></pre>
  
  <p>My view and ortho matrices are as follows:</p>
  
  <p>I have tried to set the near and far distances much greater ( like range of 50000 but still no help)</p>
  
  <pre><code>Projection := mathgl.Ortho(0.0, float32(width), float32(height), 0.0, -5.0, 5.0)
  
  
  
  
  View := mathgl.LookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
  </code></pre>
  
  <p>The only difference with my opengl process is that instead of a drawelements call for each individual object, I package all vertices, uvs(sprite atlas), translation, rotation, etc in one big package sent to vertex shader.</p>
  
  <p>Does anyone have remedies for 2d z fighting?</p>
  
  <p>edit:</p>
  
  <p>i'm adding some pictures to further describe the scenario:</p>
  
  <p><a href="https://i.stack.imgur.com/Z22vB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z22vB.png" alt="img1"></a></p>
  
  <p><a href="https://i.stack.imgur.com/K6Uw4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K6Uw4.png" alt="img2"></a></p>
  
  <p>These images are taken a few seconds apart from each other. They are simply texture moving from left to right. As they move; you see from the image, that one sprite over-lapse the other and vice versa back and forth etc very fast.</p>
  
  <p>Also note that my images (sprites) are pngs that have a transparent background to them..</p>