Skip to content

Commit e252340

Browse files
committed
Support texture anisotropy
1 parent 5557089 commit e252340

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

demosys/opengl/texture.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
from OpenGL import GL
3+
from OpenGL.GL.EXT.texture_filter_anisotropic import *
34
from PIL import Image
45

56

@@ -28,7 +29,7 @@ def __init__(self, name=None, path=None, width=0, height=0, depth=0, lod=0, targ
2829
# filters
2930
self.min_filter = min_filter
3031
self.mag_filter = mag_filter
31-
self.anisotropy = anisotropy
32+
self.anisotropy = float(anisotropy)
3233
self.mipmap = mipmap
3334
# Force mipmaps if anisotropy is specified
3435
if self.anisotropy > 0:
@@ -109,6 +110,11 @@ def _build(self, data=None):
109110
if self.mipmap:
110111
GL.glGenerateMipmap(self.target)
111112

113+
if self.anisotropy > 0:
114+
max_ani = GL.glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)
115+
self.anisotropy = min(max_ani, self.anisotropy)
116+
GL.glTexParameterf(self.target, GL_TEXTURE_MAX_ANISOTROPY_EXT, self.anisotropy)
117+
112118
def set_image(self, image):
113119
"""
114120
Set pixel data using a image file with PIL/Pillow.

0 commit comments

Comments
 (0)