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"
fragment = """ #version 120 uniform vec4 color; void main() { gl_FragColor = color; } """ # No GL context required # ---------------------- program = Program(vertex,fragment) frag = FragmentShader("uniform int dummy;") print("Attaching shader") program.attach(frag) print("Dettaching shader") program.detach(frag) print("Uniforms: %s" % program.all_uniforms) print("Attributes: %s" % program.all_attributes) print("Shaders: %s" % program.shaders) print("Program status: %s" % ( "dirty (needs new build) " if program.dirty else "clean")) print("Setting color") program['color'] = 1,1,1,1 # This should raise a ProgramException # print("Setting unknown variable") # program['position'] = 1,1,1,1
fragment = """ #version 120 uniform vec4 color; void main() { gl_FragColor = color; } """ # No GL context required # ---------------------- program = Program(vertex, fragment) frag = FragmentShader("uniform int dummy;") print("Attaching shader") program.attach(frag) print("Dettaching shader") program.detach(frag) print("Uniforms: %s" % program.all_uniforms) print("Attributes: %s" % program.all_attributes) print("Shaders: %s" % program.shaders) print("Program status: %s" % ("dirty (needs new build) " if program.dirty else "clean")) print("Setting color") program["color"] = 1, 1, 1, 1 # This should raise a ProgramException # print("Setting unknown variable") # program['position'] = 1,1,1,1