title: glGetTextureSubImage INVALID OPERATION
body: <p>I'm unable to make <strong>glGetTextureSubImage</strong> work. On the other hand, <strong>glGetTextureImage</strong> works fine for me.</p>
  
  <p>Test code:</p>
  
  <pre><code>const unsigned int sizeX=16;
  const unsigned int sizeY=16;
  
  // Init texture.
  unsigned int texId;
  glCreateTextures (GL_TEXTURE_2D, 1, &amp;texId);
  if (texId == 0)
      return false;
  
  glTextureStorage2D (texId, 1, GL_RGBA8, sizeX, sizeY);
  CheckGlError ("glTextureStorage Error: ");       // OK
  
  // Create simple image.
  unsigned int bufSize = sizeX * sizeY * 4;
  unsigned char *buffer = new unsigned char [bufSize];
      // fill buffer with anything...
  
  // Upload image to texture.
  glTextureSubImage2D (texId, 0,  0,0,  sizeX,sizeY,  GL_RGBA, GL_UNSIGNED_BYTE,  buffer);
  CheckGlError ("glTextureSubImage Error: ");      // OK
  
  // Test downloads.
  glGetTextureImage (texId, 0,  GL_RGBA, GL_UNSIGNED_BYTE,  bufSize, buffer);
  CheckGlError ("glGetTextureImage Error: ");      // OK
  
  glGetTextureSubImage (texId, 0,  0,0,0,  sizeX,sizeY,0,  GL_RGBA, GL_UNSIGNED_BYTE,  bufSize, buffer);
  CheckGlError ("glGetTextureSubImage Error: ");   // 0x502 (INVALID OPERATION)
  </code></pre>
  
  <p>I have tried all kinds of alternatives and always gives the same error, even to download a single pixel. Also tried typical solutions like GL_UNPACK_ALIGNMENT=1 or all the glTextureParameters that I have come up with, quite desperate.</p>