~ubuntu-branches/ubuntu/vivid/gnome-desktop3/vivid-proposed

« 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: 2014-09-12 07:22:38 UTC
  • mfrom: (1.6.4) (31.1.1 utopic-proposed)
  • Revision ID: package-import@ubuntu.com-20140912072238-fv5g0rpwuk5yynip
Tags: 3.12.2-2ubuntu1
* New upstream release (LP: #1372346)
* Merge with Debian, 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/rules:
    + drop obsolete --disable-scrollkeeper configure flag
  - debian/libgnome-desktop-3-10.symbols:
    + Add symbols included in Ubuntu patches
  - debian/control.in:
    + Mark gnome-desktop3-data Multi-Arch: foreign
* Dropped changes:
  - 02_refuse_to_break_GL_compositors.patch:
    + xrandr code has moved into libunity-settings-daemon now

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
 
}