Esempio n. 1
0
    def key_event(self, key, action, modifiers):
        keys = self.wnd.keys

        # Key presses
        if action == keys.ACTION_PRESS:
            if key == keys.F1:
                screenshot.create(self.fbo_1)
Esempio n. 2
0
 def key_event(self, key, action, modifiers):
     self.camera.key_event(key, action, modifiers)
     keys = self.wnd.keys
     if action == keys.ACTION_PRESS:
         if key == keys.Q:
             self.wnd.close()
         elif key == keys.U:
             self.update()
         elif key == keys.P:
             self.ctx.fbo.viewport = self.wnd.viewport[:2] + self.wnd.size
             screenshot.create(self.ctx.fbo)
         elif key == keys.TAB:
             self.ctx.wireframe = not self.ctx.wireframe
         elif key in self.shaderkeys:
             self.shaderkeys[key]()
         else:
             parameters = getattr(self.source, 'parameters', {})
             operation = parameters.get(key)
             if operation is not None:
                 operation(key, action, modifiers)
                 self.update()
Esempio n. 3
0
    def render(self, time, frame_time):

        if self.simulated_time - self._last_capture > self.gif_interval:
            # render the result to the screen
            self.ctx.clear(51 / 255, 51 / 255, 51 / 255)
            self.ctx.enable(moderngl.BLEND)
            self.render_vao.render(self.render_program, mode=moderngl.POINTS)

            # take a screenshot
            screenshot.create(self.wnd.fbo)
            self._last_capture = self.simulated_time

        # run the compute shader
        self.calculate_force.run(group_x=self.NUM_GROUP)
        # swap buffers
        self._swap_buffers()
        # run the compute shader
        self.move_planets.run(group_x=self.NUM_GROUP)
        # swap buffers
        self._swap_buffers()

        self.simulated_time += self.consts['DT']
Esempio n. 4
0
    def key_event(self, key, action, modifiers):
        keys = self.wnd.keys

        if action == keys.ACTION_PRESS and key == keys.F1:
            screenshot.create(self.wnd.fbo)
Esempio n. 5
0
 def test_fbo(self):
     """Create screenshot from fbo"""
     screenshot.create(self.window.fbo)
Esempio n. 6
0
 def test_incorrect_source(self):
     """Attempt to pass invalid source"""
     with self.assertRaises(ValueError):
         screenshot.create("Hello")
Esempio n. 7
0
 def test_texture(self):
     """Create screenshot from texture"""
     texture = self.ctx.texture((16, 16), 4)
     screenshot.create(texture)