[Image-SIG] Using PIL for background display in OGL/Python
Bob Ippolito
bob at redivi.com
Fri Jan 28 22:58:29 CET 2005
On Jan 28, 2005, at 12:26, <python at bnardone.com> wrote:
> I've just begun working OGL with Python and had a question about PIL.
> Specifically, I've been using it to load .png's as textures, and now
> have a need
> to draw other images (.jpg, .png) as background images. I'm interested
> in using
> something along the lines of:
> glPixelStorei(GL_UNPACK_ALIGNMENT,4);
> glRasterPos2i(0,600)
> glDrawPixels(800,600,GL_RGBA,*someBitmapSet*)
>
> But I am unsure as to how to get the *someBitmapSet* out of the object
> returned by
> someImage.tostring("raw", "RGBA", 0, -1)
> image = numarray.array(numarray.fromstring(image, numarray.Byte))
>
> I've tried
> glDrawPixels(800,600,GL_RGBA,GL_UNSIGNED_BYTE,image)
> to no avail.
>
> Is this possible? Am I headed in the right direction?
You shouldn't be using glDrawPixels.. it's almost always slow. You
want to draw it to a texture, and then render the texture to a rect.
There are examples out there for getting a PIL image into an OpenGL
texture, but I can't think of anything off the top of my head.
-bob
More information about the Image-SIG
mailing list