Exemplo n.º 1
0
 def test_detach(self):
     vert = VertexShader("A")
     frag = FragmentShader("B")
     program = Program(vert, frag)
     program.detach(frag)
     assert len(program.shaders) == 1
     assert program.shaders[0].code == "A"
Exemplo n.º 2
0
 def test_uniform(self):
     vert = VertexShader("uniform float A;")
     frag = FragmentShader("uniform float A; uniform vec4 B;")
     program = Program(vert, frag)
     assert ("A", gl.GL_FLOAT) in program.all_uniforms
     assert ("B", gl.GL_FLOAT_VEC4) in program.all_uniforms
     assert len(program.all_uniforms) == 2
Exemplo n.º 3
0
 def test_attach(self):
     vert = VertexShader("A")
     frag = FragmentShader("B")
     program = Program(vert)
     program.attach(frag)
     assert len(program.shaders) == 2
     assert program.shaders[0].code == "A"
     assert program.shaders[1].code == "B"
Exemplo n.º 4
0
    def test_failed_build(self):
        vert = VertexShader("A")
        frag = FragmentShader("B")

        program = Program(verts=vert)
        self.assertRaises(ValueError, program.activate)

        program = Program(frags=frag)
        self.assertRaises(ValueError, program.activate)
Exemplo n.º 5
0
 def test_uniform_float(self):
     shader = VertexShader("uniform float color;")
     assert shader.uniforms == [("color", gl.GL_FLOAT)]
Exemplo n.º 6
0
 def test_delete_no_context(self):
     shader = VertexShader()
     shader.delete()
Exemplo n.º 7
0
 def test_empty_build(self):
     shader = VertexShader()
     #with self.assertRaises(RuntimeError):
     #    shader.activate()
     self.assertRaises(RuntimeError, shader.activate)
Exemplo n.º 8
0
 def test_sourcecode(self):
     code = "/* Code */"
     shader = VertexShader(code)
     assert shader.code == code
     assert shader.source == "<string>"
Exemplo n.º 9
0
 def test_init(self):
     shader = VertexShader()
     assert shader._handle == -1
     assert shader.code is None
     assert shader.source is None
Exemplo n.º 10
0
 def test_unique_shader(self):
     vert = VertexShader("A")
     frag = FragmentShader("B")
     program = Program([vert, vert], [frag, frag, frag])
     assert len(program.shaders) == 2
Exemplo n.º 11
0
 def test_attribute_float(self):
     shader = VertexShader("attribute float color;")
     assert shader.attributes == [("color", gl.GL_FLOAT)]
Exemplo n.º 12
0
    def test_setitem(self):
        vert = VertexShader("")
        frag = FragmentShader("")

        program = Program(vert, frag)
        self.assertRaises(ValueError, program.__setitem__, "A", 1)
Exemplo n.º 13
0
 def test_attributes(self):
     vert = VertexShader("attribute float A;")
     frag = FragmentShader("")
     program = Program(vert, frag)
     assert program.all_attributes == [("A", gl.GL_FLOAT)]
Exemplo n.º 14
0
 def test_uniform_vec4(self):
     shader = VertexShader("uniform vec4 color;")
     assert shader.uniforms == [("color", gl.GL_FLOAT_VEC4)]
Exemplo n.º 15
0
 def test_delete_no_context(self):
     shader = VertexShader()
     shader.delete()
Exemplo n.º 16
0
 def test_uniform_array(self):
     shader = VertexShader("uniform float color[2];")
     assert shader.uniforms == [("color[0]", gl.GL_FLOAT),
                                ("color[1]", gl.GL_FLOAT)]
Exemplo n.º 17
0
 def test_init(self):
     shader = VertexShader()
     assert shader._target == gl.GL_VERTEX_SHADER
Exemplo n.º 18
0
 def test_attribute_vec4(self):
     shader = VertexShader("attribute vec4 color;")
     assert shader.attributes == [("color", gl.GL_FLOAT_VEC4)]
Exemplo n.º 19
0
 def test_init_from_shader(self):
     program = Program(VertexShader("A"), FragmentShader("B"))
     assert len(program.shaders) == 2
     assert program.shaders[0].code == "A"
     assert program.shaders[1].code == "B"