allow running without using the gui
[mussa.git] / py / gl.py
1 """Can we show a mussa gl object?
2 """
3 import sys
4
5 from OpenGL.GLUT import *
6 from OpenGL.GL import *
7 import mussa
8
9   
10 class pyMussaGL:
11   def __init__(self):
12     self.s = "AAGGCCTT" * 5
13     self.seq = mussa.Sequence(self.s)
14     self.glseq = mussa.GlSequence(self.seq)
15     print self.glseq.width
16
17     glutInit(sys.argv)
18     glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH )
19     glutCreateWindow('mussa')
20     glClearColor(1,1,1,0)
21
22     glOrtho(-10, len(self.s)+10, -50, 50, -50, 50)
23
24     glutDisplayFunc(self.display)
25     print "init done"
26   
27   def display(self):
28     glClear(GL_COLOR_BUFFER_BIT)
29     self.glseq.draw(-50, self.glseq.width+50)
30     #glutSwapBuffers()
31
32 if __name__ == "__main__":
33   p = pyMussaGL()
34   glutMainLoop()