Exemple #1
0
def test_opengl_state_simple():
    for gl_state in [
            window.gl_reset_blend, window.gl_enable_depth,
            window.gl_disable_depth, window.gl_enable_blend,
            window.gl_disable_blend, window.gl_set_additive_blending,
            window.gl_set_normal_blending,
            window.gl_set_multiplicative_blending,
            window.gl_set_subtractive_blending,
            window.gl_set_additive_blending_white_background
    ]:
        scene = window.Scene()
        centers = np.array([[0, 0, 0], [-.1, 0, 0], [.1, 0, 0]])
        colors = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])

        actors = actor.markers(
            centers,
            marker='s',
            colors=colors,
            marker_opacity=.5,
            scales=.2,
        )
        showm = window.ShowManager(scene,
                                   size=(900, 768),
                                   reset_camera=False,
                                   order_transparent=False)

        scene.add(actors)
        # single effect
        shaders.shader_apply_effects(showm.window, actors, effects=gl_state)
        showm.render()
def timer_callback(obj, event):
    cnt = next(counter)
    showm.render()
    # we will rotate the visualization just to help you to see
    # the results of each specifc opengl-state
    showm.scene.azimuth(1)
    if cnt == 400:
        remove_observer_from_actor(actor_no_depth_test, id_observer)
        shader_apply_effects(showm.window,
                             actor_no_depth_test,
                             effects=window.gl_set_additive_blending)
    if cnt == 1000:
        showm.exit()
Exemple #3
0
def test_opengl_state_add_remove_and_check():
    scene = window.Scene()
    centers = np.array([
        [0, 0, 0],
        [-.1, 0, 0],
        [.1, 0, 0]
    ])
    colors = np.array([
        [1, 0, 0],
        [0, 1, 0],
        [0, 0, 1]
    ])

    actor_no_depth_test = actor.markers(
        centers,
        marker='s',
        colors=colors,
        marker_opacity=.5,
        scales=.2,
    )
    showm = window.ShowManager(
        scene,
        size=(900, 768), reset_camera=False,
        order_transparent=False)

    scene.add(actor_no_depth_test)

    showm.render()
    state = window.gl_get_current_state(showm.window.GetState())
    before_depth_test = state['GL_DEPTH_TEST']
    npt.assert_equal(before_depth_test, True)
    # TODO: we are getting bad request for enum status
    # it seems we are not provide the correct values
    # vtkOpenGLState.cxx:1299  WARN| Bad request for enum status
    id_observer = shaders.shader_apply_effects(
        showm.window, actor_no_depth_test,
        effects=[
            window.gl_reset_blend, window.gl_disable_blend,
            window.gl_disable_depth])

    showm.render()
    state = window.gl_get_current_state(showm.window.GetState())
    # print('type', type(showm.window.GetState()))
    after_depth_test = state['GL_DEPTH_TEST']
    npt.assert_equal(after_depth_test, False)
    # removes the no_depth_test effect
    remove_observer_from_actor(actor_no_depth_test, id_observer)
    showm.render()
    state = window.gl_get_current_state(showm.window.GetState())
    after_remove_depth_test_observer = state['GL_DEPTH_TEST']
    npt.assert_equal(after_remove_depth_test_observer, True)
scene.add(actor_no_depth_test)
scene.add(actor_normal_blending)
scene.add(actor_add_blending)
scene.add(actor_sub_blending)
scene.add(actor_mul_blending)
###############################################################################
# Now, we will enter in the topic of this example. First, we need to create
# (or use one of the pre-built gl_function of FURY) to
# change the OpenGL state of a given fury window instance (showm.window).
#
# Here we're using the pre-build FURY window functions which has already a
# set of  specific behaviors to  be applied in the OpenGL context

shader_apply_effects(showm.window,
                     actor_normal_blending,
                     effects=window.gl_set_normal_blending)

# ###############################################################################
#  It's also possible use a list of effects. The final opengl state it'll
#  be the composition of each effect that each function has in the opengl state

id_observer = shader_apply_effects(showm.window,
                                   actor_no_depth_test,
                                   effects=[
                                       window.gl_reset_blend,
                                       window.gl_disable_blend,
                                       window.gl_disable_depth
                                   ])

shader_apply_effects(showm.window,