program['u_antialias'] = 1.0 # Polar domains program['u_major_grid_step'] = np.array([ 1.00, np.pi/6]) program['u_minor_grid_step'] = np.array([ 0.25, np.pi/60]) program['u_limits1'] = -5.1, +5.1, -5.1, +5.1 program['u_limits2'] = 1.0, 5.0, 0*np.pi, 2*np.pi # Cartesian domains # program['u_major_grid_step'] = np.array([ 1.00, 1.00]) # program['u_minor_grid_step'] = np.array([ 0.10, 0.10]) # program['u_limits1'] = -5.1, +5.1, -5.1, +5.1 # program['u_limits2'] = -5.0, +5.0, -5.0, +5.0 # Hammer domains # program['u_major_grid_step'] = np.array([ 1.00, 0.50]) * np.pi/ 6.0 # program['u_minor_grid_step'] = np.array([ 1.00, 0.50]) * np.pi/30.0 # program['u_limits1'] = -3.0, +3.0, -1.5, +1.5 # program['u_limits2'] = -np.pi, +np.pi, -np.pi/3, +np.pi/3 program['transform'] = shaders.get("transforms/polar.glsl") # program['transform'] = shaders.get("transforms/identity.glsl") # program['transform'] = shaders.get("transforms/hammer.glsl") program['trackball'] = Trackball(Position2D("texcoord")) program['trackball'].theta = 0 program['trackball'].phi = 0 program['trackball'].zoom = 7.5 window.attach(program['trackball']) app.run()
window = app.Window(width=1024, height=1024, color=(.75, .75, .75, 1)) @window.event def on_draw(dt): window.clear() teapot.draw(gl.GL_TRIANGLES, indices) @window.event def on_init(): gl.glEnable(gl.GL_BLEND) gl.glEnable(gl.GL_DEPTH_TEST) vertices, indices = primitives.teapot() vertices["position"] *= 10 teapot = gloo.Program(teapot_vert, teapot_frag) teapot.bind(vertices) teapot['texture'] = data.checkerboard() trackball = Trackball(Position("position"), znear=0.1, zfar=100.0, distance=50) teapot['transform'] = trackball trackball.theta = 40 trackball.phi = 135 trackball.zoom = 40 window.attach(teapot['transform']) app.run()
# program['u_minor_grid_step'] = np.array([ 0.25, np.pi/60]) # program['u_limits1'] = -5.1, +5.1, -5.1, +5.1 # program['u_limits2'] = 1.0, 5.0, 0*np.pi, 2*np.pi # Cartesian domains program['u_major_grid_step'] = np.array([1.00, 1.00]) program['u_minor_grid_step'] = np.array([0.10, 0.10]) program['u_limits1'] = -5.1, +5.1, -5.1, +5.1 program['u_limits2'] = -5.0, +5.0, -5.0, +5.0 # Hammer domains # program['u_major_grid_step'] = np.array([ 1.00, 0.50]) * np.pi/ 6.0 # program['u_minor_grid_step'] = np.array([ 1.00, 0.50]) * np.pi/30.0 # program['u_limits1'] = -3.0, +3.0, -1.5, +1.5 # program['u_limits2'] = -np.pi, +np.pi, -np.pi/3, +np.pi/3 # program['transform'] = shaders.get("transforms/polar.glsl") # program['transform'] = shaders.get("transforms/hammer.glsl") program['transform_forward'] = gloo.Snippet( library.get("transforms/identity_forward.glsl")) program['transform_inverse'] = gloo.Snippet( library.get("transforms/identity_inverse.glsl")) program['trackball'] = Trackball(Position("texcoord")) program['trackball'].theta = 0 program['trackball'].phi = 0 program['trackball'].zoom = 7.5 window.attach(program['trackball']) app.run()
framebuffer = gloo.FrameBuffer(color=[accumulation,revealage]) # Three quads quads = gloo.Program(vert_quads, frag_quads, count=12) quads["position"] = [ (-1,-1,-1), (-1,+1,-1), (+1,-1,-1), (+1,+1,-1), (-1,-1, 0), (-1,+1, 0), (+1,-1, 0), (+1,+1, 0), (-1,-1,+1), (-1,+1,+1), (+1,-1,+1), (+1,+1,+1) ] quads["position"] *= 10 quads["color"] = C1,C1,C1,C1, C2,C2,C2,C2, C3,C3,C3,C3 indices = np.zeros((3,6),dtype=np.uint32) indices[0] = 0 + np.array([0,1,2,1,2,3]) indices[1] = 4 + np.array([0,1,2,1,2,3]) indices[2] = 8 + np.array([0,1,2,1,2,3]) indices = indices.view(gloo.IndexBuffer) # Post composition post = gloo.Program(vert_post, frag_post) post['tex_accumulation'] = accumulation post['tex_revealage'] = revealage post['position'] = [(-1,-1), (-1,1), (1,-1), (1,1)] trackball = Trackball(Position("position"), znear=0.1, zfar=100.0, distance=50) quads['transform'] = trackball trackball.theta = 40 trackball.phi = 45 trackball.zoom = 40 window.attach(quads['transform']) app.run()
@window.event def on_draw(dt): window.clear() quads.draw(gl.GL_TRIANGLES, indices) @window.event def on_init(): gl.glEnable(gl.GL_DEPTH_TEST) quads = gloo.Program(vertex, fragment, count=12) quads["position"] = [ (-1,-1,-1), (-1,+1,-1), (+1,-1,-1), (+1,+1,-1), (-1,-1, 0), (-1,+1, 0), (+1,-1, 0), (+1,+1, 0), (-1,-1,+1), (-1,+1,+1), (+1,-1,+1), (+1,+1,+1) ] quads["position"] *= 10 indices = np.zeros((3,6),dtype=np.uint32) indices[0] = 0 + np.array([0,1,2,1,2,3]) indices[1] = 4 + np.array([0,1,2,1,2,3]) indices[2] = 8 + np.array([0,1,2,1,2,3]) indices = indices.view(gloo.IndexBuffer) trackball = Trackball(Position("position"), znear=0.1, zfar=100, distance=50) quads['transform'] = trackball trackball.theta = 40 trackball.phi = 45 trackball.zoom = 25 window.attach(quads['transform']) app.run()
quads = gloo.Program(vertex, fragment, count=12) quads["position"] = [ (-1, -1, -1), (-1, +1, -1), (+1, -1, -1), (+1, +1, -1), (-1, -1, 0), (-1, +1, 0), (+1, -1, 0), (+1, +1, 0), (-1, -1, +1), (-1, +1, +1), (+1, -1, +1), (+1, +1, +1), ] quads["position"] *= 10 indices = np.zeros((3, 6), dtype=np.uint32) indices[0] = 0 + np.array([0, 1, 2, 1, 2, 3]) indices[1] = 4 + np.array([0, 1, 2, 1, 2, 3]) indices[2] = 8 + np.array([0, 1, 2, 1, 2, 3]) indices = indices.view(gloo.IndexBuffer) trackball = Trackball(Position("position"), znear=0.1, zfar=100, distance=50) quads["transform"] = trackball trackball.theta = 40 trackball.phi = 45 trackball.zoom = 25 window.attach(quads["transform"]) app.run()