Ejemplo n.º 1
0
    def do_flip(self, block=True):
        # call the flip
        EventLoop.window.dispatch('on_flip')

        # TODO: use sync events instead!
        if block:
            # draw a transparent point
            # position
            glVertexAttribPointer(0, 2, GL_INT, GL_FALSE, 0,
                                  "\x00\x00\x00\x0a\x00\x00\x00\x0a")
            # color
            glVertexAttrib4f(3, 0.0, 0.0, 0.0, 0.0)
            glDrawArrays(GL_POINTS, 0, 1)

            # wait for flip then point to draw
            glFinish()

            # record the time immediately
            self.last_flip = event_time(clock.now(), 0.0)
        else:
            # we didn't block, so set to predicted flip time
            self.last_flip = event_time(self._next_flip_time, 0.0)

        # update flip times
        self._next_flip_time = self.last_flip['time'] + self.flip_interval
        self._next_draw_time = self.last_flip['time'] + self.flip_interval / 2.
        self._did_draw = False

        return self.last_flip
Ejemplo n.º 2
0
    def render(self, shader, primitiveType, offset, count, *args):
        if len(args) == 0:
            autoBind = self.autoBind
        else:
            autoBind = args[0]

        if count == 0:
            return

        if autoBind:
            self.bind(shader)

        if self.isVertexArray:
            if self.indices.getNumIndicies() > 0:
                buffer = self.indices.getBuffer()
                oldPosition = buffer.position()
                oldLimit = buffer.limit()
                buffer.position(offset)
                buffer.limit(offset + count)
                glDrawElements(primitiveType, count, GL_UNSIGNED_SHORT, buffer)
                buffer.position(oldPosition)
                buffer.limit(oldLimit)
            else:
                glDrawArrays(primitiveType, offset, count)
        else:
            raise Exception("Not Implemented!")

        if autoBind:
            self.unbind(shader)
Ejemplo n.º 3
0
    def do_flip(self, block=True):
        # call the flip
        EventLoop.window.dispatch('on_flip')

        # TODO: use sync events instead!
        if block:
            # draw a transparent point
            # position
            glVertexAttribPointer(0, 2, GL_INT, GL_FALSE, 0,
                                  "\x00\x00\x00\x0a\x00\x00\x00\x0a")
            # color
            glVertexAttrib4f(3, 0.0, 0.0, 0.0, 0.0)
            glDrawArrays(GL_POINTS, 0, 1)

            # wait for flip then point to draw
            glFinish()

            # record the time immediately
            self.last_flip = event_time(clock.now(), 0.0)
        else:
            # we didn't block, so set to predicted flip time
            self.last_flip = event_time(max(self._next_flip_time, clock.now()), 0.0)

        # update flip times
        self._next_flip_time = self.last_flip['time'] + self.flip_interval
        self._next_draw_time = self.last_flip['time'] + self.flip_interval/2.
        self._did_draw = False

        return self.last_flip
Ejemplo n.º 4
0
 def blocking_flip(self):
     EventLoop.window.dispatch("on_flip")
     # glEnableVertexAttribArray(0)  # kivy has this enabled already
     glVertexAttribPointer(0, 2, GL_INT, GL_FALSE, 0, "\x00\x00\x00\x0a\x00\x00\x00\x0a")  # Position
     glVertexAttrib4f(3, 0.0, 0.0, 0.0, 0.0)  # Color
     glDrawArrays(GL_POINTS, 0, 1)
     # glDisableVertexAttribArray(0)  # kivy needs this to stay enabled
     glFinish()
     self.last_flip = event_time(clock.now(), 0.0)
     return self.last_flip
Ejemplo n.º 5
0
 def blocking_flip(self):
     EventLoop.window.dispatch('on_flip')
     #glEnableVertexAttribArray(0)  # kivy has this enabled already
     glVertexAttribPointer(0, 2, GL_INT, GL_FALSE, 0,
                           "\x00\x00\x00\x0a\x00\x00\x00\x0a")  # Position
     glVertexAttrib4f(3, 0.0, 0.0, 0.0, 0.0)  # Color
     glDrawArrays(GL_POINTS, 0, 1)
     #glDisableVertexAttribArray(0)  # kivy needs this to stay enabled
     glFinish()
     self.last_flip = event_time(clock.now(), 0.0)
     return self.last_flip
Ejemplo n.º 6
0
    def blocking_flip(self):
        # TODO: use sync events instead!
        EventLoop.window.dispatch('on_flip')

        # draw a transparent point
        glVertexAttribPointer(0, 2, GL_INT, GL_FALSE, 0,
                              "\x00\x00\x00\x0a\x00\x00\x00\x0a")  # Position
        glVertexAttrib4f(3, 0.0, 0.0, 0.0, 0.0)  # Color
        glDrawArrays(GL_POINTS, 0, 1)

        # wait for flip and point to draw
        glFinish()

        # record the time immediately
        self.last_flip = event_time(clock.now(), 0.0)
        return self.last_flip