# OpenGL glTexImage3D not working?

I'm trying to use arrax textures with opengl 3.3 since this the target version for my application. So I have to use the glTexImage3D() method instead of glTexStorage3D(). The problem is, if I use glTexImage3D() instead of glTexStorage3D() the screen is always black. The other way round, everything works. Here is how I create the array texture:

public ArrayTexture(int width, int height) {
this.width = width;
this.height = height;
this.arrayTextureHandle = GL11.glGenTextures();
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, arrayTextureHandle);

//Works perfect
GL42.glTexStorage3D(GL30.GL_TEXTURE_2D_ARRAY, 1, GL11.GL_RGBA8, width, height, 10);
//Doesn't work with these parameters
//GL12.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, GL11.GL_RGBA8, width, height, 10, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null);

GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, 0);
}

if(zLayerCounter + sprites.length <= MAX_LAYERS) {
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, arrayTextureHandle);

Arrays.asList(sprites).forEach(sprite -> {
sprite.getTexture().getTextureData().prepare();
GL12.glTexSubImage3D(GL30.GL_TEXTURE_2D_ARRAY,
0,                      //Mipmap number
0, 0, zLayerCounter++, //xoffset, yoffset, zoffset
width, height, 1,          //width, height, depth
GL11.GL_RGBA,                 //format
GL11.GL_UNSIGNED_BYTE,       //type
sprite.getTexture().getTextureData().consumePixmap().getPixels()); //pointer to data

GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_WRAP_S, sprite.getTextureWrapS());
GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_WRAP_T, sprite.getTextureWrapT());
});

GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, 0);
} else {
throw new IllegalArgumentException("Maximum number of textures reached!");
}
}

• Try using glGetError Aug 16 '17 at 15:58
• I get an error 1280, which means GL_INVALID_ENUM. But that error appears with both methods. Aug 16 '17 at 16:08
• In the version that works you're only creating 10 aray slices. In the version that doesn't work you're creating 100. Have you checked your hardware maximums? Aug 16 '17 at 16:15

Looking at http://docs.gl/gl3/glTexImage3D, the 8th parameter (format) has to be one of GL_RED, GL_RG, GL_RGB, GL_BGR, GL_RGBA, and GL_BGRA, you use GL_RGBA8 which is not allowed. Use GL_RGBA instead.
• Do you still get an GL_INVALID_ENUM error? Check for errors after each gl*-Call to find out which one throws the error. Aug 16 '17 at 16:22
• no that error has nothing to do with the array texture. I get no error at all calling glTexImage3D() or glTexStorage3D(). Aug 16 '17 at 17:37