Drawing a Texture
Object:
Object:
This program demonstrates the use of the OpenGL function glCopyTexImage2D, which copies an image from the color buffer (where OpenGL draws its images) into a texture. This makes it possible to draw an image with OpenGL and then use the image as a texture on other objects.
A pop-up menu lets you select the object on which the texture image is used. The last entry in the menu is "SHOW 2D SCENE." In that case, you see the color buffer just after the 2D scene has been drawn, instead of seeing a 3D object with the scene as a texture. Note that the 2D scene does not fill the canvas. In fact, it is drawn in a 256-by-256 viewport, since the width and height of a texture image should be powers of two.
If you turn on animation, the scene shown in the texture image is animated. A new version of the scene is drawn and copied to the texture for each frame. In this case, the texture image is a 2D cart-and-windmill animation that should be familiar from other examples.
As usual, you can rotate the 3D objects using your mouse.