Example #1
0
def on_draw(dt):
    window.clear()
    program.draw(gl.GL_TRIANGLES, I)

@window.event
def on_key_press(key, modifiers):
    if key == app.window.key.SPACE:
        transform.reset()

def func3(x,y):
    return (1-x/2+x**5+y**3)*np.exp(-x**2-y**2)
x = np.linspace(-2.0, 2.0, 256).astype(np.float32)
y = np.linspace(-2.0, 2.0, 256).astype(np.float32)
X,Y = np.meshgrid(x, y)
Z = func3(X,Y)

program = gloo.Program(vertex, fragment)
V,I = primitives.plane(2.0, n=64)
program.bind(V)

program['data'] = (Z-Z.min())/(Z.max() - Z.min())
program['data'].interpolation = gl.GL_NEAREST
program['data_shape'] = Z.shape[1], Z.shape[0]
program['u_kernel'] = data.get("spatial-filters.npy")
program['u_kernel'].interpolation = gl.GL_LINEAR

transform = PanZoom(aspect=1)
program['transform'] = transform
window.attach(transform)
app.run()
Example #2
0
    surface['model'] = model
    surface['normal'] = np.array(np.matrix(np.dot(view, model)).I.T)
    # surface["height"] = 0.75*np.cos(time/5.0)


@window.event
def on_init():
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
    gl.glPolygonOffset(1, 1)
    gl.glEnable(gl.GL_LINE_SMOOTH)
    gl.glLineWidth(2.5)


n = 64
surface = gloo.Program(vertex, fragment)
vertices, s_indices = primitives.plane(2.0, n=n)
surface.bind(vertices)

I = []
for i in xrange(n): I.append(i)
for i in xrange(1,n): I.append(n-1+i*n)
for i in xrange(n-1): I.append(n*n-1-i)
for i in xrange(n-1): I.append(n*(n-1) - i*n)
b_indices = np.array(I, dtype=np.uint32).view(gloo.IndexBuffer)


def func3(x,y):
    return (1-x/2+x**5+y**3)*np.exp(-x**2-y**2)
x = np.linspace(-2.0, 2.0, 32).astype(np.float32)
y = np.linspace(-2.0, 2.0, 32).astype(np.float32)
X,Y = np.meshgrid(x, y)
Example #3
0
    program['projection'] = glm.perspective(45.0, width / float(height), 2.0, 100.0)

@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)
Example #4
0
@window.event
def on_key_press(key, modifiers):
    if key == app.window.key.SPACE:
        transform.reset()


def func3(x, y):
    return (1 - x / 2 + x**5 + y**3) * np.exp(-x**2 - y**2)


x = np.linspace(-2.0, 2.0, 256).astype(np.float32)
y = np.linspace(-2.0, 2.0, 256).astype(np.float32)
X, Y = np.meshgrid(x, y)
Z = func3(X, Y)

program = gloo.Program(vertex, fragment)
V, I = primitives.plane(2.0, n=64)
program.bind(V)

program['data'] = (Z - Z.min()) / (Z.max() - Z.min())
program['data'].interpolation = gl.GL_NEAREST
program['data_shape'] = Z.shape[1], Z.shape[0]
program['u_kernel'] = data.get("spatial-filters.npy")
program['u_kernel'].interpolation = gl.GL_LINEAR

transform = PanZoom(aspect=1)
program['transform'] = transform
window.attach(transform)
app.run()
Example #5
0
    surface['model'] = model
    surface['normal'] = np.array(np.matrix(np.dot(view, model)).I.T)
    # surface["height"] = 0.75*np.cos(time/5.0)


@window.event
def on_init():
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
    gl.glPolygonOffset(1, 1)
    gl.glEnable(gl.GL_LINE_SMOOTH)
    gl.glLineWidth(2.5)


n = 64
surface = gloo.Program(vertex, fragment)
vertices, s_indices = primitives.plane(2.0, n=n)
surface.bind(vertices)

I = []
for i in range(n):
    I.append(i)
for i in range(1, n):
    I.append(n - 1 + i * n)
for i in range(n - 1):
    I.append(n * n - 1 - i)
for i in range(n - 1):
    I.append(n * (n - 1) - i * n)
b_indices = np.array(I, dtype=np.uint32).view(gloo.IndexBuffer)


def func3(x, y):
Example #6
0
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)