showbase: Don't return same texture object if loaded with different settings

Follow-up to #1105
This commit is contained in:
rdb 2023-02-07 12:26:41 +01:00
parent fed5865645
commit c076d5ad08

View File

@ -718,23 +718,24 @@ class Loader(DirectObject):
flags &= ~LoaderOptions.TFMultiview
loaderOptions.setTextureFlags(flags)
sampler = SamplerState()
if minfilter is not None:
sampler.setMinfilter(minfilter)
if magfilter is not None:
sampler.setMagfilter(magfilter)
if anisotropicDegree is not None:
sampler.setAnisotropicDegree(anisotropicDegree)
if alphaPath is None:
assert Loader.notify.debug("Loading texture: %s" % (texturePath))
texture = TexturePool.loadTexture(texturePath, 0, readMipmaps, loaderOptions)
texture = TexturePool.loadTexture(texturePath, 0, readMipmaps, loaderOptions, sampler)
else:
assert Loader.notify.debug("Loading texture: %s %s" % (texturePath, alphaPath))
texture = TexturePool.loadTexture(texturePath, alphaPath, 0, 0, readMipmaps, loaderOptions)
texture = TexturePool.loadTexture(texturePath, alphaPath, 0, 0, readMipmaps, loaderOptions, sampler)
if not texture and not okMissing:
message = 'Could not load texture: %s' % (texturePath)
raise IOError(message)
if minfilter is not None:
texture.setMinfilter(minfilter)
if magfilter is not None:
texture.setMagfilter(magfilter)
if anisotropicDegree is not None:
texture.setAnisotropicDegree(anisotropicDegree)
return texture
def load3DTexture(self, texturePattern, readMipmaps = False, okMissing = False,
@ -780,18 +781,19 @@ class Loader(DirectObject):
loaderOptions.setTextureFlags(flags)
loaderOptions.setTextureNumViews(numViews)
texture = TexturePool.load3dTexture(texturePattern, readMipmaps, loaderOptions)
sampler = SamplerState()
if minfilter is not None:
sampler.setMinfilter(minfilter)
if magfilter is not None:
sampler.setMagfilter(magfilter)
if anisotropicDegree is not None:
sampler.setAnisotropicDegree(anisotropicDegree)
texture = TexturePool.load3dTexture(texturePattern, readMipmaps, loaderOptions, sampler)
if not texture and not okMissing:
message = 'Could not load 3-D texture: %s' % (texturePattern)
raise IOError(message)
if minfilter is not None:
texture.setMinfilter(minfilter)
if magfilter is not None:
texture.setMagfilter(magfilter)
if anisotropicDegree is not None:
texture.setAnisotropicDegree(anisotropicDegree)
return texture
def load2DTextureArray(self, texturePattern, readMipmaps = False, okMissing = False,
@ -837,18 +839,19 @@ class Loader(DirectObject):
loaderOptions.setTextureFlags(flags)
loaderOptions.setTextureNumViews(numViews)
texture = TexturePool.load2dTextureArray(texturePattern, readMipmaps, loaderOptions)
sampler = SamplerState()
if minfilter is not None:
sampler.setMinfilter(minfilter)
if magfilter is not None:
sampler.setMagfilter(magfilter)
if anisotropicDegree is not None:
sampler.setAnisotropicDegree(anisotropicDegree)
texture = TexturePool.load2dTextureArray(texturePattern, readMipmaps, loaderOptions, sampler)
if not texture and not okMissing:
message = 'Could not load 2-D texture array: %s' % (texturePattern)
raise IOError(message)
if minfilter is not None:
texture.setMinfilter(minfilter)
if magfilter is not None:
texture.setMagfilter(magfilter)
if anisotropicDegree is not None:
texture.setAnisotropicDegree(anisotropicDegree)
return texture
def loadCubeMap(self, texturePattern, readMipmaps = False, okMissing = False,
@ -890,18 +893,19 @@ class Loader(DirectObject):
flags &= ~LoaderOptions.TFMultiview
loaderOptions.setTextureFlags(flags)
texture = TexturePool.loadCubeMap(texturePattern, readMipmaps, loaderOptions)
sampler = SamplerState()
if minfilter is not None:
sampler.setMinfilter(minfilter)
if magfilter is not None:
sampler.setMagfilter(magfilter)
if anisotropicDegree is not None:
sampler.setAnisotropicDegree(anisotropicDegree)
texture = TexturePool.loadCubeMap(texturePattern, readMipmaps, loaderOptions, sampler)
if not texture and not okMissing:
message = 'Could not load cube map: %s' % (texturePattern)
raise IOError(message)
if minfilter is not None:
texture.setMinfilter(minfilter)
if magfilter is not None:
texture.setMagfilter(magfilter)
if anisotropicDegree is not None:
texture.setAnisotropicDegree(anisotropicDegree)
return texture
def unloadTexture(self, texture):