如何解决使用Python进行渲染的属性错误?

时间:2018-12-10 04:55:40

标签: python glsl rendering renderer

MyRenderer(Renderer)类:

def __init__(self, svbrdf, mesh, camera, size):
    super().__init__(size, 0, 500, camera, show=True)

    self.renderables = [Renderable(material, {
        'a_position': vertex_positions,
        'a_normal': vertex_normals,
        'a_tangent': vertex_tangents,
        'a_bitangent': vertex_bitangents,
        'a_uv': vertex_uvs,
        }, len(self.lights))]

def update_uniforms(self):
    self.program['cam_pos'] = linalg.inv(self.camera.view_mat())[:3, 3]
    self.program['u_view_mat'] = self.camera.view_mat().T
    self.program['u_model_mat'] = np.eye(4)
    self.program['u_perspective_mat'] = self.camera.perspective_mat().T

    for i, light in enumerate(self.lights):
        self.program['light_position[{}]'.format(i)] = light.position
        self.program['light_intensity[{}]'.format(i)] = light.intensity
        self.program['light_color[{}]'.format(i)] = light.color

def draw(self):
    gloo.clear(color=(1, 1, 1))
    for renderable in self.renderables:
        self.program = renderable.program
        self.update_uniforms()
        self.program.draw(gl.GL_TRIANGLES)

该代码具有AttributeError (“ MyRenderer”对象没有可渲染的属性)

如何解决?请帮助我。

0 个答案:

没有答案