1 /*
2  * Cogl
3  *
4  * A Low Level GPU Graphics and Utilities API
5  *
6  * Copyright (C) 2009 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_FEATURE_PRIVATE_H
32 #define __COGL_FEATURE_PRIVATE_H
33 
34 #include <glib.h>
35 
36 
37 #define COGL_CHECK_GL_VERSION(driver_major, driver_minor, \
38                               target_major, target_minor) \
39   ((driver_major) > (target_major) || \
40    ((driver_major) == (target_major) && (driver_minor) >= (target_minor)))
41 
42 typedef enum
43 {
44   COGL_EXT_IN_GLES = (1 << 0),
45   COGL_EXT_IN_GLES2 = (1 << 1),
46   COGL_EXT_IN_GLES3 = (1 << 2)
47 } CoglExtGlesAvailability;
48 
49 typedef struct _CoglFeatureFunction CoglFeatureFunction;
50 
51 struct _CoglFeatureFunction
52 {
53   /* The name of the function without the "EXT" or "ARB" suffix */
54   const char *name;
55   /* The offset in the context of where to store the function pointer */
56   unsigned int pointer_offset;
57 };
58 
59 typedef struct _CoglFeatureData CoglFeatureData;
60 
61 struct _CoglFeatureData
62 {
63   /* A minimum GL version which the functions should be defined in
64      without needing an extension. Set to 255,255 if it's only
65      provided in an extension */
66   int min_gl_major, min_gl_minor;
67   /* Flags specifying which versions of GLES the feature is available
68      in core in */
69   CoglExtGlesAvailability gles_availability;
70   /* \0 separated list of namespaces to try. Eg "EXT\0ARB\0" */
71   const char *namespaces;
72   /* \0 separated list of required extension names without the GL_EXT
73      or GL_ARB prefix. Any of the extensions must be available for the
74      feature to be considered available. If the suffix for an
75      extension is different from the namespace, you can specify it
76      with a ':' after the namespace */
77   const char *extension_names;
78   /* A set of feature flags to enable if the extension is available */
79   CoglFeatureFlags feature_flags;
80   /* A set of private feature flags to enable if the extension is
81    * available */
82   int feature_flags_private;
83   /* An optional corresponding winsys feature. */
84   CoglWinsysFeature winsys_feature;
85   /* A list of functions required for this feature. Terminated with a
86      NULL name */
87   const CoglFeatureFunction *functions;
88 };
89 
90 CoglBool
91 _cogl_feature_check (CoglRenderer *renderer,
92                      const char *driver_prefix,
93                      const CoglFeatureData *data,
94                      int gl_major,
95                      int gl_minor,
96                      CoglDriver driver,
97                      char * const *extensions,
98                      void *function_table);
99 
100 void
101 _cogl_feature_check_ext_functions (CoglContext *context,
102                                    int gl_major,
103                                    int gl_minor,
104                                    char * const *gl_extensions);
105 
106 #endif /* __COGL_FEATURE_PRIVATE_H */
107