title: OpenGL texture offset issue
body: <p>I'm running into an issue with a texture's rows being offset.  As a test I'm creating a 512x4 texture from/to GL_RGBA.  sizeof(_color) outputs 4.  It should just be a gradient that goes from black to blue on the X.  It looks like it's being read from an offset, as sometimes it ends with corrupted results that last about 1/3rd of a row (width). </p>
  
  <p>If I change the fragment shader to output UV coordinates on the red and green channels, I get UV coordinates that look like they're properly set, such as 0,0 (TL)  1,0 (TR),  0,1 (BL) and 1,1 (BR).  I can't see this being a UV issue anyway.</p>
  
  <p>I'm using SDL2 on OSX, which may be the source of the issue.  The result is good on Linux/SDL2, so I'm utterly clueless as to what state variable could possibly cause this.</p>
  
  <p><img src="https://i.stack.imgur.com/sgAPF.png" alt="OpenGL texture offset"></p>
  
  <pre><code>typedef struct {
      unsigned char r,g,b,a;
  } _color;
  
  glGenTextures(1, &amp;self-&gt;id);
  glBindTexture(GL_TEXTURE_2D, self-&gt;id);
  
  _color* c = (_color*)malloc(sizeof(_color) * 512 * 4);
  _color* pc = c;
  for( int y = 0; y &lt; 4; y++ )
      for( int x = 0; x &lt; 512; x++ ) {
          pc-&gt;r = 0;
          pc-&gt;g = 0;
          pc-&gt;b = (u_char)((float)x / (float)512 * 255.0);
          pc-&gt;a = 255;
          pc++;
      }
  
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 512, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, (void *)c);
  
  printf("glGetError = %d\n", glGetError()); // Outputs no error
  
  free(c);
  </code></pre>
  
  <p>UV mapped to gl_FragColor (red = U, green = V)
  <img src="https://i.stack.imgur.com/eO3IK.png" alt="UV output"></p>
  
  <p>Texture lookup changed to: texture2D(u_texture, vec2(v_uv.x, 0.0)); (y forced to 0)
  <img src="https://i.stack.imgur.com/xCsEh.png" alt="V (or UV.y) coordinate set to 0"></p>