Merged SDL_GL_SWAP_CONTROL fix from SDL 1.2 SDL-1.3
authorSam Lantinga <slouken@libsdl.org>
Sat, 24 Jun 2006 02:48:55 +0000
branchSDL-1.3
changeset 1703a51dfda0ff33
parent 1702 a7ad7081b977
child 1704 03fb364e3283
Merged SDL_GL_SWAP_CONTROL fix from SDL 1.2
src/video/wincommon/SDL_wingl.c
src/video/x11/SDL_x11gl.c
test/testgl.c
     1.1 --- a/src/video/wincommon/SDL_wingl.c	Fri Jun 23 09:01:08 2006 +0000
     1.2 +++ b/src/video/wincommon/SDL_wingl.c	Sat Jun 24 02:48:55 2006 +0000
     1.3 @@ -150,8 +150,8 @@
     1.4          this->gl_data->wglChoosePixelFormatARB = (BOOL(WINAPI *)
     1.5                                                    (HDC, const int *,
     1.6                                                     const FLOAT *, UINT, int *,
     1.7 -                                                   UINT *)) this->gl_data->
     1.8 -            wglGetProcAddress("wglChoosePixelFormatARB");
     1.9 +                                                   UINT *))
    1.10 +            this->gl_data->wglGetProcAddress("wglChoosePixelFormatARB");
    1.11          this->gl_data->wglGetPixelFormatAttribivARB =
    1.12              (BOOL(WINAPI *) (HDC, int, int, UINT, const int *, int *))
    1.13              this->gl_data->wglGetProcAddress("wglGetPixelFormatAttribivARB");
    1.14 @@ -357,7 +357,12 @@
    1.15          /* Uh oh, something is seriously wrong here... */
    1.16          wglext = NULL;
    1.17      }
    1.18 -    if (!wglext || !SDL_strstr(wglext, "WGL_EXT_swap_control")) {
    1.19 +    if (wglext && SDL_strstr(wglext, "WGL_EXT_swap_control")) {
    1.20 +        this->gl_data->wglSwapIntervalEXT =
    1.21 +            WIN_GL_GetProcAddress(this, "wglSwapIntervalEXT");
    1.22 +        this->gl_data->wglGetSwapIntervalEXT =
    1.23 +            WIN_GL_GetProcAddress(this, "wglGetSwapIntervalEXT");
    1.24 +    } else {
    1.25          this->gl_data->wglSwapIntervalEXT = NULL;
    1.26          this->gl_data->wglGetSwapIntervalEXT = NULL;
    1.27      }
    1.28 @@ -470,9 +475,8 @@
    1.29              break;
    1.30          case SDL_GL_ACCELERATED_VISUAL:
    1.31              wgl_attrib = WGL_ACCELERATION_ARB;
    1.32 -            this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc,
    1.33 -                                                        pixel_format, 0,
    1.34 -                                                        1, &wgl_attrib,
    1.35 +            this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format,
    1.36 +                                                        0, 1, &wgl_attrib,
    1.37                                                          value);
    1.38              if (*value == WGL_NO_ACCELERATION_ARB) {
    1.39                  *value = SDL_FALSE;
    1.40 @@ -483,15 +487,17 @@
    1.41              break;
    1.42          case SDL_GL_SWAP_CONTROL:
    1.43              if (this->gl_data->wglGetSwapIntervalEXT) {
    1.44 -                return this->gl_data->wglGetSwapIntervalEXT();
    1.45 +                *value = this->gl_data->wglGetSwapIntervalEXT();
    1.46 +                return 0;
    1.47              } else {
    1.48                  return -1;
    1.49              }
    1.50 +            break;
    1.51          default:
    1.52              return (-1);
    1.53          }
    1.54 -        this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format,
    1.55 -                                                    0, 1, &wgl_attrib, value);
    1.56 +        this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format, 0,
    1.57 +                                                    1, &wgl_attrib, value);
    1.58  
    1.59          return 0;
    1.60      }
    1.61 @@ -551,6 +557,14 @@
    1.62      case SDL_GL_MULTISAMPLESAMPLES:
    1.63          *value = 1;
    1.64          break;
    1.65 +    case SDL_GL_SWAP_CONTROL:
    1.66 +        if (this->gl_data->wglGetSwapIntervalEXT) {
    1.67 +            *value = this->gl_data->wglGetSwapIntervalEXT();
    1.68 +            return 0;
    1.69 +        } else {
    1.70 +            return -1;
    1.71 +        }
    1.72 +        break;
    1.73      default:
    1.74          retval = -1;
    1.75          break;
    1.76 @@ -653,4 +667,5 @@
    1.77  }
    1.78  
    1.79  #endif /* SDL_VIDEO_OPENGL */
    1.80 +
    1.81  /* vi: set ts=4 sw=4 expandtab: */
     2.1 --- a/src/video/x11/SDL_x11gl.c	Fri Jun 23 09:01:08 2006 +0000
     2.2 +++ b/src/video/x11/SDL_x11gl.c	Sat Jun 24 02:48:55 2006 +0000
     2.3 @@ -411,9 +411,10 @@
     2.4          break;
     2.5      case SDL_GL_SWAP_CONTROL:
     2.6          if (this->gl_data->glXGetSwapIntervalMESA) {
     2.7 -            return this->gl_data->glXGetSwapIntervalMESA();
     2.8 +            *value = this->gl_data->glXGetSwapIntervalMESA();
     2.9 +            return (0);
    2.10          } else {
    2.11 -            return (-1) /*(this->gl_config.swap_control > 0) */ ;
    2.12 +            return (-1);
    2.13          }
    2.14          break;
    2.15      default:
    2.16 @@ -567,3 +568,5 @@
    2.17  }
    2.18  
    2.19  #endif /* SDL_VIDEO_OPENGL_GLX */
    2.20 +
    2.21 +/* vi: set ts=4 sw=4 expandtab: */
     3.1 --- a/test/testgl.c	Fri Jun 23 09:01:08 2006 +0000
     3.2 +++ b/test/testgl.c	Sat Jun 24 02:48:55 2006 +0000
     3.3 @@ -746,7 +746,7 @@
     3.4          }
     3.5          if (strncmp(argv[i], "-h", 2) == 0) {
     3.6              printf
     3.7 -                ("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-fullscreen]\n",
     3.8 +                ("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-accel] [-sync] [-fullscreen]\n",
     3.9                   argv[0]);
    3.10              exit(0);
    3.11          }