summaryrefslogtreecommitdiffstats
path: root/opengl.h
blob: b48b441d0c6734a94f5500d3e477b4ba33a0923a (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
/*
 * Compton - a compositor for X11
 *
 * Based on `xcompmgr` - Copyright (c) 2003, Keith Packard
 *
 * Copyright (c) 2011-2013, Christopher Jeffrey
 * See LICENSE for more information.
 *
 */

#include "common.h"

#include <ctype.h>

/**
 * Check if a GLX extension exists.
 */
static inline bool
glx_hasext(session_t *ps, const char *ext) {
  const char *glx_exts = glXQueryExtensionsString(ps->dpy, ps->scr);
  const char *pos = strstr(glx_exts, ext);
  // Make sure the extension string is matched as a whole word
  if (!pos
      || ((pos - glx_exts) && !isspace(*(pos - 1)))
      || (strlen(pos) > strlen(ext) && !isspace(pos[strlen(ext)]))) {
    printf_errf("(): Missing OpenGL extension %s.", ext);
    return false;
  }

  return true;
}

static inline XVisualInfo *
get_visualinfo_from_visual(session_t *ps, Visual *visual) {
  XVisualInfo vreq = { .visualid = XVisualIDFromVisual(visual) };
  int nitems = 0;

  return XGetVisualInfo(ps->dpy, VisualIDMask, &vreq, &nitems);
}

static bool
glx_update_fbconfig(session_t *ps);

static int
glx_cmp_fbconfig(session_t *ps,
    const glx_fbconfig_t *pfbc_a, const glx_fbconfig_t *pfbc_b);