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();
    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);

public void addTexture(ScrollingSprite... sprites) {
    if(zLayerCounter + sprites.length <= MAX_LAYERS) {
        GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, arrayTextureHandle);

        Arrays.asList(sprites).forEach(sprite -> {
                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!");
  • \$\begingroup\$ Try using glGetError \$\endgroup\$
    – Bálint
    Aug 16, 2017 at 15:58
  • \$\begingroup\$ I get an error 1280, which means GL_INVALID_ENUM. But that error appears with both methods. \$\endgroup\$
    – mrdlink
    Aug 16, 2017 at 16:08
  • \$\begingroup\$ 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? \$\endgroup\$ Aug 16, 2017 at 16:15

1 Answer 1


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.

  • \$\begingroup\$ Still not working. I tried all different parameters listed in the docs. \$\endgroup\$
    – mrdlink
    Aug 16, 2017 at 16:20
  • \$\begingroup\$ Do you still get an GL_INVALID_ENUM error? Check for errors after each gl*-Call to find out which one throws the error. \$\endgroup\$
    – tkausl
    Aug 16, 2017 at 16:22
  • \$\begingroup\$ no that error has nothing to do with the array texture. I get no error at all calling glTexImage3D() or glTexStorage3D(). \$\endgroup\$
    – mrdlink
    Aug 16, 2017 at 17:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .