title: OpenGL 3.2 Why am I getting INVALID_ENUM error for glTexStorage3D?
body: <pre><code>stbi_uc* data = stbi_load(path, &amp;width, &amp;height, NULL, 4);
  if (data == NULL) {
      return false;
  }
  gl_flush_errors();
  
  glGenTextures(1, &amp;id);
  glBindTexture(GL_TEXTURE_2D_ARRAY, id);
  glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA, 50, 50, 1);
  </code></pre>
  
  <p>This is the portion of my code where the INVALID_ENUM error is coming from, which I've narrowed down to the glTexStorage3D call. I'm also experiencing an INVALID_VALUE error directly after this block of code with:</p>
  
  <pre><code>glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, width, height, 1, GL_RGBA, GL_UNSIGNED_BYTE, data);
  
  glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_REPEAT);
  glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_REPEAT);
  glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_CLAMP_TO_EDGE);
  </code></pre>
  
  <p>My goal here is to set up a texture array with my working tile instancing so I can render my tilemap in one draw call. I'm experiencing the same issue as here:
  <a href="https://stackoverflow.com/questions/41028563/instanced-drawing-with-texture-atlas">Instanced drawing with texture atlas</a></p>
  
  <p>However, I'm not sure if I'm doing this correctly at the moment so any help or direction would be appreciated. These are my shaders as well in case they're the cause of the issue:</p>
  
  <p>Fragment Shader</p>
  
  <pre><code>#version 330
  // From vertex shader
  in vec2 uvcoord;
  
  // Application data
  uniform sampler2DArray textures;
  // uniform vec3 fcolor;
  
  // Output color
  layout(location = 0) out  vec4 color;
  
  void main()
  {
  
      color = texture(textures, vec3(uvcoord.x, uvcoord.y, 0.0));
  
  
  }
  </code></pre>
  
  <p>Vertex Shader</p>
  
  <pre><code>#version 330 
  // Input attributes
  in vec2 in_position;
  in vec2 in_uvcoord;
  in vec2 in_centre_pos;
  
  // Passed to fragment shader
  out vec2 uvcoord;
  out vec2 vpos;
  
  // Application data
  uniform mat3 transform;
  uniform mat3 projection;
  
  void main()
  {
      uvcoord = in_uvcoord;
      vpos = in_position;
      vec3 pos = projection * vec3(in_position.x + in_centre_pos.x, in_position.y + in_centre_pos.y, 1.0);
      gl_Position = vec4(pos.x, pos.y, 0.0, 1.0);
  }
  </code></pre>