Skip to content

Commit

Permalink
GlfBaseTexture: using glGenerateMipmap instead of setting obsoleted G…
Browse files Browse the repository at this point in the history
…L_GENERATE_MIPMAP texture property.

Fixes #1171

(Internal change: 2067269)
  • Loading branch information
unhyperbolic authored and pixar-oss committed May 12, 2020
1 parent 5ac776e commit d644aad
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pxr/imaging/glf/baseTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ GlfBaseTexture::_CreateTexture(GlfBaseTextureDataConstPtr texData,

glBindTexture(textureTarget, _textureName);

bool generateMipMaps = false;

// Check if mip maps have been requested, if so, it will either
// enable automatic generation or use the ones loaded in cpu memory
int numMipLevels = 1;
Expand All @@ -365,10 +367,10 @@ GlfBaseTexture::_CreateTexture(GlfBaseTextureDataConstPtr texData,
if (numMipLevels > 1) {
glTexParameteri(textureTarget, GL_TEXTURE_MAX_LEVEL, numMipLevels-1);
} else {
glTexParameteri(textureTarget, GL_GENERATE_MIPMAP, GL_TRUE);
generateMipMaps = true;
}
} else {
glTexParameteri(textureTarget, GL_GENERATE_MIPMAP, GL_FALSE);
glTexParameteri(textureTarget, GL_TEXTURE_MAX_LEVEL, 0);
}

if (texData->IsCompressed()) {
Expand Down Expand Up @@ -492,6 +494,10 @@ GlfBaseTexture::_CreateTexture(GlfBaseTextureDataConstPtr texData,
}
}

if (generateMipMaps) {
glGenerateMipmap(textureTarget);
}

glBindTexture(textureTarget, 0);
_SetMemoryUsed(texData->ComputeBytesUsed());
}
Expand Down

0 comments on commit d644aad

Please sign in to comment.