def __init__(self, **kwargs):
    super().__init__(**kwargs)
    self.prog = self.ctx.program(vertex_shader='\n                #version 330\n\n                uniform mat4 Mvp;\n\n                in vec3 in_vert;\n                in vec3 in_norm;\n                in vec2 in_text;\n\n                out vec3 v_vert;\n                out vec3 v_norm;\n                out vec2 v_text;\n\n                void main() {\n                    gl_Position = Mvp * vec4(in_vert, 1.0);\n                    v_vert = in_vert;\n                    v_norm = in_norm;\n                    v_text = in_text;\n                }\n            ', fragment_shader='\n                #version 330\n\n                uniform vec3 Light;\n                uniform sampler2D Texture;\n\n                in vec3 v_vert;\n                in vec3 v_norm;\n                in vec2 v_text;\n\n                out vec4 f_color;\n\n                void main() {\n                    float lum = clamp(dot(normalize(Light - v_vert), normalize(v_norm)), 0.0, 1.0) * 0.8 + 0.2;\n                    f_color = vec4(texture(Texture, v_text).rgb * lum, 1.0);\n                }\n            ')
    self.mvp = self.prog['Mvp']
    self.light = self.prog['Light']
    obj = Obj.open(data.find('crate.obj'))
    img = Image.open(data.find('crate.png')).transpose(Image.FLIP_TOP_BOTTOM).convert('RGB')
    self.texture = self.ctx.texture(img.size, 3, img.tobytes())
    self.texture.use()
    self.vbo = self.ctx.buffer(obj.pack('vx vy vz nx ny nz tx ty'))
    self.vao = self.ctx.simple_vertex_array(self.prog, self.vbo, 'in_vert', 'in_norm', 'in_text')
def __init__(self, **kwargs):
    super().__init__(**kwargs)
    self.prog = self.ctx.program(vertex_shader='\n                #version 330\n\n                uniform mat4 Mvp;\n\n                in vec3 in_vert;\n                in vec3 in_norm;\n                in vec2 in_text;\n\n                out vec3 v_vert;\n                out vec3 v_norm;\n                out vec2 v_text;\n\n                void main() {\n                    gl_Position = Mvp * vec4(in_vert, 1.0);\n                    v_vert = in_vert;\n                    v_norm = in_norm;\n                    v_text = in_text;\n                }\n            ', fragment_shader='\n                #version 330\n\n                uniform vec3 Light;\n                uniform sampler2D Texture;\n\n                in vec3 v_vert;\n                in vec3 v_norm;\n                in vec2 v_text;\n\n                out vec4 f_color;\n\n                void main() {\n                    float lum = clamp(dot(normalize(Light - v_vert), normalize(v_norm)), 0.0, 1.0) * 0.8 + 0.2;\n                    f_color = vec4(texture(Texture, v_text).rgb * lum, 1.0);\n                }\n            ')
    self.mvp = self.prog['Mvp']
    self.light = self.prog['Light']
    obj = Obj.open(data.find('crate.obj'))
    img = Image.open(data.find('crate.png')).transpose(Image.FLIP_TOP_BOTTOM).convert('RGB')
    self.texture = self.ctx.texture(img.size, 3, img.tobytes())
    self.texture.use()
    self.vbo = self.ctx.buffer(obj.pack('vx vy vz nx ny nz tx ty'))
    self.vao = self.ctx.simple_vertex_array(self.prog, self.vbo, 'in_vert', 'in_norm', 'in_text')