~oem-solutions-group/unity-2d/clutter-1.0

« back to all changes in this revision

Viewing changes to clutter/cogl/cogl/winsys/cogl-glx.c

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2010-03-21 13:27:56 UTC
  • mto: (2.1.3 experimental)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100321132756-nf8yd30yxo3zzwcm
Tags: upstream-1.2.2
ImportĀ upstreamĀ versionĀ 1.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Cogl
 
3
 *
 
4
 * An object oriented GL/GLES Abstraction/Utility Layer
 
5
 *
 
6
 * Copyright (C) 2007,2008,2009 Intel Corporation.
 
7
 *
 
8
 * This library is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU Lesser General Public
 
10
 * License as published by the Free Software Foundation; either
 
11
 * version 2 of the License, or (at your option) any later version.
 
12
 *
 
13
 * This library is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * Lesser General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU Lesser General Public
 
19
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 
20
 *
 
21
 *
 
22
 */
 
23
 
 
24
#ifdef HAVE_CONFIG_H
 
25
#include "config.h"
 
26
#endif
 
27
 
 
28
#include "cogl.h"
 
29
 
 
30
#ifdef HAVE_CLUTTER_GLX
 
31
#include <dlfcn.h>
 
32
#include <GL/glx.h>
 
33
 
 
34
typedef CoglFuncPtr (*GLXGetProcAddressProc) (const GLubyte *procName);
 
35
#endif
 
36
 
 
37
 
 
38
CoglFuncPtr
 
39
_cogl_winsys_get_proc_address (const char *name)
 
40
{
 
41
  static GLXGetProcAddressProc get_proc_func = NULL;
 
42
  static void                 *dlhand = NULL;
 
43
 
 
44
  if (get_proc_func == NULL && dlhand == NULL)
 
45
    {
 
46
      dlhand = dlopen (NULL, RTLD_LAZY);
 
47
 
 
48
      if (!dlhand)
 
49
        {
 
50
          g_warning ("Failed to dlopen (NULL, RTDL_LAZY): %s", dlerror ());
 
51
          return NULL;
 
52
        }
 
53
 
 
54
      dlerror ();
 
55
 
 
56
      get_proc_func =
 
57
        (GLXGetProcAddressProc) dlsym (dlhand, "glXGetProcAddress");
 
58
 
 
59
      if (dlerror () != NULL)
 
60
        {
 
61
          get_proc_func =
 
62
            (GLXGetProcAddressProc) dlsym (dlhand, "glXGetProcAddressARB");
 
63
        }
 
64
 
 
65
      if (dlerror () != NULL)
 
66
        {
 
67
          get_proc_func = NULL;
 
68
          g_warning ("failed to bind GLXGetProcAddress "
 
69
                     "or GLXGetProcAddressARB");
 
70
        }
 
71
    }
 
72
 
 
73
  if (get_proc_func)
 
74
    return get_proc_func ((GLubyte *) name);
 
75
 
 
76
  return NULL;
 
77
}
 
78