PDA

View Full Version : GL_TEXTURE_CUBE_MAP min/mag filter problem



Unresolved External
02-06-2014, 11:02 AM
Hello! I found it hard getting min/mag filtering to work with cubemap texture. In the screenshot-attachment I've created a cube using a cubemap texture, and also a grid of planes using a 2D texture. For both the cubemap and 2D texture I use GL_LINEAR_MIPMAP_LINEAR, for min-filter. For 2D texture it works, but for the cubemap it doesn't.

Below, I've listed the code for how I set up my cubemap texture. I would be glad if someone could help me out with this, thanks in advance :)



levels = floor(log2(max(width, height))) + 1;


glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
glGenTextures(1, &id);
glActiveTexture(textureUnit);
glBindTexture(GL_TEXTURE_CUBE_MAP, id);


glTexStorage2D(GL_TEXTURE_CUBE_MAP, levels, internalFormat, width, height);


for (GLenum target = GL_TEXTURE_CUBE_MAP_POSITIVE_X, i = 0; target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; target++, i++)
{
glTexSubImage2D(target, 0, 0, 0, width, height, format, GL_UNSIGNED_BYTE, cubeMapList[i]->pixels);
}


glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);