summaryrefslogtreecommitdiff
path: root/xcbxf86dri.c
blob: e471431b25933db0f9f677068541ab47b3cebda3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Copyright (C) 2006 Josh Triplett. All Rights Reserved.  See the file
 * COPYING in this directory for licensing information. */
#include <X11/XCB/xcb.h>
#include <X11/XCB/xf86dri.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
    int screen;
    XCBXF86DriQueryVersionCookie qvc;
    XCBXF86DriQueryVersionRep *qv;
    XCBXF86DriQueryDirectRenderingCapableCookie qdrc;
    XCBXF86DriQueryDirectRenderingCapableRep *qdr;
    XCBConnection *c = XCBConnect(NULL, &screen);

    if(!c)
    {
        fprintf(stderr, "Error establishing connection to X server.");
        return 1;
    }

    qvc  = XCBXF86DriQueryVersion(c);
    qdrc = XCBXF86DriQueryDirectRenderingCapable(c, screen);

    qv  = XCBXF86DriQueryVersionReply(c, qvc, 0);
    if(!qv)
    {
        fprintf(stderr, "Error querying DRI extension version.\n");
        return 1;
    }
    printf("DRI extension version: %hu.%hu.%u\n",
           qv->dri_major_version, qv->dri_minor_version, qv->dri_minor_patch);
    free(qv);

    qdr = XCBXF86DriQueryDirectRenderingCapableReply(c, qdrc, 0);
    if(!qdr)
    {
        fprintf(stderr, "Error querying direct rendering capability.\n");
        return 1;
    }
    printf("Direct rendering (screen %d): %s\n",
           screen, qdr->is_capable ? "yes" : "no");
    free(qdr);

    XCBDisconnect(c);

    return 0;
}