Exemple #1
0
def _test_setting_stuff():
    # Set stuff to touch functions

    gl.glClear(gl.GL_COLOR_BUFFER_BIT)
    #
    gl.glBlendColor(1.0, 1.0, 1.0, 1.0)
    gl.glBlendEquation(gl.GL_FUNC_ADD)
    gl.glBlendEquationSeparate(gl.GL_FUNC_ADD, gl.GL_FUNC_ADD)
    gl.glBlendFunc(gl.GL_ONE, gl.GL_ZERO)
    gl.glBlendFuncSeparate(gl.GL_ONE, gl.GL_ZERO, gl.GL_ONE, gl.GL_ZERO)
    #
    gl.glClearColor(0.0, 0.0, 0.0, 1.0)
    gl.glClearDepth(1)
    gl.glClearStencil(0)
    #
    gl.glColorMask(True, True, True, True)
    gl.glDepthMask(False)
    gl.glStencilMask(255)
    gl.glStencilMaskSeparate(gl.GL_FRONT, 128)
    #
    gl.glStencilFunc(gl.GL_ALWAYS, 0, 255)
    gl.glStencilFuncSeparate(gl.GL_FRONT, gl.GL_ALWAYS, 0, 255)
    gl.glStencilOp(gl.GL_KEEP, gl.GL_KEEP, gl.GL_KEEP)
    gl.glStencilOpSeparate(gl.GL_FRONT, gl.GL_KEEP, gl.GL_KEEP, gl.GL_KEEP)
    #
    gl.glFrontFace(gl.GL_CW)
    gl.glHint(gl.GL_GENERATE_MIPMAP_HINT, gl.GL_FASTEST)
    gl.glLineWidth(2.0)
    gl.glPolygonOffset(0.0, 0.0)
    gl.glSampleCoverage(1.0, False)

    # And getting stuff
    try:
        with use_log_level('error', print_msg=False):
            r, p = gl.glGetShaderPrecisionFormat(gl.GL_FRAGMENT_SHADER,
                                                 gl.GL_HIGH_FLOAT)
            gl.check_error()  # Sometimes the func is there but OpenGL errs
    except Exception:
        pass  # accept if the function is not there ...
        # We should catch RuntimeError and GL.error.NullFunctionError,
        # but PyOpenGL may not be available.
        # On Travis this function was not there on one machine according
        # to PyOpenGL, but our desktop backend worked fine ...

    #
    v = gl.glGetParameter(gl.GL_VERSION)
    assert_true(isinstance(v, string_types))
    assert_true(len(v) > 0)

    gl.check_error()
Exemple #2
0
def _test_setting_stuff():
    # Set stuff to touch functions
    
    gl.glClear(gl.GL_COLOR_BUFFER_BIT)
    #
    gl.glBlendColor(1.0, 1.0, 1.0, 1.0)
    gl.glBlendEquation(gl.GL_FUNC_ADD)
    gl.glBlendEquationSeparate(gl.GL_FUNC_ADD, gl.GL_FUNC_ADD)
    gl.glBlendFunc(gl.GL_ONE, gl.GL_ZERO)
    gl.glBlendFuncSeparate(gl.GL_ONE, gl.GL_ZERO, gl.GL_ONE, gl.GL_ZERO)
    #
    gl.glClearColor(0.0, 0.0, 0.0, 1.0)
    gl.glClearDepth(1)
    gl.glClearStencil(0)
    #
    gl.glColorMask(True, True, True, True)
    gl.glDepthMask(False)
    gl.glStencilMask(255)
    gl.glStencilMaskSeparate(gl.GL_FRONT, 128)
    #
    gl.glStencilFunc(gl.GL_ALWAYS, 0, 255)
    gl.glStencilFuncSeparate(gl.GL_FRONT, gl.GL_ALWAYS, 0, 255)
    gl.glStencilOp(gl.GL_KEEP, gl.GL_KEEP, gl.GL_KEEP)
    gl.glStencilOpSeparate(gl.GL_FRONT, gl.GL_KEEP, gl.GL_KEEP, gl.GL_KEEP)
    #
    gl.glFrontFace(gl.GL_CW)
    gl.glHint(gl.GL_GENERATE_MIPMAP_HINT, gl.GL_FASTEST)
    gl.glLineWidth(2.0)
    gl.glPolygonOffset(0.0, 0.0)
    gl.glSampleCoverage(1.0, False)
    
    # And getting stuff
    try:
        with use_log_level('error', print_msg=False):
            r, p = gl.glGetShaderPrecisionFormat(gl.GL_FRAGMENT_SHADER,
                                                 gl.GL_HIGH_FLOAT)
            gl.check_error()  # Sometimes the func is there but OpenGL errs
    except Exception:
        pass  # accept if the function is not there ...
        # We should catch RuntimeError and GL.error.NullFunctionError,
        # but PyOpenGL may not be available.
        # On Travis this function was not there on one machine according
        # to PyOpenGL, but our desktop backend worked fine ...
        
    #
    v = gl.glGetParameter(gl.GL_VERSION)
    assert_true(isinstance(v, string_types))
    assert_true(len(v) > 0)
    
    gl.check_error()
Exemple #3
0
    def on_draw(self, event):
        """ canvas update callback """

        # Clear depth and color buffers
        gloo.clear(color=C0)

        # Filled cube
        gloo.set_state(depth_test=True, blend=True, depth_mask=False)
        #gloo.set_depth_mask(False)
        #gl.glEnable(gl.GL_DEPTH_TEST)
        #gl.glDepthMask(gl.GL_FALSE)
        #gl.glEnable(gl.GL_BLEND)

        #
        self.quads['u_pass'] = 0.0
        self.framebuffer.color_buffer = self.accum
        self.framebuffer.activate()
        gloo.clear(color=(0, 0, 0, 0))
        #gloo.set_blend_func('one', 'one')
        #gl.glBlendFunc(gl.GL_ONE, gl.GL_ONE)
        gl.glBlendFuncSeparate(gl.GL_ONE, gl.GL_ONE,
                               gl.GL_ONE, gl.GL_ONE)
        self.quads.draw('triangles', self.indices)
        self.framebuffer.deactivate()

        #
        self.quads['u_pass'] = 1.0
        self.framebuffer.color_buffer = self.reveal
        self.framebuffer.activate()
        gloo.clear(color=(1, 1, 1, 1))
        #gloo.set_blend_func('zero', 'one_minus_src_color')
        #gl.glBlendFunc(gl.GL_ZERO, gl.GL_ONE_MINUS_SRC_COLOR)
        gl.glBlendFuncSeparate(gl.GL_ZERO, gl.GL_ONE_MINUS_SRC_COLOR,
                               gl.GL_ZERO, gl.GL_ONE_MINUS_SRC_COLOR)
        self.quads.draw('triangles', self.indices)
        self.framebuffer.deactivate()

        # Filled cube
        #gloo.set_blend_func('src_alpha', 'one_minus_src_alpha')
        gl.glBlendFuncSeparate(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA,
                               gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
        # gloo.set_state('translucent', blend=True, depth_test=False)
        self.post.draw('triangle_strip', self.indices)
Exemple #4
0
    def on_draw(self, event):
        """ canvas update callback """

        # Clear depth and color buffers
        gloo.clear(color=C0)

        # Filled cube
        gloo.set_state(depth_test=True, blend=True, depth_mask=False)
        #gloo.set_depth_mask(False)
        #gl.glEnable(gl.GL_DEPTH_TEST)
        #gl.glDepthMask(gl.GL_FALSE)
        #gl.glEnable(gl.GL_BLEND)

        #
        self.quads['u_pass'] = 0.0
        self.framebuffer.color_buffer = self.accum
        self.framebuffer.activate()
        gloo.clear(color=(0, 0, 0, 0))
        #gloo.set_blend_func('one', 'one')
        #gl.glBlendFunc(gl.GL_ONE, gl.GL_ONE)
        gl.glBlendFuncSeparate(gl.GL_ONE, gl.GL_ONE, gl.GL_ONE, gl.GL_ONE)
        self.quads.draw('triangles', self.indices)
        self.framebuffer.deactivate()

        #
        self.quads['u_pass'] = 1.0
        self.framebuffer.color_buffer = self.reveal
        self.framebuffer.activate()
        gloo.clear(color=(1, 1, 1, 1))
        #gloo.set_blend_func('zero', 'one_minus_src_color')
        #gl.glBlendFunc(gl.GL_ZERO, gl.GL_ONE_MINUS_SRC_COLOR)
        gl.glBlendFuncSeparate(gl.GL_ZERO, gl.GL_ONE_MINUS_SRC_COLOR,
                               gl.GL_ZERO, gl.GL_ONE_MINUS_SRC_COLOR)
        self.quads.draw('triangles', self.indices)
        self.framebuffer.deactivate()

        # Filled cube
        #gloo.set_blend_func('src_alpha', 'one_minus_src_alpha')
        gl.glBlendFuncSeparate(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA,
                               gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
        # gloo.set_state('translucent', blend=True, depth_test=False)
        self.post.draw('triangle_strip', self.indices)