I’m having some hassles trying to render a bunch of textures to another texture (basically, trying to dynamically create a texture atlas) via a framebuffer. I’ve got everything hooked up—for example, glClear() affects my texture properly. And once I set the modelview matrix to the identity and reset the projection matrix to gluOrtho2D(0, tex_width, tex_height, 0) (I’m using ftransform() in my vertex shader at present), I can get one—and only one—of my textures to render in my final texture. Specifically, I get one texture rendered in the upper-left corner of my destination texture—the first one. For each new texture I’m resubmitting glVertexPointer and glTexCoordPointer, as well as rebinding to the new texture to draw and translating to the new position in the texture. Nothing besides the first texture gets drawn.
My first texture has vertices (0, 0), (0, 48), (48, 48), (48, 0), while my next one has the same vertices but with a (48, 0) translation, and so on as more textures are drawn.
I wonder if I’m just confused about how framebuffer-to-texture works. None of the tutorials I poked through mentioned having to reset the modelview and projection matrices, but I didn’t even get this far (to a single rendered texture) without changing them. I’d like to completely avoid them and just figure out the final position in my vertex shader, but I don’t know how to begin. Are the final texture coordinates (0, 0) lower-left to (1, 1) upper-right, or do they use the actual storage width and height of the texture as the upper-right corner?
I’d show some code, but it’s splattered all over several places in my code base.