OpenGL Images

Images are drawn with glDrawPixels

glDrawPixels(width, height, format, type, pixels)

width & height are the size of the image, in pixels.

format is GL_RGB for RGB images, or GL_LUMINANCE for greyscale (there are other formats as well).

type indicates the data type of the pixel data. GL_UNSIGNED_BYTE is standard for 8-bit-per-channel images.

pixels is the actual array of image data. Use the tostring() function with PIL images.

    img = Image.open("foo.jpg")
    glDrawPixels(img.size[0], img.size[1], GL_RGB,
                 GL_UNSIGNED_BYTE, img.tostring())