]> git.cworth.org Git - fips/blob - fips-dispatch-gl.c
Push final collection of CFLAGS/LDFLAGS from Makefile.config to Makefile.local
[fips] / fips-dispatch-gl.c
1 /* Copyright © 2012, Intel Corporation
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to deal
5  * in the Software without restriction, including without limitation the rights
6  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7  * copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19  * THE SOFTWARE.
20  */
21
22 #include "fips-dispatch-gl.h"
23
24 static void
25 check_initialized (void)
26 {
27         if (fips_dispatch_initialized)
28                 return;
29
30         fprintf (stderr,
31                  "Internal error: fips_dispatch_init must be called before\n"
32                  "any OpenGL function supported via fips_dispatch.\n");
33         exit (1);
34 }
35
36 static void
37 unsupported (const char *name)
38 {
39         fprintf (stderr, "Error: fips failed to find support for %s\n", name);
40
41         exit (1);
42 }
43
44 static void
45 resolve_glGenQueries (void)
46 {
47         fips_dispatch_glGenQueries = fips_dispatch_lookup ("glGenQueries");
48
49         if (! fips_dispatch_glGenQueries)
50                 fips_dispatch_glGenQueries = fips_dispatch_lookup ("glGenQueriesARB");
51
52         if (! fips_dispatch_glGenQueries)
53                 unsupported ("GenQueries");
54 }
55
56 static void
57 stub_glGenQueries (GLsizei n, GLuint *ids)
58 {
59         check_initialized ();
60         resolve_glGenQueries ();
61         fips_dispatch_glGenQueries (n, ids);
62 }
63
64 PFNGLGENQUERIESPROC fips_dispatch_glGenQueries = stub_glGenQueries;
65
66 static void
67 resolve_glDeleteQueries (void)
68 {
69         fips_dispatch_glDeleteQueries = fips_dispatch_lookup ("glDeleteQueries");
70
71         if (! fips_dispatch_glDeleteQueries)
72                 fips_dispatch_glDeleteQueries = fips_dispatch_lookup ("glDeleteQueriesARB");
73
74         if (! fips_dispatch_glDeleteQueries)
75                 unsupported ("DeleteQueries");
76 }
77
78 static void
79 stub_glDeleteQueries (GLsizei n, const GLuint * ids)
80 {
81         check_initialized ();
82         resolve_glDeleteQueries ();
83         fips_dispatch_glDeleteQueries (n, ids);
84 }
85
86 PFNGLDELETEQUERIESPROC fips_dispatch_glDeleteQueries = stub_glDeleteQueries;
87
88 static void
89 resolve_glBeginQuery (void)
90 {
91         fips_dispatch_glBeginQuery = fips_dispatch_lookup ("glBeginQuery");
92
93         if (! fips_dispatch_glBeginQuery)
94                 fips_dispatch_glBeginQuery = fips_dispatch_lookup ("glBeginQueryARB");
95
96         if (! fips_dispatch_glBeginQuery)
97                 unsupported ("BeginQuery");
98 }
99
100 static void
101 stub_glBeginQuery (GLenum target, GLuint id)
102 {
103         check_initialized ();
104         resolve_glBeginQuery ();
105         fips_dispatch_glBeginQuery (target, id);
106 }
107
108 PFNGLBEGINQUERYPROC fips_dispatch_glBeginQuery = stub_glBeginQuery;
109
110 static void
111 resolve_glEndQuery (void)
112 {
113         fips_dispatch_glEndQuery = fips_dispatch_lookup ("glEndQuery");
114
115         if (! fips_dispatch_glEndQuery)
116                 fips_dispatch_glEndQuery = fips_dispatch_lookup ("glEndQueryARB");
117
118         if (! fips_dispatch_glEndQuery)
119                 unsupported ("EndQuery");
120 }
121
122 static void
123 stub_glEndQuery (GLenum target)
124 {
125         check_initialized ();
126         resolve_glEndQuery ();
127         fips_dispatch_glEndQuery (target);
128 }
129
130 PFNGLENDQUERYPROC fips_dispatch_glEndQuery = stub_glEndQuery;
131
132 static void
133 resolve_glGetQueryObjectuiv (void)
134 {
135         fips_dispatch_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC) fips_dispatch_lookup ("glGetQueryObjectuivARB");
136
137         if (! fips_dispatch_glGetQueryObjectuiv)
138                 unsupported ("GetQueryObjectuiv");
139 }
140
141 static void
142 stub_glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint * params)
143 {
144         check_initialized ();
145         resolve_glGetQueryObjectuiv ();
146         fips_dispatch_glGetQueryObjectuiv (id, pname, params);
147 }
148
149 PFNGLGETQUERYOBJECTUIVPROC fips_dispatch_glGetQueryObjectuiv = stub_glGetQueryObjectuiv;