Quick fix for Blender 2.80 texture loading

The `Image.gl_load()` call was changed in Blender commit
7ad802cf3ae500bc72863b6dba0f28a488fce3d1; the two parameters we were using
were removed.

This commit fixes the exception and makes the texture browser usable again,
but doesn't properly fix everything. The textures are drawn in the wrong
colour space, which will be fixed in another commit once I know how.
This commit is contained in:
Sybren A. Stüvel 2019-05-17 11:09:57 +02:00
parent 01541f181e
commit e74e014c66
3 changed files with 11 additions and 1 deletions

View File

@ -105,3 +105,8 @@ def bind_texture(texture: bpy.types.Image):
"""Bind a Blender image to a GL texture slot."""
bgl.glActiveTexture(bgl.GL_TEXTURE0)
bgl.glBindTexture(bgl.GL_TEXTURE_2D, texture.bindcode)
def load_texture(texture: bpy.types.Image) -> int:
"""Load the texture, return OpenGL error code."""
return texture.gl_load()

View File

@ -88,3 +88,8 @@ def aabox_with_texture(v1: Float2, v2: Float2):
def bind_texture(texture: bpy.types.Image):
"""Bind a Blender image to a GL texture slot."""
bgl.glBindTexture(bgl.GL_TEXTURE_2D, texture.bindcode[0])
def load_texture(texture: bpy.types.Image) -> int:
"""Load the texture, return OpenGL error code."""
return texture.gl_load(filter=bgl.GL_NEAREST, mag=bgl.GL_NEAREST)

View File

@ -164,7 +164,7 @@ class MenuItem:
texture = self.icon
if texture:
err = texture.gl_load(filter=bgl.GL_NEAREST, mag=bgl.GL_NEAREST)
err = draw.load_texture(texture)
assert not err, 'OpenGL error: %i' % err
# ------ TEXTURE ---------#