예제 #1
0
    def display(self):
        gl.clear(gl.COLOR_BUFFER_BIT)
        # gl.color(0, 0.0625, 0.125, 1)
        # self.polyfill()

        gl.lineWidth(2)
        gl.color(0.2, 0.2, 0.05, 1)

        for power in (1, ):

            # gl.lineWidth((3 - power) ** 2)

            dx = self.width // (2**power)
            dy = self.height // (2**power)

            with gl.begin(gl.LINES):
                for x in xrange(dx, self.width, dx):
                    gl.vertex(x, 0, 0)
                    gl.vertex(x, self.height, 0)
                for y in xrange(dy, self.height, dy):
                    gl.vertex(0, y, 0)
                    gl.vertex(self.width, y, 0)


        glut.swapBuffers()
예제 #2
0
    def scan(self):

        sync_to = 0.1
        x = math.fmod(time.time(), sync_to)
        x = sync_to - x
        time.sleep(x)

        self.reset_timer()

        scan_iter = self.iter_scan()
        while True:

            try:
                next(scan_iter)
            except StopIteration:
                break

            self.tick()

            if not self.no_black:
                gl.clear(gl.COLOR_BUFFER_BIT)
                glut.swapBuffers()
                self.tick()

            if self.dropped:
                gl.color(1, 0, 0, 1)
                self.polyfill()
                glut.swapBuffers()
                time.sleep(0.5)
                return
예제 #3
0
    def display(self):

        gl.clear(gl.COLOR_BUFFER_BIT)
        gl.color(1, 1, 1, 1)


        max_bits = max(int(math.log(self.width - 1, 2)), int(math.log(self.height - 1, 2))) + 1
        assert max_bits < 16

        for power in xrange(0, self.layers):

            size = self.base_size * 2**power
            gl.lineWidth(self.base_width + 2 * power)

            v = (power + 1) / float(self.layers)
            gl.color(v, v, v, 1)

            with gl.begin(gl.LINES):
                for x in xrange(size, self.width, size):
                    gl.vertex(x, 0, 0)
                    gl.vertex(x, self.height, 0)
                for y in xrange(size, self.height, size):
                    gl.vertex(0, y, 0)
                    gl.vertex(self.width, y, 0)

        glut.swapBuffers()
예제 #4
0
    def display(self):

        gl.clear(gl.COLOR_BUFFER_BIT)
        gl.color(1, 1, 1, 1)

        max_bits = max(int(math.log(self.width - 1, 2)),
                       int(math.log(self.height - 1, 2))) + 1
        assert max_bits < 16

        for power in xrange(0, self.layers):

            size = self.base_size * 2**power
            gl.lineWidth(self.base_width + 2 * power)

            v = (power + 1) / float(self.layers)
            gl.color(v, v, v, 1)

            with gl.begin(gl.LINES):
                for x in xrange(size, self.width, size):
                    gl.vertex(x, 0, 0)
                    gl.vertex(x, self.height, 0)
                for y in xrange(size, self.height, size):
                    gl.vertex(0, y, 0)
                    gl.vertex(self.width, y, 0)

        glut.swapBuffers()
예제 #5
0
    def display(self):
    
        gl.bindFramebuffer(gl.FRAMEBUFFER, self.fbo)

        # Wipe the window.
        gl.enable('depth_test')
        gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

        gl.loadIdentity()
        
        gl.disable('texture_2d')
        self.fixed.use()
        gl.color(1, 1, 1, 1)

        for freq, offset, amp in self.curves:
            with gl.begin('line_strip'):
                for x in xrange(0, self.width + 1, 10):
                    gl.vertex(x, self.height * (0.5 + 0.5 * amp * math.sin(4 * self.frame / self.frame_rate + offset + x * freq / self.width)), 0)

        gl.bindFramebuffer(gl.FRAMEBUFFER, 0)
        gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
        gl.enable('texture_2d')
        gl.enable('depth_test')
        gl.color(1, 1, 1, 1)

        print 'I need to print so it doesnt explode.'
        self.shader.use()
        location = gl.getUniformLocation(self.shader._prog, "texture1")
        if location >= 0:
            gl.uniform1i(location, 0)
        location = gl.getUniformLocation(self.shader._prog, "width")
        if location >= 0:
            gl.uniform1f(location, float(self.width))
        location = gl.getUniformLocation(self.shader._prog, "height")
        if location >= 0:
            gl.uniform1f(location, float(self.height))
        location = gl.getUniformLocation(self.shader._prog, "dilate")
        if location >= 0:
            gl.uniform1f(location, float(self.dilate))

        with gl.begin('polygon'):
            gl.texCoord(0, 0)
            gl.vertex(0, 0)
            gl.texCoord(1, 0)
            gl.vertex(self.width, 0)
            gl.texCoord(1, 1)
            gl.vertex(self.width, self.height)
            gl.texCoord(0, 1)
            gl.vertex(0, self.height)

        glut.swapBuffers()
예제 #6
0
    def iter_scan(self):

        stages = [stage() for stage in self.stages]
        for stage in stages:
            while True:

                gl.clear(gl.COLOR_BUFFER_BIT)
                gl.color(1, 1, 1, 1)

                try:
                    next(stage)
                except StopIteration:
                    break

                glut.swapBuffers()
                yield