title: OpenGL cubemap face order & sampling issue
body: <p>I have a renderer based on SDL2 and OpenGL (3.3 core profile), which gives me expected results with regards to transformations and texture(2D)ing.</p>
  <p>However, when I'm trying to display a skybox using a cubemap created from <a href="http://www.humus.name/Textures/Lycksele.zip" rel="nofollow noreferrer">these textures</a> (though I've tried others too), there are two steps in the process that no other tutorial or example that I have encountered seems to have to do, and I cannot explain:</p>
  <p>1, The top / bottom faces have to be swapped upon uploading, i.e.: the top one is uploaded as <code>GL_TEXTURE_CUBEMAP_NEGATIVE_Y</code>, and the bottom one is <code>GL_TEXTURE_CUBEMAP_POSITIVE_Y</code>;
  2, When sampling the cube map, I have to invert vertex positions along y, but <em>also</em> along z;</p>
  <p>Without this, I'm getting the following result:</p>
  <p><a href="https://i.stack.imgur.com/lUwGO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lUwGO.png" alt="enter image description here" /></a></p>
  <p>(N.B. the left-bottom-far vertex was scaled by .8 to clarify that my coordinate system is the right way around)</p>
  <p>The image files are named correctly.</p>
  <p>The cube is the only draw I'm performing.</p>
  <p>If I remove [the indices for] any of the sides, I get the expected results (i.e. no swapping / mirroring there).</p>
  <p>I seem to be getting the same results with my integrated and dedicated GPUs.</p>
  <p>My OpenGL constants, from a <a href="https://github.com/zyndor/glloadgen/" rel="nofollow noreferrer">glLoadGen</a> (<a href="https://bitbucket.org/alfonse/glloadgen/wiki/Home" rel="nofollow noreferrer">originally</a>) generated header:</p>
  <pre><code>#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
  #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
  #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
  #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
  #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
  #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
  </code></pre>
  <p>The texture uploading code (much the same as <a href="https://learnopengl.com/Advanced-OpenGL/Cubemaps" rel="nofollow noreferrer">LearnOpenGL's tutorial</a>):</p>
  <pre><code>GLuint name;
  glGenTextures(1, &amp;name);
  glBindTexture(GL_TEXTURE_CUBE_MAP, name);
  
  glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
  
  glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
  glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
  
  GLint target = GL_TEXTURE_CUBE_MAP_POSITIVE_X;
  for (uint8_t i = 0; i &lt; 6; ++i)
  {
    glTexImage2D(target + i, 0, GL_RGB8, width, height, 0, GL_RGB,
      GL_UNSIGNED_BYTE, pixelData[i]));
  }
  </code></pre>
  <p>Vertex shader:</p>
  <pre><code>#version 330
  
  precision mediump float;
  uniform mat4 uModelViewProjection;
  in vec3 aPosition;
  out vec3 vTexCoord;
  
  void main()
  {
    vec4 position = uModelViewProjection * vec4(aPosition, 1.f);
    gl_Position = position.xyww;
    
    vTexCoord = aPosition;
  }
  </code></pre>
  <p>Fragment shader:</p>
  <pre><code>#version 330
  
  precision mediump float;
  uniform samplerCube uTexture0;
  in vec3 vTexCoord;
  out vec4 FragColor;
  
  void main()
  {
    FragColor = texture(uTexture0, vTexCoord);
    // using textureCube() yields a compile error asking for #extension  GL_NV_shadow_samplers_cube : enable, but even with that, the issue perists.
  }
  </code></pre>
  <p>Mesh setup (semi-pseudo-code):</p>
  <pre><code>//    4----5
  //   /|   /|
  //  6----7 |
  //  | |  | |
  //  | 0--|-1
  //  |/   |/
  //  2----3
  VertexType vertices[8] = {
    Vector3(-1.f, -1.f, -1.f) * .8f, // debug coordinate system
    Vector3(1.f, -1.f, -1.f),
  
    Vector3(-1.f, -1.f, 1.f),
    Vector3(1.f, -1.f, 1.f),
  
    Vector3(-1.f, 1.f, -1.f),
    Vector3(1.f, 1.f, -1.f),
  
    Vector3(-1.f, 1.f, 1.f),
    Vector3(1.f, 1.f, 1.f),
  };
  
  uint16_t indices[] = {
    4, 0, 5,
    0, 1, 5,
  
    6, 2, 4,
    2, 0, 4,
  
    7, 3, 6,
    3, 2, 6,
  
    5, 1, 7,
    1, 3, 7,
  
    0, 2, 1,
    2, 3, 1,
  
    5, 7, 4,
    7, 6, 4,
  };
  
  // create buffers &amp; upload data
  </code></pre>
  <p>Rendering (pseudo-code):</p>
  <pre><code>// -clear color &amp; depth buffers;
  // -set the model transform to a translation of -10 units along z; 
  //   view transform is identity; projection is perspective with .25
  //   radians vertical FOV, zNear of .1, zFar of 100.; viewport is full screen
  // -set shader program;
  // -bind texture (same name, same target as upon uploading);
  // -enable backface culling only (no depth test / write);
  // -draw the cube
  // -glFlush() and swap buffers;
  </code></pre>
  <p>What on earth can be causing the two issues described above?</p>