import sys, math, time from OpenGL.GLUT import * from OpenGL.GL import * from OpenGL.GLU import * import Image img = Image.open('image.jpg') #img = img.transpose(Image.FLIP_TOP_BOTTOM) def draw(): glClear(GL_COLOR_BUFFER_BIT) # glPixelStoref(GL_UNPACK_ALIGNMENT, 1) # glRasterPos2f(0, 0) glDrawPixels(img.size[0], img.size[1], GL_RGB, GL_UNSIGNED_BYTE, img.tostring()) glutSwapBuffers() def keyboard(key, x, y): if key == chr(27): sys.exit(0) def idle(): glutPostRedisplay() glutInit([]) glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB) glutInitWindowSize(500, 500) glutInitWindowPosition(0,0) glutCreateWindow(sys.argv[0]) glutDisplayFunc(draw) glutKeyboardFunc(keyboard) glutIdleFunc(idle) glutMainLoop()