~darkxst/ubuntu/utopic/gnome-desktop3/3.12

« back to all changes in this revision

Viewing changes to libgnome-desktop/check_gl_texture_size.c

  • Committer: Package Import Robot
  • Author(s): Tim Lunn
  • Date: 2013-05-28 09:10:46 UTC
  • mfrom: (1.6.1) (21.1.10 experimental)
  • Revision ID: package-import@ubuntu.com-20130528091046-b0oc28za9l97fgq1
Tags: 3.8.2-0ubuntu1
* New upstream release
* Sync with Debian (LP: #1184812) Remaining changes:
  - debian/patches:
    + 04_compute_average_color.patch: Compute the avergage color in
      gnome-desktop itself, not in unity to fix some races (LP #963140)
    + tweak_color_computation.patch, Patch from Gord, no patch header,
      no bug link.
    + git_revert_draw_background.patch
    + ubuntu_language.patch, Ported relevant bits from g-c-c 
      52_region_language.patch, as required for gnome 3.8 region panel
    + ubuntu_language_list_from_SUPPORTED.patch,
      adds api to get list of available languages from SUPPORTED file.
      To be used by gnome 3.8 region panel language installation.
  - debian/control.in:
    + Don't break gnome-shell << 3.7.90
    + Use source:Version for gnome-desktop3-data Depend
    + Add epoch to gnome-desktop3-data's Breaks/Replaces, as our old
      gnome-desktop source package introduced an epoch. This needs to be
      kept until after 14.04 LTS.
 - Install helper tools into a versioned directory (by overriding
   libexecdir). They could alternatively be installed in a separate package
* Dropped changes:
  - 02_refuse_to_break_GL_compositors.patch:
    + Doesn't appear to be needed any more
 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
 
 
4
#include <unistd.h>
 
5
 
 
6
#include <X11/Xlib.h>
 
7
#include <GL/gl.h>
 
8
#include <GL/glx.h>
 
9
 
 
10
int main (int argc, char **argv)
 
11
{
 
12
  Display *dpy = XOpenDisplay (NULL);
 
13
  
 
14
  Window win;
 
15
  int attribSingle[] = {
 
16
    GLX_RGBA,
 
17
    GLX_RED_SIZE, 1,
 
18
    GLX_GREEN_SIZE, 1,
 
19
    GLX_BLUE_SIZE, 1,
 
20
    None };
 
21
  
 
22
  int attribDouble[] = {
 
23
    GLX_RGBA,
 
24
    GLX_RED_SIZE, 1,
 
25
    GLX_GREEN_SIZE, 1,
 
26
    GLX_BLUE_SIZE, 1,
 
27
    GLX_DOUBLEBUFFER,
 
28
    None };
 
29
  
 
30
  XSetWindowAttributes attr;
 
31
  unsigned long mask;
 
32
  GLXContext ctx = NULL;
 
33
  XVisualInfo *visinfo;
 
34
  
 
35
  int exit_status = EXIT_SUCCESS;
 
36
  
 
37
  GLint max_texture_size = 0;
 
38
 
 
39
  if (!dpy) {
 
40
    /* We have, for some reason, been unable to connect to X
 
41
     * Bail cleanly, and leave a little note */
 
42
    fprintf (stderr, "check_gl_texture_size: Unable to open display %s", getenv("DISPLAY"));
 
43
    exit (EXIT_FAILURE);
 
44
  }
 
45
  
 
46
  visinfo = glXChooseVisual (dpy, DefaultScreen (dpy), attribSingle);
 
47
  if (!visinfo)
 
48
    visinfo = glXChooseVisual (dpy, DefaultScreen (dpy), attribDouble);
 
49
  
 
50
  if (visinfo)
 
51
    ctx = glXCreateContext (dpy, visinfo, NULL, GL_TRUE);
 
52
  
 
53
  if (!visinfo) {
 
54
    exit_status = EXIT_FAILURE;
 
55
    goto child_out;
 
56
  }
 
57
  
 
58
  if (!ctx) {
 
59
    XFree (visinfo);
 
60
    exit_status = EXIT_FAILURE;
 
61
    goto child_out;
 
62
  }
 
63
  
 
64
  attr.background_pixel = 0;
 
65
  attr.border_pixel = 0;
 
66
  attr.colormap = XCreateColormap (dpy, DefaultRootWindow (dpy),
 
67
                                   visinfo->visual, AllocNone);
 
68
  attr.event_mask = StructureNotifyMask | ExposureMask;
 
69
  mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
 
70
  win = XCreateWindow (dpy, DefaultRootWindow (dpy), 0, 0, 100, 100,
 
71
                       0, visinfo->depth, InputOutput,
 
72
                       visinfo->visual, mask, &attr);
 
73
  
 
74
  if (!glXMakeCurrent (dpy, win, ctx)) {
 
75
    exit_status = EXIT_FAILURE;
 
76
    goto child_out;
 
77
  }
 
78
 
 
79
  glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_texture_size);
 
80
  
 
81
  printf ("%u", max_texture_size);
 
82
 
 
83
child_out:
 
84
  XCloseDisplay (dpy);
 
85
  exit (exit_status);
 
86
}