Store Sequence sequence location in a shared_ptr class
[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
17     # add our annotation
18     annot = mussa.annot(0, 5, "name", "type")
19     self.seq.add_annotation(annot)
20
21     # AnnotationColors is required, even though it'd be nice
22     # if it were optional
23     self.glseq = mussa.GlSequence(self.seq, mussa.AnnotationColors())
24     assert len(self.s) == self.glseq.size
25
26     # set up opengl buffer
27     glutInit(sys.argv)
28     glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH )
29     glutCreateWindow('mussa')
30     glClearColor(1,1,1,0)
31
32     glOrtho(-10, len(self.s)+10, -50, 50, -50, 50)
33
34     glutDisplayFunc(self.display)
35     print "init done"
36   
37   def display(self):
38     """Update showing buffer"""
39     glClear(GL_COLOR_BUFFER_BIT)
40     self.glseq.draw(-50, self.glseq.size+50)
41     #glutSwapBuffers()
42
43 if __name__ == "__main__":
44   p = pyMussaGL()
45   glutMainLoop()