1
# Another forms test program for the Python port of
2
# the Fast Light Tool Kit (pyFLTK).
3
# Modified to have 2 cubes to test multiple OpenGL contexts
5
# FLTk is Copyright 1998-2003 by Bill Spitzak and others.
6
# pyFLTK is Copyright 2003 by Andreas Held
8
# This library is free software; you can redistribute it and/or
9
# modify it under the terms of the GNU Library General Public
10
# License as published by the Free Software Foundation; either
11
# version 2 of the License, or (at your option) any later version.
13
# This library is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
# Library General Public License for more details.
18
# You should have received a copy of the GNU Library General Public
19
# License along with this library; if not, write to the Free Software
20
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
28
from OpenGL.GLUT import *
29
from OpenGL.GL import *
32
ERROR: PyOpenGL not installed properly.
39
class cube_box(Fl_Gl_Window):
44
def __init__(self, x, y, w, h, l):
45
Fl_Gl_Window.__init__(self, x, y, w, h, l)
49
self.lasttime = self.lasttime+self.speed
52
glViewport(0,0,self.w(),self.h())
53
glEnable(GL_DEPTH_TEST)
54
glFrustum(-1,1,-1,1,2,10000)
56
gl_font(FL_HELVETICA_BOLD, 16 )
59
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
62
glRotatef(self.lasttime*1.6,0,0,1)
63
glRotatef(self.lasttime*4.2,1,0,0)
64
glRotatef(self.lasttime*2.3,0,1,0)
65
glTranslatef(-1.0, 1.2, -1.5);
66
glScalef(self.size,self.size,self.size)
70
glDisable(GL_DEPTH_TEST)
72
gl_draw("Cube: wire", -4.5, -4.5)
74
gl_draw("Cube: flat", -4.5, -4.5)
75
glEnable(GL_DEPTH_TEST)
77
print "Exception: ", sys.exc_type, sys.exc_value
104
glBegin(GL_LINE_LOOP)
107
glColor3ub(0,255,255)
114
glBegin(GL_LINE_LOOP)
117
glColor3ub(255,0,255)
124
glBegin(GL_LINE_LOOP)
127
glColor3ub(255,255,0)
134
glBegin(GL_LINE_LOOP)
144
glBegin(GL_LINE_LOOP)
164
class MyBox(Fl_Group):
165
def __init__(self, type, x, y, w, h, l):
166
Fl_Group.__init__(self, x, y, w, h, l)
167
Fl_Group.box(self, type)
182
form = Fl_Window(510+390,390,name)
183
b1 = Fl_Box(FL_DOWN_FRAME,20,20,350,350,"")
184
b2 = Fl_Box(FL_DOWN_FRAME,510,20,350,350,"")
185
speed = Fl_Slider(FL_VERT_SLIDER,390,90,40,220,"Speed")
186
size = Fl_Slider(FL_VERT_SLIDER,450,90,40,220,"Size")
187
wire = Fl_Radio_Light_Button(390,20,100,30,"Wire")
188
flat = Fl_Radio_Light_Button(390,50,100,30,"Flat")
189
button = Fl_Button(390,340,100,30,"Exit")
190
button.callback(exit_cb)
191
cube = cube_box(23,23,344,344, "")
192
cube2 = cube_box(513,23,344,344, "")
193
b = Fl_Box(FL_NO_BOX,cube.x(),size.y(), cube.w(),size.h(),"")
194
#b = MyBox(FL_NO_BOX,cube.x(),size.y(), cube.w(),size.h(),"")
200
if __name__ == '__main__':
201
makeform(sys.argv[0])
216
form.show(len(sys.argv), sys.argv)
221
if form.visible() == 1 and speed.value() != 0:
228
cube.wire = wire.value()
229
cube2.wire = not wire.value()
230
cube.size = size.value()
231
cube2.size = size.value()
232
cube.speed = speed.value()
233
cube2.speed = speed.value()
236
if Fl.readqueue() == button: