| 1 | /* $Id: glut_mesa.c,v 1.2 2000-02-09 08:46:14 jeroen Exp $ */
|
|---|
| 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 | /*#ifdef __WIN32OS2__
|
|---|
| 33 | __glutMesaSwapHackSupport=1;
|
|---|
| 34 | return;
|
|---|
| 35 | #endif*/
|
|---|
| 36 |
|
|---|
| 37 | if (doneAlready)
|
|---|
| 38 | return;
|
|---|
| 39 | env = getenv("MESA_SWAP_HACK");
|
|---|
| 40 | if (env) {
|
|---|
| 41 | if ((env[0] != 'n') && (env[0] != 'N')) {
|
|---|
| 42 | vendor = (char *) glGetString(GL_VENDOR);
|
|---|
| 43 | renderer = (char *) glGetString(GL_RENDERER);
|
|---|
| 44 |
|
|---|
| 45 | /* Old versions of X11 Mesa uses the renderer string
|
|---|
| 46 | "Mesa"; Brian plans to start using "Mesa X11" to
|
|---|
| 47 | distinguish the X version of Mesa from other flavor
|
|---|
| 48 | such as Windows or 3Dfx. */
|
|---|
| 49 |
|
|---|
| 50 | #define MESA_X11 "Mesa X11"
|
|---|
| 51 |
|
|---|
| 52 | /* XXX At some point in the future, eliminate the
|
|---|
| 53 | backward compatibility for the old "Mesa" renderer
|
|---|
| 54 | string. */
|
|---|
| 55 |
|
|---|
| 56 | if (!strcmp(vendor, "Brian Paul") && (!strcmp(renderer, "Mesa") ||
|
|---|
| 57 | !strncmp(renderer, MESA_X11, sizeof(MESA_X11) - 1)))
|
|---|
| 58 | __glutMesaSwapHackSupport = 1;
|
|---|
| 59 | }
|
|---|
| 60 | }
|
|---|
| 61 | doneAlready = 1;
|
|---|
| 62 | }
|
|---|