Exemple #1
0
    def __init__(self):
        app.Canvas.__init__(self)
        self.size = 800, 600

        # Create program
        self._program = oogl.Program(VERT_SHADER, FRAG_SHADER)
        self._program.set_vars(data.data, s_texture=oogl.Texture2D(im1))

        # Create first explosion
        self._new_explosion()
Exemple #2
0
 def __init__(self):
     app.Canvas.__init__(self)
     
     # Create program
     self._program = oogl.Program( VERT_SHADER, FRAG_SHADER)
     
     # Creat FBO
     self._fbo = oogl.FrameBuffer()
     self._fbo.attach_depth(oogl.RenderBuffer(im1.shape))
     
     # Create vbo
     self._vbo = oogl.VertexBuffer(vertex_data)
     
     # Create textures 
     self._tex1 = oogl.Texture2D(im1)
     self._tex2 = oogl.Texture2D(im1.shape)
     for tex in (self._tex1, self._tex2):
         tex.set_filter('NEAREST', 'NEAREST')
     
     
     # Set uniforms and attributes
     self._program.set_vars(self._vbo)
     self._program['u_texsize'] = im1.shape[1], im1.shape[0]
Exemple #3
0
    def __init__(self):
        app.Canvas.__init__(self)

        # Create program
        self._program = oogl.Program(VERT_SHADER, FRAG_SHADER)

        # Create vertex buffer
        self._vbo = oogl.VertexBuffer(vertex_data)

        # Set uniforms, samplers, attributes
        # We create one VBO with all vertex data (array of structures)
        # and create two views from it for the attributes.
        self._program['texture1'] = oogl.Texture2D(im1)
        self._program.set_vars(self._vbo)  # This does:
Exemple #4
0
    def __init__(self):
        app.Canvas.__init__(self)

        self.geometry = 0, 0, 400, 400

        # Create program
        self._program = oogl.ShaderProgram(oogl.VertexShader(VERT_SHADER),
                                           oogl.FragmentShader(FRAG_SHADER))

        # Create vbo
        self._vbo = oogl.VertexBuffer(vertex_data)

        # Set uniforms, samplers, attributes
        self._program.attributes.update(self._vbo)
        self._program.uniforms['s_texture'] = oogl.Texture2D(im1)

        # Create first explosion
        self._new_explosion()
Exemple #5
0
    def __init__(self, **kwargs):
        app.Canvas.__init__(self, **kwargs)
        self.geometry = 0, 0, 400, 400

        self.program = oogl.Program(VERT_CODE, FRAG_CODE)

        # Set attributes
        self.program['a_position'] = oogl.VertexBuffer(positions)
        self.program['a_texcoord'] = oogl.VertexBuffer(texcoords)

        self.program['u_texture'] = oogl.Texture2D(io.crate())

        # Handle transformations
        self.init_transforms()

        self.timer = app.Timer(1.0 / 60)
        self.timer.connect(self.update_transforms)
        self.timer.start()
Exemple #6
0
    def __init__(self):
        app.Canvas.__init__(self)
        self.size = W*5,H*5

        self.program = oogl.Program(VERT_SHADER, FRAG_SHADER)
        self.texture = oogl.Texture2D(I)
        self.texture.set_filter(gl.GL_NEAREST, gl.GL_NEAREST)
        
        self.program['u_texture'] = self.texture
        self.program.set_vars(oogl.VertexBuffer(data))

        self.view = np.eye(4,dtype=np.float32)
        self.model = np.eye(4,dtype=np.float32)
        self.projection = np.eye(4,dtype=np.float32)

        self.program['u_model'] = self.model
        self.program['u_view'] = self.view
        self.projection = ortho(0, W, 0, H, -1, 1)
        self.program['u_projection'] = self.projection
Exemple #7
0
    def __init__(self):
        app.Canvas.__init__(self)
        self.size = 560, 420

        # Create texture to render to
        self._rendertex = oogl.Texture2D()

        # Create FBO, attach the color buffer and depth buffer
        self._fbo = oogl.FrameBuffer(self._rendertex, oogl.RenderBuffer())

        # Create program to render a shape
        self._program1 = oogl.Program(oogl.VertexShader(VERT_SHADER1),
                                      oogl.FragmentShader(FRAG_SHADER1))
        self._program1['u_color'] = 0.9, 1.0, 0.4, 1
        self._program1['a_position'] = oogl.VertexBuffer(vPosition)

        # Create program to render FBO result
        self._program2 = oogl.Program(oogl.VertexShader(VERT_SHADER2),
                                      oogl.FragmentShader(FRAG_SHADER2))
        self._program2['a_position'] = oogl.VertexBuffer(vPosition)
        self._program2['a_texcoord'] = oogl.VertexBuffer(vTexcoord)
        self._program2['u_texture1'] = self._rendertex
Exemple #8
0
    def __init__(self):
        app.Canvas.__init__(self)
        self.size = 800, 600
        self.title = "A very fake galaxy [mouse scroll to zoom]"

        self.program = oogl.Program(VERT_SHADER, FRAG_SHADER)
        self.view = np.eye(4, dtype=np.float32)
        self.model = np.eye(4, dtype=np.float32)
        self.projection = np.eye(4, dtype=np.float32)
        self.theta, self.phi = 0, 0

        self.translate = 5
        translate(self.view, 0, 0, -self.translate)

        self.program.set_vars(data.data,
                              u_colormap=oogl.Texture2D(cmap),
                              u_size=5. / self.translate,
                              u_model=self.model,
                              u_view=self.view)

        self.timer = app.Timer(1.0 / 60)
        self.timer.connect(self.on_timer)