lib/gamnit: fix `Subtexture::gl_texture` not being set
[nit.git] / lib / gamnit / textures.nit
index e29b71e..ce5546e 100644 (file)
@@ -39,7 +39,7 @@ abstract class Texture
        var error: nullable Error = null
 
        # OpenGL handle to this texture
-       var gl_texture: Int is noinit
+       fun gl_texture: Int do return root.gl_texture
 
        # Prepare a subtexture from this texture
        fun subtexture(left, top, width, height: Numeric): GamnitSubtexture
@@ -92,6 +92,8 @@ class GamnitRootTexture
        # Has this texture been loaded yet?
        var loaded = false
 
+       redef var gl_texture = -1
+
        init do all_root_textures.add self
 
        private fun load_from_pixels(pixels: Pointer, width, height: Int, format: GLPixelFormat)