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