Révision 11 PyOpenGL-Demo/redbook/drawf.py

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)

Formats disponibles : Unified diff