예제 #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"
예제 #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
예제 #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"
예제 #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)
예제 #5
0
 def test_uniform_float(self):
     shader = VertexShader("uniform float color;")
     assert shader.uniforms == [("color", gl.GL_FLOAT)]
예제 #6
0
 def test_delete_no_context(self):
     shader = VertexShader()
     shader.delete()
예제 #7
0
 def test_empty_build(self):
     shader = VertexShader()
     #with self.assertRaises(RuntimeError):
     #    shader.activate()
     self.assertRaises(RuntimeError, shader.activate)
예제 #8
0
 def test_sourcecode(self):
     code = "/* Code */"
     shader = VertexShader(code)
     assert shader.code == code
     assert shader.source == "<string>"
예제 #9
0
 def test_init(self):
     shader = VertexShader()
     assert shader._handle == -1
     assert shader.code is None
     assert shader.source is None
예제 #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
예제 #11
0
 def test_attribute_float(self):
     shader = VertexShader("attribute float color;")
     assert shader.attributes == [("color", gl.GL_FLOAT)]
예제 #12
0
    def test_setitem(self):
        vert = VertexShader("")
        frag = FragmentShader("")

        program = Program(vert, frag)
        self.assertRaises(ValueError, program.__setitem__, "A", 1)
예제 #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)]
예제 #14
0
 def test_uniform_vec4(self):
     shader = VertexShader("uniform vec4 color;")
     assert shader.uniforms == [("color", gl.GL_FLOAT_VEC4)]
예제 #15
0
파일: test_shader.py 프로젝트: jk34/glumpy
 def test_delete_no_context(self):
     shader = VertexShader()
     shader.delete()
예제 #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)]
예제 #17
0
 def test_init(self):
     shader = VertexShader()
     assert shader._target == gl.GL_VERTEX_SHADER
예제 #18
0
 def test_attribute_vec4(self):
     shader = VertexShader("attribute vec4 color;")
     assert shader.attributes == [("color", gl.GL_FLOAT_VEC4)]
예제 #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"