Debian Codegraph @

fltk/test/shapeGL.py

raw symbols SCIP
1 #
2 # "$Id: shapeGL.py 495 2013-03-30 09:39:45Z andreasheld $"
3 #
4 # OpenGL test program for pyFLTK the Python bindings
5 # for the Fast Light Tool Kit (FLTK).
6 #
7 # FLTK copyright 1998-1999 by Bill Spitzak and others.
8 # pyFLTK copyright 2003 by Andreas Held.
9 #
10 # This library is free software you can redistribute it and/or
11 # modify it under the terms of the GNU Library General Public
12 # License, version 2.0 as published by the Free Software Foundation.
13 #
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Library General Public License for more details.
18 #
19 # You should have received a copy of the GNU Library General Public
20 # License along with this library if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 # USA.
23 #
24 # Please report all bugs and problems to "[email protected]".
25 #
26
27 from fltk import *
28 import sys, math, time
29
30 #sleep(5)
31
32 try:
33 class ShapeWindow(Fl_Gl_Window):
34
35 def __init__(self, x, y, w, h, l):
36 Fl_Gl_Window.__init__(self, x,y,w,h,l)
37 self.sides = 3
38
39 def draw(self):
40 #// draw an amazing graphic:
41 glClear(0x00004000) #GL_COLOR_BUFFER_BIT)
42 glColor3f(0.5,0.6,0.7)
43 glBegin(9) #GL_POLYGON)
44 for i in range(int(self.sides)):
45 ang = i*2.0*3.141/self.sides
46 x = math.cos(ang)
47 y = math.sin(ang)
48 glVertex3f( x, y, 0.0)
49 glEnd()
50
51 # def handle(self, event):
52 # if event == FL_PUSH:
53 # print "Mouse pushed!"
54 # return 1
55 # else:
56 # return 0
57
58
59 def sides_cb(self, slider):
60 self.sides = slider.value()
61 self.redraw()
62
63 except NameError:
64 fl_message("This demo requires OpenGL. Reconfigure and rebuild with OpenGl enabled.")
65 sys.exit(0)
66
67 window = Fl_Window(10, 10, 300, 330, sys.argv[0])
68
69 sw = ShapeWindow(10,10,280,280, "Shape Window")
70 window.resizable(sw)
71
72 slider = Fl_Hor_Slider(50, 295, window.w()-60, 30, "Sides")
73 slider.align(FL_ALIGN_LEFT)
74 slider.callback(sw.sides_cb)
75 slider.value(float(sw.sides))
76 slider.step(1)
77 slider.bounds(3, 40)
78
79 window.end()
80 window.show(len(sys.argv), sys.argv)
81 sw.show()
82
83 Fl.run()