File: accumulate.py

package info (click to toggle)
glitch 0.6-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 488 kB
  • ctags: 649
  • sloc: python: 3,432; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 768 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

import OpenGL.GL as gl

import glitch, glitch.gtk
from glitch.limbo.objects import make_lit_test_scene

class Accumulate(glitch.Node):
    def render(self, ctx):
        gl.glClear(gl.GL_ACCUM_BUFFER_BIT)

        for child in self.children:
            gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
            child.render(ctx)
            gl.glAccum(gl.GL_ACCUM, 1.0 / len(self.children))

        gl.glAccum(gl.GL_RETURN, 1.0)

if __name__ == '__main__':
    scene = make_lit_test_scene()
    scene_x = glitch.Rotate(0.5, 0, 1, 0, children=[scene])
    scene_y = glitch.Rotate(0.5, 1, 0, 0, children=[scene])
    camera = glitch.gtk.GtkMovingCamera(eye=[0, 2, 3], children=[
        Accumulate(children=[scene, scene_x, scene_y])])
    camera.run()