예제 #1
0
def _test_functonality(backend):
    """ Create app and canvas so we have a context. Then run tests.
    """
    # use the backend
    gl.use(backend)
    
    with Canvas() as canvas:
        _clear_screen()
        
        # Prepare
        w, h = canvas.size
        gl.glViewport(0, 0, w, h)
        gl.glScissor(0, 0, w, h)  # touch
        gl.glClearColor(0.0, 0.0, 0.0, 1.0)
        
        # Setup visualization, ensure to do it in a draw event
        objects = _prepare_vis()
        _clear_screen()
        _draw1()
        _clear_screen()
        _draw2()
        _clear_screen()
        _draw3()

        # Clean up
        for delete_func, handle in objects:
            delete_func(handle)
        gl.glFinish()
예제 #2
0
def _test_functonality(backend):
    """ Create app and canvas so we have a context. Then run tests.
    """

    # use the backend
    gl.use(backend)
    
    # Note that we explicitly use pyglet because with Qt we seem
    # to get errors for this test
    
    with app_opengl_context('qt') as context:
        
        _clear_screen()
        
        # Prepare
        w, h = context.c.size
        gl.glViewport(0, 0, w, h)
        gl.glScissor(0, 0, w, h)  # touch
        gl.glClearColor(0.0, 0.0, 0.0, 1.0)
        
        # Setup visualization, ensure to do it in a paint event
        objects = context.test(_prepare_vis)
        
        _clear_screen()
        
        # Draw 1
        context.test(_draw1)
        if SHOW:
            context.c.swap_buffers()
            app.process_events()
            time.sleep(1.0)
        
        _clear_screen()
        
        # Draw 2
        context.test(_draw2)
        if SHOW:
            context.c.swap_buffers()
            app.process_events()
            time.sleep(1.0)
        
        _clear_screen()
        
        # Draw 3
        context.test(_draw3)
        if SHOW:
            context.c.swap_buffers()
            app.process_events()
            time.sleep(1.0)
        
        # Clean up
        for delete_func, handle in objects:
            delete_func(handle)
예제 #3
0
파일: test_basics.py 프로젝트: LiloD/vispy
def _test_basics(backend):
    """ Create app and canvas so we have a context. Then run tests.
    """

    # use the backend
    gl.use(backend)
    
    with app_opengl_context():
        _test_setting_parameters()
        _test_enabling_disabling()
        _test_setting_stuff()
        _test_object_creation_and_deletion()
        _test_fbo()
예제 #4
0
파일: test_use.py 프로젝트: LiloD/vispy
def test_use_desktop():
    """ Using that gl.use injects all names in gl namespace """

    # Use desktop
    gl.use('desktop')
    #
    for name in dir(gl.desktop):
        if name.lower().startswith('gl'):
            val1 = getattr(gl, name)
            val2 = getattr(gl.desktop, name)
            assert_is(val1, val2)

    # Use pyopengl
    gl.use('pyopengl')
    #
    for name in dir(gl.desktop):
        if name.lower().startswith('gl'):
            val1 = getattr(gl, name)
            val2 = getattr(gl.pyopengl, name)
            assert_is(val1, val2)
    
    # Touch debug wrapper stuff
    gl.use('desktop debug')
    
    # Use desktop again
    gl.use('desktop')
    #
    for name in dir(gl.desktop):
        if name.lower().startswith('gl'):
            val1 = getattr(gl, name)
            val2 = getattr(gl.desktop, name)
            assert_is(val1, val2)
예제 #5
0
def test_wrappers():
    """Test gloo wrappers"""
    with Canvas():
        gl.use('desktop debug')
        # check presets
        assert_raises(ValueError, gloo.set_state, preset='foo')
        for state in gloo.get_state_presets().keys():
            gloo.set_state(state)
        assert_raises(ValueError, gloo.set_blend_color, (0., 0.))  # bad color
        assert_raises(TypeError, gloo.set_hint, 1, 2)  # need strs
        assert_raises(TypeError, gloo.get_parameter, 1)  # need str
        # this doesn't exist in ES 2.0 namespace
        assert_raises(ValueError, gloo.set_hint, 'fog_hint', 'nicest')
        # test bad enum
        assert_raises(RuntimeError, gloo.set_line_width, -1)

        # check read_pixels
        assert_true(isinstance(gloo.read_pixels(), np.ndarray))
        assert_true(isinstance(gloo.read_pixels((0, 0, 1, 1)), np.ndarray))
        assert_raises(ValueError, gloo.read_pixels, (0, 0, 1))  # bad port

        # now let's (indirectly) check our set_* functions
        viewport = (0, 0, 1, 1)
        blend_color = (0., 0., 0.)
        _funs = dict(viewport=viewport,  # checked
                     hint=('generate_mipmap_hint', 'nicest'),
                     depth_range=(1., 2.),
                     front_face='cw',  # checked
                     cull_face='front',
                     line_width=1.,
                     polygon_offset=(1., 1.),
                     blend_func=('zero', 'one'),
                     blend_color=blend_color,
                     blend_equation='func_add',
                     scissor=(0, 0, 1, 1),
                     stencil_func=('never', 1, 2, 'back'),
                     stencil_mask=4,
                     stencil_op=('zero', 'zero', 'zero', 'back'),
                     depth_func='greater',
                     depth_mask=True,
                     color_mask=(True, True, True, True),
                     sample_coverage=(0.5, True))
        gloo.set_state(**_funs)
        gloo.clear((1., 1., 1., 1.), 0.5, 1)
        gloo.flush()
        gloo.finish()
        # check some results
        assert_array_equal(gloo.get_parameter('viewport'), viewport)
        assert_equal(gloo.get_parameter('front_face'), gl.GL_CW)
        assert_equal(gloo.get_parameter('blend_color'), blend_color + (1,))
예제 #6
0
파일: test_app.py 프로젝트: kif/vispy
import sys

from numpy.testing import assert_array_equal
from nose.tools import assert_equal, assert_true, assert_raises

from vispy.app import Application, Canvas, Timer, MouseEvent, KeyEvent
from vispy.app.base import BaseApplicationBackend
from vispy.util.testing import requires_pyglet, requires_qt, requires_glfw, requires_glut, requires_application  # noqa

from vispy.gloo.program import Program, VertexBuffer, IndexBuffer
from vispy.gloo.shader import VertexShader, FragmentShader
from vispy.util.testing import assert_in, assert_is
from vispy.gloo.util import _screenshot
from vispy.gloo import gl

gl.use("desktop debug")


def on_nonexist(self, *args):
    return


def on_mouse_move(self, *args):
    return


def _on_mouse_move(self, *args):
    return


def _test_callbacks(canvas):
예제 #7
0
def teardown_module():
    gl.use()  # Reset to default
예제 #8
0
 def tearDown(self):
     gl.use('desktop')
예제 #9
0
 def tearDown(self):
     gl.use('desktop')
예제 #10
0
from time import sleep

from numpy.testing import assert_array_equal
from nose.tools import assert_equal, assert_true, assert_raises

from vispy.app import default_app, Canvas, Timer, MouseEvent, KeyEvent
from vispy.app.base import BaseApplicationBackend
from vispy.testing import requires_application, SkipTest, assert_is, assert_in
from vispy.util import keys, use_log_level

from vispy.gloo.program import (Program, VertexBuffer, IndexBuffer)
from vispy.gloo.shader import VertexShader, FragmentShader
from vispy.gloo.util import _screenshot
from vispy.gloo import gl

gl.use('desktop debug')


def on_nonexist(self, *args):
    return


def on_mouse_move(self, *args):
    return


def _on_mouse_move(self, *args):
    return


def _test_callbacks(canvas):