summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Bernard <public.jbernard@web.de>2021-04-24 01:48:09 +0200
committerJonas Bernard <public.jbernard@web.de>2021-04-24 01:48:09 +0200
commit79a6c6b13f42a6a2cd4a1b0dd4a93e25756e1b87 (patch)
tree23c1b417f74106c2540889c30090bcc1ba471b59
parentd4f6d3919e992ed9bb8d43833c694e431c9735c9 (diff)
downloadtxtgameengine-79a6c6b13f42a6a2cd4a1b0dd4a93e25756e1b87.tar.gz
txtgameengine-79a6c6b13f42a6a2cd4a1b0dd4a93e25756e1b87.tar.bz2
txtgameengine-79a6c6b13f42a6a2cd4a1b0dd4a93e25756e1b87.zip
Image.clode()
-rw-r--r--txtgameengine/twod/textures.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/txtgameengine/twod/textures.py b/txtgameengine/twod/textures.py
index 0451e5c..796774e 100644
--- a/txtgameengine/twod/textures.py
+++ b/txtgameengine/twod/textures.py
@@ -12,16 +12,14 @@ class Texture:
def __init__(self, app: 'TxtGameApp', path: str):
self.app = app
self.path = path
- self._load_from_disk()
self._bind_to_gl()
- def _load_from_disk(self):
- self.image = Image.open(TEXTURE_FOLDER + self.path)
- self.width, self.height = self.image.size
-
def _bind_to_gl(self):
- imagedata = np.array(list(self.image.getdata()), np.uint8)
+ image = Image.open(TEXTURE_FOLDER + self.path)
+ self.width, self.height = image.size
+ imagedata = np.array(list(image.getdata()), np.uint8)
self.gl_texid = self.app.render.setup_texture(self.width, self.height, imagedata)
+ image.close()
def free(self):
self.app.render.free_texture(self.gl_texid) \ No newline at end of file