configure: allow C{,XX}FLAGS override
[mesa.git] / src / glut / glx / glut_mesa.c
1
2 /* Copyright (c) Mark J. Kilgard, 1996. */
3
4 /* This program is freely distributable without licensing fees
5 and is provided without guarantee or warrantee expressed or
6 implied. This program is -not- in the public domain. */
7
8 #include <stdlib.h>
9 #include <string.h>
10 #include "glutint.h"
11
12 int __glutMesaSwapHackSupport = 0; /* Not supported until
13 proven otherwise. */
14
15 /* Use the "Mesa swap hack" if reasonable if and only if
16 MESA_SWAP_HACK is set to something whose first character is
17 not "N" or "n" AND "Brian Paul" is the vendor string AND
18 "Mesa X11"* (or "Mesa" for backward compatibility) is the
19 renderer string.
20
21 Anyone who modifies Mesa so that glXSwapBuffers does not
22 simply blit the previously rendered back buffer should
23 change either their vendor or renderer string to avoid
24 confusing GLUT. */
25
26 void
27 __glutDetermineMesaSwapHackSupport(void)
28 {
29 static int doneAlready = 0;
30 char *env, *vendor, *renderer;
31
32 if (doneAlready)
33 return;
34 env = getenv("MESA_SWAP_HACK");
35 if (env) {
36 if ((env[0] != 'n') && (env[0] != 'N')) {
37 vendor = (char *) glGetString(GL_VENDOR);
38 renderer = (char *) glGetString(GL_RENDERER);
39
40 /* Old versions of X11 Mesa uses the renderer string
41 "Mesa"; Brian plans to start using "Mesa X11" to
42 distinguish the X version of Mesa from other flavor
43 such as Windows or 3Dfx. */
44
45 #define MESA_X11 "Mesa X11"
46
47 /* XXX At some point in the future, eliminate the
48 backward compatibility for the old "Mesa" renderer
49 string. */
50
51 if (!strcmp(vendor, "Brian Paul") && (!strcmp(renderer, "Mesa") ||
52 !strncmp(renderer, MESA_X11, sizeof(MESA_X11) - 1)))
53 __glutMesaSwapHackSupport = 1;
54 }
55 }
56 doneAlready = 1;
57 }