Texturing Bitmaps

Hi folks,

What I want to do is to draw a bitmap that identifies a section of a plane to texture and have OpenGL texture it just as though it were a polygon for which I had set texture coordinates.

Obviously, the bitmap is a 2D structure, but you should, as I understand it, be able to control the texture matrix directly to have the texture appear in the appropriate perspective.

I’ve tried doing this, and I have managed to draw a bitmap where the texture affects the colour, but I’ve had no success whatsoever in controlling the effect.

Has anyone succeeded in doing this?

And will OpenGL actually do it, in the way I describe above?


OK. Answering my own question.

Did some reading, and discovered a bit in the red book that made me feel really stupid.

I’ve been assuming that the texture matrix defines texture coordinates.

It doesn’t; it transforms them, before they’re used to index the texture.

Which means you need some coordinates first.

So, in order to apply perspective texture to a bitmap (using glBitmap) you’d need to enable some form of automatic coordinate generation, and then figure out a texture matrix that would convert the coordinates into those that you wanted.

I haven’t actually tried this, because I ran a test, and doing what I want with bitmaps is too slow even before you enable texturing. However, it seems to follow all the appropriate OpenGL logic.