title: Tiling + OpenGL texture flipping
body: <p>I am trying to convert tiling rendering from SDL2 to OpenGL. Here is the image from SDL2;</p>
  
  <p><img src="https://imgur.com/TnFTVNU.png" alt="SDL2 rendering"></p>
  
  <p>And the same image rendered using OpenGL without texture flipped in Y-axis;</p>
  
  <p><img src="https://imgur.com/vFqF5Hb.png" alt="OpenGL with no texture flipping"></p>
  
  <p>And here is the image from OpenGL rendering with texture flipped in Y-axis;</p>
  
  <p><img src="https://imgur.com/2zL1vAF.png" alt="OpenGL with texture flipped"></p>
  
  <p>Where should I compensate the coordinates with a Y-flipped texture and to get it rendered properly in the OpenGL coordinate system? Here is the code I used to get the texture uv's to render the second picture(texture not flipped) and third picture(flipped texture) in OpenGL;</p>
  
  <pre><code>glm::vec4 srcRect;
  srcRect.x = (float)((tileLayer-&gt;GetTileId(x, y) - (tileY * tilesPerRow))* (tileWidth+ spacing) )/imageWidth;
  srcRect.y = (float)(tileY * (tileHeight + spacing)+ margin)/imageHeight;
  srcRect.z = (float)tileWidth/imageWidth;
  srcRect.w = (float)tileHeight/imageHeight ;
  </code></pre>