450b1bd0e4f5e9f690894b66d96807d8ba5769e1
[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     """Initalize our data and our glut window"""
13     # make up a simple sequence
14     self.s = "AAGGCCTT" * 5
15     self.seq = mussa.Sequence(self.s)
16     # AnnotationColors is required, even though it'd be nice
17     # if it were optional
18     self.glseq = mussa.GlSequence(self.seq, mussa.AnnotationColors())
19     assert len(self.s) == self.glseq.length
20
21     # set up opengl buffer
22     glutInit(sys.argv)
23     glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH )
24     glutCreateWindow('mussa')
25     glClearColor(1,1,1,0)
26
27     glOrtho(-10, len(self.s)+10, -50, 50, -50, 50)
28
29     glutDisplayFunc(self.display)
30     print "init done"
31   
32   def display(self):
33     """Update showing buffer"""
34     glClear(GL_COLOR_BUFFER_BIT)
35     self.glseq.draw(-50, self.glseq.width+50)
36     #glutSwapBuffers()
37
38 if __name__ == "__main__":
39   p = pyMussaGL()
40   glutMainLoop()