예제 #1
0
import numpy as np
from vispy import app
from vispy import gloo
from vispy.gloo import gl

app.use('glfw')


vertex = """
attribute float x;
attribute float y;
attribute float a;

varying float v_a;
void main (void)
{
    v_a = a;
    gl_Position = vec4(x, y, 0.0, 1.0);
}
"""

fragment = """
varying float v_a;
void main()
{
    gl_FragColor = vec4(1.0-v_a);
}
"""

class Window(app.Canvas):
    def __init__(self, n=50):
예제 #2
0
This example shows how to actively select and test the glut backend.

You should see a black window and any mouse or keyboard event should be
detected. A timer is also run every second and it should print "tick !"
every second.

Notes
-----
Depending on on your glut implementation (native or freeglut), the mouse wheel
event may or may not be detected. Furthermore, glut has no utf-8 support and
non ascii-key will most likely produces garbage.
"""

from vispy import app
from vispy.gloo import gl
app.use('glut')


class Canvas(app.Canvas):

    def __init__(self, *args, **kwargs):
        app.Canvas.__init__(self, *args, **kwargs)
        timer = app.Timer(1.0)
        timer.connect(self.on_timer)
        timer.start()

    def on_initialize(self, event):
        gl.glClearColor(0, 0, 0, 1)
        print('on_initialize')

    def on_close(self, event):
예제 #3
0
This example shows how to actively select and test the glut backend.

You should see a black window and any mouse or keyboard event should be
detected. A timer is also ran every second and it should print "tick !"
every second.

Note:
====
Depending on on your glut implementation (native or freeglut), the mouse wheel
event may or may not be detected. Furthermore, glut has no utf-8 support and
non ascii-key will most likely produces garbage.
"""

from vispy import app
from vispy.gloo import gl
app.use('glut')


class Canvas(app.Canvas):
    def __init__(self, *args, **kwargs):
        app.Canvas.__init__(self, *args, **kwargs)
        timer = app.Timer(1.0)
        timer.connect(self.on_timer)
        timer.start()

    def on_initialize(self, event):
        gl.glClearColor(0, 0, 0, 1)
        print('on_initialize')

    def on_close(self, event):
        print('on_close')
예제 #4
0
# !/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This example shows how to actively select and test the qt backend.

You should see a black window and any mouse or keyboard event should be
detected. A timer is also run every second and it should print "tick !"
every second.
"""

from vispy import app
from vispy.gloo import gl
app.use('qt')


class Canvas(app.Canvas):

    def __init__(self, *args, **kwargs):
        app.Canvas.__init__(self, *args, **kwargs)
        timer = app.Timer(1.0)
        timer.connect(self.on_timer)
        timer.start()

    def on_initialize(self, event):
        gl.glClearColor(0, 0, 0, 1)
        print('on_initialize')

    def on_close(self, event):
        print('on_close')

    def on_resize(self, event):
예제 #5
0
파일: app-pyglet.py 프로젝트: ds604/vispy
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This example shows how to actively select and test the pyglet backend.

You should see a black window and any mouse or keyboard event should be
detected. A timer is also ran every second and it should print "tick !"
every second.
"""

from vispy import app
from vispy.gloo import gl
app.use('pyglet')

class Canvas(app.Canvas):
    def __init__(self, *args, **kwargs):
        app.Canvas.__init__(self, *args, **kwargs)
        timer = app.Timer(1.0)
        timer.connect(self.on_timer)
        timer.start()

    def on_initialize(self, event):
        gl.glClearColor(0,0,0,1)
        print('on_initialize')

    def on_close(self, event):
        print('on_close')

    def on_resize(self, event):
        print('on_resize (%dx%d)' % event.size)
예제 #6
0
import numpy as np
from vispy import app
from vispy import gloo
from vispy.gloo import gl

app.use('glfw')

vertex = """
attribute float x;
attribute float y;
void main (void)
{
    gl_Position = vec4(x, y, 0.0, 1.0);
}
"""

fragment = """
void main()
{
    gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
}
"""


class Window(app.Canvas):
    def __init__(self, n=50):
        app.Canvas.__init__(self)
        self.program = gloo.Program(vertex, fragment, n)
        gl.glClearColor(1, 1, 1, 1)
        self.program['x'] = np.linspace(-1.0, +1.0, n)
        self.program['y'] = np.random.uniform(-0.5, +0.5, n)
예제 #7
0
파일: app-pyglet.py 프로젝트: ds604/vispy
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This example shows how to actively select and test the pyglet backend.

You should see a black window and any mouse or keyboard event should be
detected. A timer is also ran every second and it should print "tick !"
every second.
"""

from vispy import app
from vispy.gloo import gl
app.use('pyglet')


class Canvas(app.Canvas):
    def __init__(self, *args, **kwargs):
        app.Canvas.__init__(self, *args, **kwargs)
        timer = app.Timer(1.0)
        timer.connect(self.on_timer)
        timer.start()

    def on_initialize(self, event):
        gl.glClearColor(0, 0, 0, 1)
        print('on_initialize')

    def on_close(self, event):
        print('on_close')

    def on_resize(self, event):
        print('on_resize (%dx%d)' % event.size)
예제 #8
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A GLSL sandbox application based on the spinning cube. Requires PySide
or PyQt4.
"""

import numpy as np
from vispy import app, gloo, dataio
from vispy.util.transforms import perspective, translate, rotate

# Force using qt and take QtCore+QtGui from backend module,
# since we do not know whether PySide or PyQt4 is used
app.use("qt")
QtCore = (app.default_app.backend_module.QtCore,)
QtGui = app.default_app.backend_module.QtGui


VERT_CODE = """
uniform   mat4 u_model;
uniform   mat4 u_view;
uniform   mat4 u_projection;

attribute vec3 a_position;
attribute vec2 a_texcoord;

varying vec2 v_texcoord;

void main()
{
    v_texcoord = a_texcoord;