Skip to content

Commit 5557089

Browse files
committed
Support mipmapping
1 parent dd3ddd6 commit 5557089

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

demosys/opengl/texture.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ def __init__(self, name=None, path=None, width=0, height=0, depth=0, lod=0, targ
3030
self.mag_filter = mag_filter
3131
self.anisotropy = anisotropy
3232
self.mipmap = mipmap
33+
# Force mipmaps if anisotropy is specified
34+
if self.anisotropy > 0:
35+
self.mipmap = True
36+
# Ensure we are using the right interpolation modes
37+
if self.mipmap:
38+
self.min_filter = GL.GL_LINEAR_MIPMAP_LINEAR
39+
self.mag_filter = GL.GL_LINEAR
3340
# For pre-loading files
3441
self.name = name
3542
self.path = path
@@ -99,6 +106,9 @@ def _build(self, data=None):
99106
GL.glTexImage1D(self.target, self.lod, self.internal_format,
100107
self.height, 0, self.format, self.type, data)
101108

109+
if self.mipmap:
110+
GL.glGenerateMipmap(self.target)
111+
102112
def set_image(self, image):
103113
"""
104114
Set pixel data using a image file with PIL/Pillow.

0 commit comments

Comments
 (0)