Révision 11

PyOpenGL-Demo/redbook/fog.py (revision 11)
2 2

  
3 3
# This is statement is required by the build system to query build info
4 4
if __name__ == '__build__':
5
	raise Exception
5
	raise(Exception)
6 6

  
7 7
'''
8 8
fog.c from the Redbook examples.  
......
64 64
  from OpenGL.GLUT import *
65 65
  from OpenGL.GL import *
66 66
except:
67
  print '''
67
  print('''
68 68
ERROR: PyOpenGL not installed properly.  
69
        '''
69
        ''')
70 70
  sys.exit()
71 71

  
72 72

  
......
108 108

  
109 109
# display() draws 5 spheres at different z positions.
110 110
def display():
111
   print 'redisplay'
111
   print('redisplay')
112 112
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
113 113
   renderSphere (-2., -0.5, -1.0)
114 114
   renderSphere (-1., -0.5, -2.0)
......
130 130

  
131 131
def keyboard(key, x, y):
132 132
  global fogMode
133
  if key in ['f','F']:
133
  if key in [b'f',b'F']:
134 134
    if (fogMode == GL_EXP):
135 135
      fogMode = GL_EXP2;
136
      print "Fog mode is GL_EXP2"
136
      print("Fog mode is GL_EXP2")
137 137
    elif (fogMode == GL_EXP2):
138 138
      fogMode = GL_LINEAR
139
      print "Fog mode is GL_LINEAR"
139
      print("Fog mode is GL_LINEAR")
140 140
    elif (fogMode == GL_LINEAR):
141 141
      fogMode = GL_EXP
142
      print "Fog mode is GL_EXP"
142
      print("Fog mode is GL_EXP")
143 143
    glFogi(GL_FOG_MODE, fogMode)
144 144
    glutPostRedisplay()
145 145
  
......
154 154
glutInit(sys.argv)
155 155
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
156 156
glutInitWindowSize(500, 500)
157
glutCreateWindow('fog')
157
glutCreateWindow(b'fog')
158 158
init()
159 159
glutReshapeFunc(reshape)
160 160
glutKeyboardFunc(keyboard)
PyOpenGL-Demo/redbook/scene.py (revision 11)
2 2

  
3 3
# This is statement is required by the build system to query build info
4 4
if __name__ == '__build__':
5
	raise Exception
5
	raise(Exception)
6 6

  
7 7
'''
8 8
scene.c from the Redbook examples.  
......
60 60
  from OpenGL.GLUT import *
61 61
  from OpenGL.GL import *
62 62
except:
63
  print '''
63
  print('''
64 64
ERROR: PyOpenGL not installed properly.  
65
        '''
65
        ''')
66 66
  sys.exit()
67 67

  
68 68

  
......
124 124

  
125 125

  
126 126
def keyboard(key, x, y):
127
   if key == chr(27):
127
   if key == str.encode(chr(27)):
128 128
       sys.exit(0)
129 129
   
130 130

  
......
136 136
glutInit(sys.argv)
137 137
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH)
138 138
glutInitWindowSize (500, 500)
139
glutCreateWindow('scene')
139
glutCreateWindow(b'scene')
140 140
init()
141 141
glutReshapeFunc(reshape)
142 142
glutKeyboardFunc(keyboard)
PyOpenGL-Demo/redbook/cube.py (revision 11)
2 2

  
3 3
# This is statement is required by the build system to query build info
4 4
if __name__ == '__build__':
5
	raise Exception
5
	raise(Exception)
6 6

  
7 7
'''
8 8

  
......
60 60
  from OpenGL.GL import *
61 61
  from OpenGL.GLU import *
62 62
except:
63
  print '''
63
  print('''
64 64
ERROR: PyOpenGL not installed properly.  
65
        '''
65
        ''')
66 66

  
67 67
def init(): 
68 68
   glClearColor (0.0, 0.0, 0.0, 0.0)
......
86 86
   glMatrixMode (GL_MODELVIEW)
87 87

  
88 88
def keyboard(key, x, y):
89
   if key == chr(27):
89
   if key == str.encode(chr(27)):
90 90
      import sys
91 91
      sys.exit(0)
92 92

  
......
94 94
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB)
95 95
glutInitWindowSize (500, 500)
96 96
glutInitWindowPosition (100, 100)
97
glutCreateWindow ('cube')
97
glutCreateWindow (b'cube')
98 98
init ()
99 99
glutDisplayFunc(display)
100 100
glutReshapeFunc(reshape)
PyOpenGL-Demo/redbook/movelight.py (revision 11)
2 2

  
3 3
# This is statement is required by the build system to query build info
4 4
if __name__ == '__build__':
5
	raise Exception
5
	raise(Exception)
6 6

  
7 7
'''
8 8
Converted to Python 6/00 by Jason Petrone(jp@demonseed.net)
......
70 70
  from OpenGL.GL import *
71 71
  from OpenGL.GLU import *
72 72
except:
73
  print '''
73
  print('''
74 74
ERROR: PyOpenGL not installed properly.  
75
        '''
75
        ''')
76 76
  sys.exit()
77 77

  
78 78

  
......
128 128
       glutPostRedisplay()
129 129

  
130 130
def keyboard(key, x, y):
131
   if key == chr(27):
131
   if key == str.encode(chr(27)):
132 132
       sys.exit(0)
133 133

  
134 134
glutInit(sys.argv)
135 135
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
136 136
glutInitWindowSize (500, 500); 
137 137
glutInitWindowPosition(100, 100)
138
glutCreateWindow("movelight")
138
glutCreateWindow(b"movelight")
139 139
init()
140 140
glutDisplayFunc(display)
141 141
glutReshapeFunc(reshape)
PyOpenGL-Demo/redbook/teapots.py (revision 11)
52 52
  from OpenGL.GL import *
53 53
  from OpenGL.GLU import *
54 54
except:
55
  print '''
55
  print('''
56 56
ERROR: PyOpenGL not installed properly.  
57
        '''
57
        ''')
58 58
  sys.exit()
59 59

  
60 60
teapotList = None
......
189 189

  
190 190

  
191 191
def keyboard(key, x, y):
192
   if key == chr(27):
192
   if key == str.encode(chr(27)):
193 193
      sys.exit(0)
194 194

  
195 195
# Main Loop 
......
198 198
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
199 199
	glutInitWindowSize(500, 600);
200 200
	glutInitWindowPosition(50,50);
201
	glutCreateWindow(sys.argv[0]);
201
	glutCreateWindow(str.encode(sys.argv[0]));
202 202
	glutReshapeFunc(reshape)
203 203
	glutDisplayFunc(display)
204 204
	glutKeyboardFunc(keyboard)
PyOpenGL-Demo/redbook/drawf.py (revision 11)
55 55
	from OpenGL.GLUT import *
56 56
	from OpenGL.GL import *
57 57
except:
58
	print '''
58
	print('''
59 59
ERROR: PyOpenGL not installed properly.  
60
'''
60
''')
61 61
	sys.exit()
62 62

  
63 63

  
......
66 66
	0xff, 0x00, 0xff, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00,
67 67
	0xff, 0xc0, 0xff, 0xc0)
68 68

  
69
rasters = ''
69
rasters = b''
70 70
for byte in rasterBytes:
71 71
	rasters = rasters + struct.pack('B', byte)
72 72

  
......
75 75
	glClearColor(0.0, 0.0, 0.0, 0.0)
76 76

  
77 77
def display():
78
	print 'display'
78
	print('display')
79 79
	glClear(GL_COLOR_BUFFER_BIT)
80 80
	glColor3f(1.0, 1.0, 1.0)
81 81
	glRasterPos2i(20, 20)
82
	print 'beginning bitmaps'
82
	print('beginning bitmaps')
83 83
	glBitmap(10, 12, 0.0, 0.0, 11.0, 0.0, rasters)
84 84
	glBitmap(10, 12, 0.0, 0.0, 11.0, 0.0, rasters)
85 85
	glBitmap(10, 12, 0.0, 0.0, 11.0, 0.0, rasters)
86
	print 'flushing'
86
	print('flushing')
87 87
	glFlush()
88 88
	
89 89
def reshape(w, h):
90
	print 'reshape'
90
	print('reshape')
91 91
	glViewport(0, 0, w, h)
92 92
	glMatrixMode(GL_PROJECTION)
93 93
	glLoadIdentity()
......
95 95
	glMatrixMode(GL_MODELVIEW)
96 96

  
97 97
def keyboard(key, x, y):
98
	print 'keyboard', key, x,y
99
	if key == chr(27):
98
	print('keyboard', key, x,y)
99
	if key == str.encode(chr(27)):
100 100
		sys.exit()
101 101

  
102 102
#  Main Loop
......
107 107
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
108 108
	glutInitWindowSize(100, 100)
109 109
	glutInitWindowPosition(100, 100)
110
	glutCreateWindow('drawf')
110
	glutCreateWindow(b'drawf')
111 111
	init()
112 112
	glutReshapeFunc(reshape)
113 113
	glutKeyboardFunc(keyboard)
PyOpenGL-Demo/redbook/hello.py (revision 11)
2 2

  
3 3
# This is statement is required by the build system to query build info
4 4
if __name__ == '__build__':
5
	raise Exception
5
	raise(Exception)
6 6

  
7 7
'''
8 8
Converted to Python 6/00 by Jason Petrone
......
55 55
  from OpenGL.GL import *
56 56
  from OpenGL.GLU import *
57 57
except:
58
  print '''
58
  print('''
59 59
ERROR: PyOpenGL not installed properly.  
60
        '''
60
        ''')
61 61
  sys.exit()
62 62

  
63 63

  
......
98 98
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
99 99
glutInitWindowSize(250, 250)
100 100
glutInitWindowPosition(100, 100)
101
glutCreateWindow("hello")
101
glutCreateWindow(b"hello")
102 102
init()
103 103
glutDisplayFunc(display)
104 104
glutMainLoop()
PyOpenGL-Demo/redbook/smooth.py (revision 11)
2 2

  
3 3
# This is statement is required by the build system to query build info
4 4
if __name__ == '__build__':
5
	raise Exception
5
	raise(Exception)
6 6

  
7 7
'''
8 8
smooth.c from the Redbook examples.  
......
61 61
  from OpenGL.GL import *
62 62
  from OpenGL.GLU import *
63 63
except:
64
  print '''
64
  print('''
65 65
ERROR: PyOpenGL not installed properly.  
66
        '''
66
        ''')
67 67
  sys.exit()
68 68

  
69 69

  
......
98 98
   glMatrixMode(GL_MODELVIEW)
99 99

  
100 100
def keyboard(key, x, y):
101
   if key == chr(27):
101
   if key == str.encode(chr(27)):
102 102
      sys.exit(0)
103 103

  
104 104

  
......
106 106
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
107 107
glutInitWindowSize(500, 500) 
108 108
glutInitWindowPosition(100, 100)
109
glutCreateWindow('Smooth')
109
glutCreateWindow(b'Smooth')
110 110
init()
111 111
glutReshapeFunc(reshape)
112 112
glutKeyboardFunc(keyboard)
PyOpenGL-Demo/redbook/double.py (revision 11)
1
#!/usr/bin/python
1
#!/usr/bin/env python3
2 2

  
3 3
# This is statement is required by the build system to query build info
4 4
if __name__ == '__build__':
5
	raise Exception
5
	raise(Exception)
6 6

  
7 7
'''
8 8
double.c from the Redbook examples.  
......
62 62
  from OpenGL.GL import *
63 63
  from OpenGL.GLU import *
64 64
except:
65
  print '''
65
  print('''
66 66
ERROR: PyOpenGL not installed properly.  
67
        '''
67
        ''')
68 68
  sys.exit()
69 69

  
70 70

  
......
113 113
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
114 114
glutInitWindowSize(250, 250)
115 115
glutInitWindowPosition(100, 100)
116
glutCreateWindow('Double')
116
glutCreateWindow(b'Double')
117 117
init()
118 118
glutDisplayFunc(display)
119 119
glutReshapeFunc(reshape)
PyOpenGL-Demo/redbook/lines.py (revision 11)
2 2

  
3 3
# This is statement is required by the build system to query build info
4 4
if __name__ == '__build__':
5
	raise Exception
5
	raise(Exception)
6 6

  
7 7
'''
8 8
lines.c from the Redbook examples.  
......
60 60
  from OpenGL.GL import *
61 61
  from OpenGL.GLU import *
62 62
except:
63
  print '''
63
  print('''
64 64
ERROR: PyOpenGL not installed properly.  
65
        '''
65
        ''')
66 66
  sys.exit()
67 67

  
68 68
def drawOneLine(x1, y1, x2, y2):
......
129 129
  gluOrtho2D(0.0, w, 0.0, h)
130 130

  
131 131
def keyboard(key, x, y):
132
  if key == chr(27):
132
  if key == str.encode(chr(27)):
133 133
    sys.exit(0)
134 134

  
135 135
glutInit(sys.argv)
136 136
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
137 137
glutInitWindowSize(400, 150)
138 138
glutInitWindowPosition(100, 100)
139
glutCreateWindow('Lines')
139
glutCreateWindow(b'Lines')
140 140
init()
141 141
glutDisplayFunc(display)
142 142
glutReshapeFunc(reshape)

Formats disponibles : Unified diff