OpenGL hardware acceleration defaults on
authorSam Lantinga <slouken@libsdl.org>
Tue, 15 Dec 2009 20:36:31 +0000
changeset 35707812d3e9564e
parent 3569 7f743e9b0b5b
child 3571 19691cebb866
OpenGL hardware acceleration defaults on
src/video/SDL_video.c
src/video/cocoa/SDL_cocoaopengl.m
src/video/win32/SDL_win32opengl.c
src/video/x11/SDL_x11opengl.c
test/testgl.c
test/testgl2.c
     1.1 --- a/src/video/SDL_video.c	Tue Dec 15 20:14:50 2009 +0000
     1.2 +++ b/src/video/SDL_video.c	Tue Dec 15 20:36:31 2009 +0000
     1.3 @@ -239,7 +239,7 @@
     1.4      _this->gl_config.multisamplebuffers = 0;
     1.5      _this->gl_config.multisamplesamples = 0;
     1.6      _this->gl_config.retained_backing = 1;
     1.7 -    _this->gl_config.accelerated = -1;  /* not known, don't set */
     1.8 +    _this->gl_config.accelerated = 1;
     1.9      _this->gl_config.major_version = 2;
    1.10      _this->gl_config.minor_version = 1;
    1.11  
    1.12 @@ -3274,7 +3274,7 @@
    1.13      case SDL_GL_ACCELERATED_VISUAL:
    1.14          {
    1.15              /* FIXME: How do we get this information? */
    1.16 -            *value = (_this->gl_config.accelerated != 0);
    1.17 +            *value = _this->gl_config.accelerated;
    1.18              return 0;
    1.19          }
    1.20      default:
     2.1 --- a/src/video/cocoa/SDL_cocoaopengl.m	Tue Dec 15 20:14:50 2009 +0000
     2.2 +++ b/src/video/cocoa/SDL_cocoaopengl.m	Tue Dec 15 20:36:31 2009 +0000
     2.3 @@ -28,6 +28,7 @@
     2.4  #if SDL_VIDEO_OPENGL_CGL
     2.5  #include <OpenGL/CGLTypes.h>
     2.6  #include <OpenGL/OpenGL.h>
     2.7 +#include <OpenGL/CGLRenderers.h>
     2.8  
     2.9  #include "SDL_loadso.h"
    2.10  #include "SDL_opengl.h"
    2.11 @@ -132,8 +133,11 @@
    2.12          attr[i++] = NSOpenGLPFANoRecovery;
    2.13      }
    2.14  
    2.15 -    if (_this->gl_config.accelerated > 0) {
    2.16 +    if (_this->gl_config.accelerated) {
    2.17          attr[i++] = NSOpenGLPFAAccelerated;
    2.18 +    } else {
    2.19 +        attr[i++] = NSOpenGLPFARendererID;
    2.20 +        attr[i++] = kCGLRendererGenericFloatID;
    2.21      }
    2.22  
    2.23      attr[i++] = NSOpenGLPFAScreenMask;
     3.1 --- a/src/video/win32/SDL_win32opengl.c	Tue Dec 15 20:14:50 2009 +0000
     3.2 +++ b/src/video/win32/SDL_win32opengl.c	Tue Dec 15 20:36:31 2009 +0000
     3.3 @@ -469,12 +469,9 @@
     3.4          *iAttr++ = _this->gl_config.multisamplesamples;
     3.5      }
     3.6  
     3.7 -    if (_this->gl_config.accelerated >= 0) {
     3.8 -        *iAttr++ = WGL_ACCELERATION_ARB;
     3.9 -        *iAttr++ =
    3.10 -            (_this->gl_config.accelerated ? WGL_GENERIC_ACCELERATION_ARB :
    3.11 -             WGL_NO_ACCELERATION_ARB);
    3.12 -    }
    3.13 +    *iAttr++ = WGL_ACCELERATION_ARB;
    3.14 +    *iAttr++ = (_this->gl_config.accelerated ? WGL_GENERIC_ACCELERATION_ARB :
    3.15 +                                               WGL_NO_ACCELERATION_ARB);
    3.16  
    3.17      *iAttr = 0;
    3.18  
     4.1 --- a/src/video/x11/SDL_x11opengl.c	Tue Dec 15 20:14:50 2009 +0000
     4.2 +++ b/src/video/x11/SDL_x11opengl.c	Tue Dec 15 20:36:31 2009 +0000
     4.3 @@ -359,17 +359,19 @@
     4.4          attribs[i++] = _this->gl_config.multisamplesamples;
     4.5      }
     4.6  
     4.7 -    if (_this->gl_config.accelerated >= 0
     4.8 -        && _this->gl_data->HAS_GLX_EXT_visual_rating) {
     4.9 +    if (_this->gl_data->HAS_GLX_EXT_visual_rating) {
    4.10          attribs[i++] = GLX_VISUAL_CAVEAT_EXT;
    4.11 -        attribs[i++] = GLX_NONE_EXT;
    4.12 +        attribs[i++] = _this->gl_config.accelerated ? GLX_NONE_EXT :
    4.13 +                                                      GLX_SLOW_VISUAL_EXT;
    4.14      }
    4.15 +
    4.16  #ifdef GLX_DIRECT_COLOR         /* Try for a DirectColor visual for gamma support */
    4.17      if (X11_UseDirectColorVisuals()) {
    4.18          attribs[i++] = GLX_X_VISUAL_TYPE;
    4.19          attribs[i++] = GLX_DIRECT_COLOR;
    4.20      }
    4.21  #endif
    4.22 +
    4.23      attribs[i++] = None;
    4.24  
    4.25      vinfo = _this->gl_data->glXChooseVisual(display, screen, attribs);
     5.1 --- a/test/testgl.c	Tue Dec 15 20:14:50 2009 +0000
     5.2 +++ b/test/testgl.c	Tue Dec 15 20:36:31 2009 +0000
     5.3 @@ -370,7 +370,7 @@
     5.4  int
     5.5  RunGLTest(int argc, char *argv[],
     5.6            int logo, int logocursor, int slowly, int bpp, float gamma,
     5.7 -          int noframe, int fsaa, int sync, int accel)
     5.8 +          int noframe, int fsaa, int sync, int noaccel)
     5.9  {
    5.10      int i;
    5.11      int rgb_size[3];
    5.12 @@ -454,9 +454,7 @@
    5.13          SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
    5.14          SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa);
    5.15      }
    5.16 -    if (accel) {
    5.17 -        SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
    5.18 -    }
    5.19 +    SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, !noaccel);
    5.20      if (SDL_SetVideoMode(w, h, bpp, video_flags) == NULL) {
    5.21          fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
    5.22          SDL_Quit();
    5.23 @@ -493,10 +491,8 @@
    5.24          printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
    5.25                 value);
    5.26      }
    5.27 -    if (accel) {
    5.28 -        SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
    5.29 -        printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
    5.30 -    }
    5.31 +    SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
    5.32 +    printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", !noaccel, value);
    5.33      if (sync) {
    5.34          printf("Buffer swap interval: requested 1, got %d\n",
    5.35                 SDL_GL_GetSwapInterval());
    5.36 @@ -707,7 +703,7 @@
    5.37      float gamma = 0.0;
    5.38      int noframe = 0;
    5.39      int fsaa = 0;
    5.40 -    int accel = 0;
    5.41 +    int noaccel = 0;
    5.42      int sync = 0;
    5.43  
    5.44      logo = 0;
    5.45 @@ -738,22 +734,22 @@
    5.46          if (strcmp(argv[i], "-fsaa") == 0) {
    5.47              ++fsaa;
    5.48          }
    5.49 -        if (strcmp(argv[i], "-accel") == 0) {
    5.50 -            ++accel;
    5.51 +        if (strcmp(argv[i], "-noaccel") == 0) {
    5.52 +            ++noaccel;
    5.53          }
    5.54          if (strcmp(argv[i], "-sync") == 0) {
    5.55              ++sync;
    5.56          }
    5.57          if (strncmp(argv[i], "-h", 2) == 0) {
    5.58              printf
    5.59 -                ("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-accel] [-sync] [-fullscreen]\n",
    5.60 +                ("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-noaccel] [-sync] [-fullscreen]\n",
    5.61                   argv[0]);
    5.62              exit(0);
    5.63          }
    5.64      }
    5.65      for (i = 0; i < numtests; ++i) {
    5.66          RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma,
    5.67 -                  noframe, fsaa, sync, accel);
    5.68 +                  noframe, fsaa, sync, noaccel);
    5.69      }
    5.70      return 0;
    5.71  }
     6.1 --- a/test/testgl2.c	Tue Dec 15 20:14:50 2009 +0000
     6.2 +++ b/test/testgl2.c	Tue Dec 15 20:36:31 2009 +0000
     6.3 @@ -162,7 +162,7 @@
     6.4  int
     6.5  main(int argc, char *argv[])
     6.6  {
     6.7 -    int fsaa, accel;
     6.8 +    int fsaa, noaccel;
     6.9      int value;
    6.10      int i, done;
    6.11      SDL_DisplayMode mode;
    6.12 @@ -172,7 +172,7 @@
    6.13  
    6.14      /* Initialize parameters */
    6.15      fsaa = 0;
    6.16 -    accel = 0;
    6.17 +    noaccel = 0;
    6.18  
    6.19      /* Initialize test framework */
    6.20      state = CommonCreateState(argv, SDL_INIT_VIDEO);
    6.21 @@ -187,15 +187,15 @@
    6.22              if (SDL_strcasecmp(argv[i], "--fsaa") == 0) {
    6.23                  ++fsaa;
    6.24                  consumed = 1;
    6.25 -            } else if (SDL_strcasecmp(argv[i], "--accel") == 0) {
    6.26 -                ++accel;
    6.27 +            } else if (SDL_strcasecmp(argv[i], "--noaccel") == 0) {
    6.28 +                ++noaccel;
    6.29                  consumed = 1;
    6.30              } else {
    6.31                  consumed = -1;
    6.32              }
    6.33          }
    6.34          if (consumed < 0) {
    6.35 -            fprintf(stderr, "Usage: %s %s [--fsaa] [--accel]\n", argv[0],
    6.36 +            fprintf(stderr, "Usage: %s %s [--fsaa] [--noaccel]\n", argv[0],
    6.37                      CommonUsage(state));
    6.38              quit(1);
    6.39          }
    6.40 @@ -213,9 +213,7 @@
    6.41          state->gl_multisamplebuffers = 1;
    6.42          state->gl_multisamplesamples = fsaa;
    6.43      }
    6.44 -    if (accel) {
    6.45 -        state->gl_accelerated=1;
    6.46 -    }
    6.47 +    state->gl_accelerated = !noaccel;
    6.48  
    6.49      if (!CommonInit(state)) {
    6.50          quit(2);
    6.51 @@ -284,14 +282,13 @@
    6.52                     SDL_GetError());
    6.53          }
    6.54      }
    6.55 -    if (accel) {
    6.56 -        status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
    6.57 -        if (!status) {
    6.58 -            printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
    6.59 -        } else {
    6.60 -            printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
    6.61 -                   SDL_GetError());
    6.62 -        }
    6.63 +    status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
    6.64 +    if (!status) {
    6.65 +        printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", !noaccel,
    6.66 +               value);
    6.67 +    } else {
    6.68 +        printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
    6.69 +               SDL_GetError());
    6.70      }
    6.71  
    6.72      /* Set rendering settings */