1 /*
2  * Cogl
3  *
4  * A Low Level GPU Graphics and Utilities API
5  *
6  * Copyright (C) 2011 Intel Corporation.
7  *
8  * Permission is hereby granted, free of charge, to any person
9  * obtaining a copy of this software and associated documentation
10  * files (the "Software"), to deal in the Software without
11  * restriction, including without limitation the rights to use, copy,
12  * modify, merge, publish, distribute, sublicense, and/or sell copies
13  * of the Software, and to permit persons to whom the Software is
14  * furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26  * SOFTWARE.
27  *
28  *
29  */
30 
31 #ifndef __COGL_RENDERER_GLX_PRIVATE_H
32 #define __COGL_RENDERER_GLX_PRIVATE_H
33 
34 #include <gmodule.h>
35 #include "cogl-object-private.h"
36 #include "cogl-xlib-renderer-private.h"
37 
38 typedef struct _CoglGLXRenderer
39 {
40   int glx_major;
41   int glx_minor;
42 
43   int glx_error_base;
44   int glx_event_base;
45 
46   /* Vblank stuff */
47   int dri_fd;
48 
49   /* enumeration with relatioship between OML_sync_control
50    * UST (unadjusted-system-time) and the system clock */
51   enum
52 {
53     COGL_GLX_UST_IS_UNKNOWN,
54     COGL_GLX_UST_IS_GETTIMEOFDAY,
55     COGL_GLX_UST_IS_MONOTONIC_TIME,
56     COGL_GLX_UST_IS_OTHER
57   } ust_type;
58 
59   /* GModule pointing to libGL which we use to get glX functions out of */
60   GModule *libgl_module;
61 
62   CoglClosure *flush_notifications_idle;
63 
64   /* Copy of the winsys features that are based purely on the
65    * information we can get without using a GL context. We want to
66    * determine this before we have a context so that we can use the
67    * function pointers from the extensions earlier. This is necessary
68    * to use the glXCreateContextAttribs function. */
69   unsigned long base_winsys_features
70     [COGL_FLAGS_N_LONGS_FOR_SIZE (COGL_WINSYS_FEATURE_N_FEATURES)];
71 
72   /* Function pointers for core GLX functionality. We can't just link
73      against these directly because we need to conditionally load
74      libGL when we are using GLX so that it won't conflict with a GLES
75      library if we are using EGL + GLES. These are just the functions
76      that we want to use before calling glXGetProcAddress */
77   Bool
78   (* glXQueryExtension) (Display *dpy, int *errorb, int *event);
79   const char *
80   (* glXQueryExtensionsString) (Display *dpy, int screen);
81   Bool
82   (* glXQueryVersion) (Display *dpy, int *maj, int *min);
83   void *
84   (* glXGetProcAddress) (const GLubyte *procName);
85 
86   int
87   (* glXQueryDrawable) (Display *dpy, GLXDrawable drawable,
88                         int attribute, unsigned int *value);
89 
90   /* Function pointers for GLX specific extensions */
91 #define COGL_WINSYS_FEATURE_BEGIN(a, b, c, d, e, f, g)
92 
93 #define COGL_WINSYS_FEATURE_FUNCTION(ret, name, args) \
94   ret (APIENTRY * name) args;
95 
96 #define COGL_WINSYS_FEATURE_END()
97 
98 #include "winsys/cogl-winsys-glx-feature-functions.h"
99 
100 #undef COGL_WINSYS_FEATURE_BEGIN
101 #undef COGL_WINSYS_FEATURE_FUNCTION
102 #undef COGL_WINSYS_FEATURE_END
103 } CoglGLXRenderer;
104 
105 #endif /* __COGL_RENDERER_GLX_PRIVATE_H */
106