PDA

View Full Version : How to build mipmaps for a TEXTURE_2D_ARRAY?



resle
06-08-2010, 03:01 AM
I need to build mipmaps for a texture array that normaly upload as follows

glGenTextures(1, @handle);
glBindTexture(GL_TEXTURE_2D_ARRAY, handle);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, width, height, maps.count, 0, GL_BGRA, GL_UNSIGNED_BYTE, data);

For a single 2D texture I could, of course, use GluBuild2DMipMap just before calling GlTexImage2D. I remember seeing that a GluBuild3DMipMap exists, but I can't actually get its address within Opengl.dll, it seems to be amiss in every version I try. I also installed several different drivers.

Any hint?

resle
06-08-2010, 03:06 AM
Solved with GlTexParameteri(GL_TEXTURE_2D_ARRAY, GL_GENERATE_MIPMAP, GL_TRUE)

Sorry for bothering :)

ZbuffeR
06-08-2010, 04:30 AM
http://www.opengl.org/wiki/Common_Mistakes#Automatic_mipmap_generation

glGenerateMipmapEXT(GL_TEXTURE_2D_ARRAY); is preferred with current OpenGL. Especially useful if you do several changes to the texture(s), as mipmap generation will be done only once.