glBindTexture(GL_TEXTURE_2D_ARRAY, texture_id);
glTexStorage3D(GL_TEXTURE_2D_ARRAY,
1, // No mipmaps
GL_RGBA8, // Internal format
width, height, // width,height
1 // Number of layers
);
glTexSubImage3D(GL_TEXTURE_2D_ARRAY,
0, // Mipmap number
0, 0, 0, // xoffset, yoffset, zoffset
width, height, 1, // width, height, depth
GL_RGBA8, // format
GL_UNSIGNED_BYTE, // type
image); // pointer to data
For testing I only create an array of length 1. I am currently using OpenGL 4.3 but I want to switch back to OpenGL 3.3 which means that I can not use glTexStorage3D
.
So I tried to switch to glTexImage3D
glBindTexture(GL_TEXTURE_2D_ARRAY, texture_id);
glTexImage3D(GL_TEXTURE_2D_ARRAY,
1, // level
GL_RGBA8, // Internal format
width, height, 1, // width,height,depth
0, // border?
GL_RGBA, // format
GL_UNSIGNED_BYTE, // type
0); // pointer to data
glTexSubImage3D(GL_TEXTURE_2D_ARRAY,
0, // Mipmap number
0, 0, 0, // xoffset, yoffset, zoffset
width, height, 1, // width, height, depth
GL_RGBA8, // format
GL_UNSIGNED_BYTE, // type
image); // pointer to data
But it is not working and I am not sure what I am doing wrong.
Edit: I should probably add that it is working with glTexStorage3d
.