Example #1
0
 def test_valid(self):
     " Test if generated programs are valid"
     prog1 = ShaderProgram.new_program()
     prog2 = ShaderProgram(8000, owned = True)
     
     self.assertTrue(prog1.valid())
     self.assertFalse(prog2.valid())
     self.assertTrue(prog1)
     self.assertFalse(prog2)
Example #2
0
 def test_freeing(self):
     " Test if programs are freed correctly "
     prog = ShaderProgram.new_program()
     vert, frag = self.get_objects()
     prog.attach(vert, frag)
     
     # Warning, borrowed_obj do not own the underlying shader so it will not be freed automatically
     borrowed_prog = ShaderProgram(glCreateProgram(), owned=False)
     
     pid = prog.pid
     pid2 = borrowed_prog.pid
     del prog
     del borrowed_prog
     gc.collect()
     
     self.assertEqual(glIsProgram(pid), GL_FALSE, 'Program was not freed')
     self.assertEqual(glIsProgram(pid2), GL_TRUE, 'Program was freed')
     self.assertFalse(vert.valid(), 'vert was not freed')
     self.assertFalse(frag.valid(), 'frag was not freed')
     
     # Free the program object
     glDeleteProgram(pid2)        
Example #3
0
 def test_eq(self):
     prog = ShaderProgram.new_program()
     prog_clone = ShaderProgram(prog.pid)
     
     self.assertEqual(prog, prog_clone, 'prog and prog clone are not equal')