@@ -200,29 +200,35 @@ package. Here is a minimal setup that should open a window with a black backgrou
200
200
201
201
.. code :: python
202
202
203
- import sys
204
203
import OpenGL.GL as gl
205
204
import OpenGL.GLUT as glut
206
205
206
+ window = None
207
+
208
+
207
209
def display ():
208
210
gl.glClear(gl.GL_COLOR_BUFFER_BIT )
209
211
glut.glutSwapBuffers()
210
212
211
- def reshape (width ,height ):
213
+
214
+ def reshape (width , height ):
212
215
gl.glViewport(0 , 0 , width, height)
213
216
214
- def keyboard ( key , x , y ):
217
+
218
+ def keyboard (key , x , y ):
215
219
if key == b ' \x1b ' :
216
- sys.exit( )
217
-
218
- glut.glutInit()
219
- glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA )
220
- glut.glutCreateWindow(' Hello world!' )
221
- glut.glutReshapeWindow(512 ,512 )
222
- glut.glutReshapeFunc(reshape)
223
- glut.glutDisplayFunc(display)
224
- glut.glutKeyboardFunc(keyboard)
225
- glut.glutMainLoop()
220
+ glut.glutDestroyWindow(window)
221
+
222
+
223
+ if __name__ == ' __main__' :
224
+ glut.glutInit()
225
+ glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA )
226
+ window = glut.glutCreateWindow(' Hello World' )
227
+ glut.glutReshapeWindow(512 , 512 )
228
+ glut.glutReshapeFunc(reshape)
229
+ glut.glutDisplayFunc(display)
230
+ glut.glutKeyboardFunc(keyboard)
231
+ glut.glutMainLoop()
226
232
227
233
.. Note ::
228
234
0 commit comments