コード例 #1
0
ファイル: line-collection.py プロジェクト: vispy/experimental
def on_display():
    gl.glClearColor(1, 1, 1, 1)
    gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
    gl.glEnable(gl.GL_BLEND)

    shader.bind()

    shader.uniformi('uniforms', 0)
    shape = collection.uniforms_shape or (1, 1)
    shader.uniformf('uniforms_shape', shape[0], shape[1])
    gl.glActiveTexture(gl.GL_TEXTURE0)
    gl.glBindTexture(gl.GL_TEXTURE_2D, collection.uniforms_id)

    _, _, width, height = gl.glGetIntegerv(gl.GL_VIEWPORT)
    P = orthographic(0, width, 0, height, -1, +1)
    V = np.eye(4).astype(np.float32)
    M = np.eye(4).astype(np.float32)
    shader.uniform_matrixf('M', M)
    shader.uniform_matrixf('V', V)
    shader.uniform_matrixf('P', P)
    collection.draw()
    shader.unbind()

    glut.glutSwapBuffers()
コード例 #2
0
ファイル: collection.py プロジェクト: x2nie/gl-agg
    def draw(self):
        if self._dirty:
            self.upload()

        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
        gl.glEnable(gl.GL_BLEND)
        _, _, width, height = gl.glGetIntegerv(gl.GL_VIEWPORT)
        P = orthographic(0, width, 0, height, -1, +1)
        V = np.eye(4).astype(np.float32)
        M = np.eye(4).astype(np.float32)

        shader = self.shader
        shader.bind()
        gl.glActiveTexture(gl.GL_TEXTURE0)
        shader.uniformi('u_uniforms', 0)
        gl.glBindTexture(gl.GL_TEXTURE_2D, self._ubuffer_id)
        if self.dash_atlas:
            gl.glActiveTexture(gl.GL_TEXTURE1)
            shader.uniformi('u_dash_atlas', 1)
            gl.glBindTexture(gl.GL_TEXTURE_2D, self.dash_atlas.texture_id)
        shader.uniform_matrixf('u_M', M)
        shader.uniform_matrixf('u_V', V)
        shader.uniform_matrixf('u_P', P)
        shape = self._ubuffer_shape
        shader.uniformf('u_uniforms_shape', shape[1] // 4, shape[0])
        self._vbuffer.draw()
        shader.unbind()
コード例 #3
0
def on_display():
    gl.glClearColor(1,1,1,1);
    gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
    gl.glEnable(gl.GL_BLEND)

    shader.bind()

    shader.uniformi( 'uniforms', 0 )
    shape = collection.uniforms_shape or (1,1)
    shader.uniformf( 'uniforms_shape', shape[0], shape[1])
    gl.glActiveTexture( gl.GL_TEXTURE0 )
    gl.glBindTexture( gl.GL_TEXTURE_2D, collection.uniforms_id )

    _,_,width,height = gl.glGetIntegerv( gl.GL_VIEWPORT )
    P = orthographic( 0, width, 0, height, -1, +1 )
    V = np.eye(4).astype( np.float32 )
    M = np.eye(4).astype( np.float32 )
    shader.uniform_matrixf( 'M', M )
    shader.uniform_matrixf( 'V', V )
    shader.uniform_matrixf( 'P', P )
    collection.draw( )
    shader.unbind()

    glut.glutSwapBuffers()
コード例 #4
0
ファイル: collection.py プロジェクト: Eric89GXL/gl-agg
    def draw(self):
        if self._dirty:
            self.upload()

        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
        gl.glEnable(gl.GL_BLEND)
        _,_,width,height = gl.glGetIntegerv( gl.GL_VIEWPORT )
        P = orthographic( 0, width, 0, height, -1, +1 )
        V = np.eye(4).astype( np.float32 )
        M = np.eye(4).astype( np.float32 )

        shader = self.shader
        shader.bind()
        gl.glActiveTexture( gl.GL_TEXTURE0 )
        shader.uniformi( 'u_uniforms', 0 )
        gl.glBindTexture( gl.GL_TEXTURE_2D, self._ubuffer_id )
        if self.dash_atlas:
            gl.glActiveTexture( gl.GL_TEXTURE1 )
            shader.uniformi('u_dash_atlas', 1)
            gl.glBindTexture( gl.GL_TEXTURE_2D, self.dash_atlas.texture_id )
        shader.uniform_matrixf( 'u_M', M )
        shader.uniform_matrixf( 'u_V', V )
        shader.uniform_matrixf( 'u_P', P )
        shape = self._ubuffer_shape
        shader.uniformf( 'u_uniforms_shape', shape[1]//4, shape[0])
        self._vbuffer.draw( )
        shader.unbind()
コード例 #5
0
 def draw(self):
     self.set_options()
     
     # WARNING: THIS IS TERRIBLY INEFFICIENT BECAUSE ALL DATA
     # IS SENT ON GPU AT EVERY REFRESH!!!
     # We need to put this stuff at initialization time.
     self._program._create()
     self._program._build()  # attributes / uniforms are not available until program is built
     
     self._program.bind(gloo.VertexBuffer(self._V))
     for n, v in uniforms.iteritems():
         self._program[n] = v
         
     # WARNING/TODO: put the different sets of uniforms and put them in attributes instead
     for n, v in self._U[0].iteritems():
         self._program[n] = v
         
     self._program['tr_scale'] = self._parent.panzoom.scale[:2]
         
     self._program['u_dash_atlas'] = gloo.Texture2D(self._collec.da._data)
     width, height = self.width, self.height
     self._program['u_scale'] = width//2, height//2
     self._program['u_proj'] = orthographic( -width//2, width//2, 
                                             -height//2, height//2, -1, +1 )
     
     self._program.draw('triangles', indices=self.index)
コード例 #6
0
ファイル: line_agg.py プロジェクト: vispy/experimental
 def on_resize(self, event):
     self.width, self.height = event.size
     gloo.set_viewport(0, 0, self.width, self.height)
     self.program['u_proj'] = orthographic(-self.width // 2,
                                           self.width // 2,
                                           -self.height // 2,
                                           self.height // 2, -1, +1),
コード例 #7
0
    def draw(self):
        self.set_options()

        # WARNING: THIS IS TERRIBLY INEFFICIENT BECAUSE ALL DATA
        # IS SENT ON GPU AT EVERY REFRESH!!!
        # We need to put this stuff at initialization time.
        self._program._create()
        self._program._build(
        )  # attributes / uniforms are not available until program is built

        self._program.bind(gloo.VertexBuffer(self._V))
        for n, v in uniforms.iteritems():
            self._program[n] = v

        # WARNING/TODO: put the different sets of uniforms and put them in attributes instead
        for n, v in self._U[0].iteritems():
            self._program[n] = v

        self._program['tr_scale'] = self._parent.panzoom.scale[:2]

        self._program['u_dash_atlas'] = gloo.Texture2D(self._collec.da._data)
        width, height = self.width, self.height
        self._program['u_scale'] = width // 2, height // 2
        self._program['u_proj'] = orthographic(-width // 2, width // 2,
                                               -height // 2, height // 2, -1,
                                               +1)

        self._program.draw('triangles', indices=self.index)
コード例 #8
0
ファイル: line-uniform.py プロジェクト: tatak/experimental
def on_display():
    gl.glClearColor(1, 1, 1, 1)
    gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
    gl.glEnable(gl.GL_BLEND)

    shader.bind()
    _, _, width, height = gl.glGetIntegerv(gl.GL_VIEWPORT)
    P = orthographic(0, width, 0, height, -1, +1)
    V = np.eye(4).astype(np.float32)
    M = np.eye(4).astype(np.float32)
    shader.uniform_matrixf("M", M)
    shader.uniform_matrixf("V", V)
    shader.uniform_matrixf("P", P)
    shader.uniformf("width", 1.0)
    shader.uniformf("blur", 1.0)
    shader.uniformf("color", 0.0, 0.0, 0.0, 1.0)
    shader.uniformf("miter_limit", 4.0)
    line.draw()
    shader.unbind()
    glut.glutSwapBuffers()
コード例 #9
0
ファイル: line-uniform.py プロジェクト: vispy/experimental
def on_display():
    gl.glClearColor(1,1,1,1);
    gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
    gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
    gl.glEnable(gl.GL_BLEND)

    shader.bind()
    _,_,width,height = gl.glGetIntegerv( gl.GL_VIEWPORT )
    P = orthographic( 0, width, 0, height, -1, +1 )
    V = np.eye(4).astype( np.float32 )
    M = np.eye(4).astype( np.float32 )
    shader.uniform_matrixf( 'M', M )
    shader.uniform_matrixf( 'V', V )
    shader.uniform_matrixf( 'P', P )
    shader.uniformf( 'width', 1.0 )
    shader.uniformf( 'blur',  1.0 )
    shader.uniformf( 'color',  0.0, 0.0, 0.0, 1.0)
    shader.uniformf( 'miter_limit',  4.0 )
    line.draw( )
    shader.unbind()
    glut.glutSwapBuffers()
コード例 #10
0
ファイル: line_agg.py プロジェクト: gabr1e11/GLSL-Examples
 def on_resize(self, event):
     self.width, self.height = event.size
     gloo.set_viewport(0, 0, self.width, self.height)
     self.program['u_proj'] = orthographic( -self.width//2, self.width//2, -self.height//2, self.height//2, -1, +1 ),