const vec4 blue = vec4(0.80,0.80,1.00,1.00); const vec4 white = vec4(1.00,1.00,1.00,1.00); uniform sampler2D texture; varying vec2 v_texcoord; void main() { float v = texture2D(texture, v_texcoord).r; gl_FragColor = mix(white,blue,v); } """ transform = Arcball(Position(),znear=1,zfar=10) viewport = Viewport() radius = 1.5 vertices, indices = sphere(radius, 64, 64) earth = gloo.Program(vertex, fragment) earth.bind(vertices) earth['texture'] = data.get("earth-black.jpg") earth['texture'].interpolation = gl.GL_LINEAR earth['transform'] = transform paths = PathCollection(mode="agg+", color="global", linewidth="global", viewport=viewport, transform=transform) paths["color"] = 0,0,0,0.5 paths["linewidth"] = 1.0 theta = np.linspace(0, 2*np.pi, 64, endpoint=True) for phi in np.linspace(0, np.pi, 12, endpoint=False): paths.append(spheric_to_cartesian(phi, theta, radius*1.01), closed=True)
@window.event def on_init(): gl.glEnable(gl.GL_DEPTH_TEST) @window.event def on_key_press(key, modifiers): global vertices, indices, index if key == ord(' '): index = (index+1) % len(shapes) vertices, indices = shapes[index] program.bind(vertices) index = 0 shapes = [ primitives.plane(1.5), primitives.cube(1.5), primitives.sphere(), primitives.cubesphere(), primitives.cylinder(), primitives.torus(), primitives.cone(), primitives.pyramid(), primitives.teapot() ] vertices, indices = shapes[index] program = gloo.Program(vertex, fragment) program.bind(vertices) view = np.eye(4, dtype=np.float32) model = np.eye(4, dtype=np.float32) projection = np.eye(4, dtype=np.float32) glm.translate(view, 0, 0, -5) program['model'] = model
@window.event def on_key_press(key, modifiers): global vertices, indices, index if key == ord(' '): index = (index + 1) % len(shapes) vertices, indices = shapes[index] program.bind(vertices) index = 0 shapes = [ primitives.plane(1.5), primitives.cube(1.5), primitives.sphere(), primitives.cubesphere(), primitives.cylinder(), primitives.torus(), primitives.cone(), primitives.pyramid(), primitives.teapot() ] vertices, indices = shapes[index] program = gloo.Program(vertex, fragment) program.bind(vertices) view = np.eye(4, dtype=np.float32) model = np.eye(4, dtype=np.float32) projection = np.eye(4, dtype=np.float32) glm.translate(view, 0, 0, -5)