Displaying Images

The images.viewer vocabulary uses the opengl.textures vocabulary to display any instance of image.

An image-gadget can be used for static images and an image-control for changing images (for example a video feed). For changing images, the image should be contained in a model. Change the model value with set-model or mutate the image and call notify-connections when you want to update the image. To stop refreshing the image, call stop-control. To start refreshing again, call start-control.

If the image or model containing the image is available when the object is created, use the following words to create the gadget:
<image-gadget> ( object -- gadget )

<image-control> ( model -- gadget )

The image or model can also be given after the construction of the object. In this case, use new-image-gadget and set-image. The gadget will automatically detect if the image changes size or format and reallocate a new texture if needed. This means images can be set even after the gadget has been grafted. Grafted gadgets without an image will display a blank screen.

The image can be set after the gadget has been grafted. However, for an image-gadget, this can be done only once. If your image is changing, you should be using an image-control and a model.

Performance will be greatly reduced if you are using images that have more than 512 pixels on one of their axis.

Utility words for displaying images:
image. ( object -- )

image-window ( object -- )