| ![[Previous]](../prev.gif) | ![[Contents]](../contents.gif) | ![[Index]](../keyword_index.gif) | ![[Next]](../next.gif) | 
Attach to a display on a graphics device
#include <gf/gf.h>
int gf_display_attach( gf_display_t * pdisplay,
                       gf_dev_t gfx,
                       unsigned display_index,
                       gf_display_info_t *info );
gf
This function attaches to a display on a graphics device. This function provides you with a handle that lets you use the display while maintaining thread safety. Actual parameters for the individual display (or displays) on a graphics device are configured via a separate configuration file and maintained by a separate server, io-display.
A device typically drives one display, although some hardware is fitted with multiple displays, each of which you can attach to via this function. With a separate handle for each display, you can address and manipulate each on an individual basis.
The info argument contains information about the attached display:
typedef struct
{
    unsigned nlayers;
    unsigned main_layer_index;
    uint16_t xres;
    uint16_t yres;
    gf_format_t format;
    int refresh;
} gf_display_info_t;
It contains at least the following members:
|  | If the format filled in by gf_display_attach() is a packed format, it will not be endian-specific. | 
Attach to a device, and then use the device information structure gf_dev_info_t to attach to the device's displays:
    gf_dev_t            gdev;
    gf_dev_info_t       gdev_info;
    gf_display_t        display;
    gf_display_info_t   display_info;
    int i;
    if (gf_dev_attach(&gdev,GF_DEVICE_INDEX(0),&gdev_info) != GF_ERR_OK) {
        printf("gf_dev_attach() failed\n");
        return (-1);
    }
    printf("Number of displays: %d\n",gdev_info.ndisplays);
    for (i = gdev_info.ndisplays;i;) {
        printf("Display %d: ",i--);
        if (gf_display_attach(&display,gdev,i,&display_info) == GF_ERR_OK) {
            printf("%dX%d, refresh = %dHz\n",display_info.xres,display_info.yres,display_info.refresh);
            printf("Number of layers: %d\n",display_info.nlayers);
        } else {
            printf("gf_display_attach() failed\n");
        }
    }
QNX Graphics Framework
| Safety: | |
|---|---|
| Interrupt handler | No | 
| Signal handler | No | 
| Thread | Yes | 
gf_display_detach(), gf_display_set_layer_order()
| ![[Previous]](../prev.gif) | ![[Contents]](../contents.gif) | ![[Index]](../keyword_index.gif) | ![[Next]](../next.gif) |