gui: Allow OnscreenImage to be used before ShowBase is created

Use TexturePool directly instead of a loader being present in the builtins

Fixes #1209
This commit is contained in:
rdb 2021-12-04 20:40:29 +01:00
parent 82ebf908fa
commit 24755bc8eb

View File

@ -114,7 +114,9 @@ class OnscreenImage(DirectObject, NodePath):
tex = image
else:
# It's a Texture file name
tex = loader.loadTexture(image)
tex = TexturePool.loadTexture(image)
if not tex:
raise IOError('Could not load texture: %s' % (image))
cm = CardMaker('OnscreenImage')
cm.setFrame(-1, 1, -1, 1)
self.assign(parent.attachNewNode(cm.generate(), sort))