Sometimes, it makes sense to generate textures on the fly during the execution of the program. The texture could be a pattern that is generated from some internal algorithm (a so-called procedural texture), or it could be that the texture is meant to represent another portion of the scene.
An example of the latter case might be a video screen where one can see another part of the world, perhaps via a security camera in another room. The video screen could be constantly updated as objects move around in the other room, by re-rendering the view from the security camera to the texture that is applied to the video screen!
In the following image, the texture appearing on the cube was generated by rendering the cow to an internal texture and then applying that texture to the faces of the cube:

In OpenGL, rendering directly to textures has been greatly simplified by the introduction of framebuffer objects (FBOs). We can create a separate rendering target buffer (the FBO), attach...