title: GL_INVALID_OPERATION in glGenerateMipmap(incomplete cube map)
body: <p>I'm trying to learn OpenGL and i'm using SOIL to load images.</p>
  
  <p>I have the following piece of code:</p>
  
  <pre><code>GLuint texID = 0;
  
  bool loadCubeMap(const char * baseFileName) {
  
      glActiveTexture(GL_TEXTURE0);
  
      glGenTextures(1, &amp;texID);
      glBindTexture(GL_TEXTURE_CUBE_MAP, texID);
  
      const char * suffixes[] = { "posx", "negx", "posy", "negy", "posz", "negz" };
      GLuint targets[] = {
          GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
          GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
          GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
      };
  
      for (int i = 0; i &lt; 6; i++) {
          int width, height;
          std::string fileName = std::string(baseFileName) + "_" + suffixes[i] + ".png";
          std::cout &lt;&lt; "Loading: " &lt;&lt; fileName &lt;&lt; std::endl;        
          unsigned char * image = SOIL_load_image(fileName.c_str(), &amp;width, &amp;height, 0, SOIL_LOAD_RGB);
          if (!image) {
              std::cerr &lt;&lt; __FUNCTION__ &lt;&lt; " cannot load image " &lt;&lt; fileName &lt;&lt; " (" &lt;&lt; SOIL_last_result() &lt;&lt; ")" &lt;&lt; std::endl;
              return false;
          }
          glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
          SOIL_free_image_data(image);
      }
  
      glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
      glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
      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);
      glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
  
      glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
      return true;
  
  }
  </code></pre>
  
  <p>When i call this, the images load successfully, but then i get an error in console:</p>
  
  <pre><code>---- OGL DEBUG ----
  message &lt;1&gt;: 'API' reported 'Error' with 'High' severity: 
  GL_INVALID_OPERATION in glGenerateMipmap(incomplete cube map)
  ---- BACKTRACE ----
  </code></pre>
  
  <p>and no cubemap is displaying at all.
  Do you see any mistake in this code?</p>