def draw_contents(self): with self.render_pass: view = Matrix4f.look_at( origin=[0, -2, -10], target=[0, 0, 0], up=[0, 1, 0] ) model = Matrix4f.rotate( [0, 1, 0], glfw.getTime() ) fbsize = self.framebuffer_size() proj = Matrix4f.perspective( fov=25 * np.pi / 180, near=0.1, far=20, aspect=fbsize[0] / float(fbsize[1]) ) mvp = proj @ view @ model self.shader.set_buffer("mvp", np.float32(mvp).T) with self.shader: self.shader.draw_array(Shader.PrimitiveType.Triangle, 0, 36, indexed=True)
def draw_contents(self): if self.shader is None: return import numpy as np view = Matrix4f.look_at(origin=[0, -2, -10], target=[0, 0, 0], up=[0, 1, 0]) model = Matrix4f.rotate([0, 1, 0], glfw.getTime()) model2 = Matrix4f.rotate([1, 0, 0], self.rotation) size = self.size() proj = Matrix4f.perspective(fov=25 * np.pi / 180, near=0.1, far=20, aspect=size[0] / float(size[1])) mvp = proj @ view @ model @ model2 self.shader.set_buffer("mvp", np.float32(mvp).T) with self.shader: self.shader.draw_array(Shader.PrimitiveType.Triangle, 0, 36, indexed=True)
def draw_contents(self): if self.shader is None: return self.render_pass.resize(self.framebuffer_size()) s = self.size() with self.render_pass: mvp = Matrix4f.scale([s[1] / float(s[0]) * 0.25, 0.25, 0.25]) @ \ Matrix4f.rotate([0, 0, 1], glfw.getTime()) self.shader.set_buffer("mvp", np.float32(mvp).T) with self.shader: self.shader.draw_array(Shader.PrimitiveType.Triangle, 0, 6, True)