Default to allow either accelerated or not
authorSam Lantinga <slouken@libsdl.org>
Tue, 15 Dec 2009 20:53:09 +0000
changeset 357119691cebb866
parent 3570 7812d3e9564e
child 3572 6bb9952d5029
Default to allow either accelerated or not
src/video/SDL_video.c
src/video/cocoa/SDL_cocoaopengl.m
src/video/win32/SDL_win32opengl.c
src/video/x11/SDL_x11opengl.c
test/common.c
test/testgl.c
test/testgl2.c
     1.1 --- a/src/video/SDL_video.c	Tue Dec 15 20:36:31 2009 +0000
     1.2 +++ b/src/video/SDL_video.c	Tue Dec 15 20:53:09 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;
     1.8 +    _this->gl_config.accelerated = -1;  /* accelerated or not, both are fine */
     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;
    1.17 +            *value = (_this->gl_config.accelerated != 0);
    1.18              return 0;
    1.19          }
    1.20      default:
     2.1 --- a/src/video/cocoa/SDL_cocoaopengl.m	Tue Dec 15 20:36:31 2009 +0000
     2.2 +++ b/src/video/cocoa/SDL_cocoaopengl.m	Tue Dec 15 20:53:09 2009 +0000
     2.3 @@ -133,11 +133,13 @@
     2.4          attr[i++] = NSOpenGLPFANoRecovery;
     2.5      }
     2.6  
     2.7 -    if (_this->gl_config.accelerated) {
     2.8 -        attr[i++] = NSOpenGLPFAAccelerated;
     2.9 -    } else {
    2.10 -        attr[i++] = NSOpenGLPFARendererID;
    2.11 -        attr[i++] = kCGLRendererGenericFloatID;
    2.12 +    if (_this->gl_config.accelerated >= 0) {
    2.13 +        if (_this->gl_config.accelerated) {
    2.14 +            attr[i++] = NSOpenGLPFAAccelerated;
    2.15 +        } else {
    2.16 +            attr[i++] = NSOpenGLPFARendererID;
    2.17 +            attr[i++] = kCGLRendererGenericFloatID;
    2.18 +        }
    2.19      }
    2.20  
    2.21      attr[i++] = NSOpenGLPFAScreenMask;
     3.1 --- a/src/video/win32/SDL_win32opengl.c	Tue Dec 15 20:36:31 2009 +0000
     3.2 +++ b/src/video/win32/SDL_win32opengl.c	Tue Dec 15 20:53:09 2009 +0000
     3.3 @@ -469,9 +469,12 @@
     3.4          *iAttr++ = _this->gl_config.multisamplesamples;
     3.5      }
     3.6  
     3.7 -    *iAttr++ = WGL_ACCELERATION_ARB;
     3.8 -    *iAttr++ = (_this->gl_config.accelerated ? WGL_GENERIC_ACCELERATION_ARB :
     3.9 -                                               WGL_NO_ACCELERATION_ARB);
    3.10 +    if (_this->gl_config.accelerated >= 0) {
    3.11 +        *iAttr++ = WGL_ACCELERATION_ARB;
    3.12 +        *iAttr++ =
    3.13 +            (_this->gl_config.accelerated ? WGL_GENERIC_ACCELERATION_ARB :
    3.14 +             WGL_NO_ACCELERATION_ARB);
    3.15 +    }
    3.16  
    3.17      *iAttr = 0;
    3.18  
     4.1 --- a/src/video/x11/SDL_x11opengl.c	Tue Dec 15 20:36:31 2009 +0000
     4.2 +++ b/src/video/x11/SDL_x11opengl.c	Tue Dec 15 20:53:09 2009 +0000
     4.3 @@ -359,7 +359,8 @@
     4.4          attribs[i++] = _this->gl_config.multisamplesamples;
     4.5      }
     4.6  
     4.7 -    if (_this->gl_data->HAS_GLX_EXT_visual_rating) {
     4.8 +    if (_this->gl_config.accelerated >= 0 &&
     4.9 +        _this->gl_data->HAS_GLX_EXT_visual_rating) {
    4.10          attribs[i++] = GLX_VISUAL_CAVEAT_EXT;
    4.11          attribs[i++] = _this->gl_config.accelerated ? GLX_NONE_EXT :
    4.12                                                        GLX_SLOW_VISUAL_EXT;
     5.1 --- a/test/common.c	Tue Dec 15 20:36:31 2009 +0000
     5.2 +++ b/test/common.c	Tue Dec 15 20:53:09 2009 +0000
     5.3 @@ -104,7 +104,7 @@
     5.4      state->gl_multisamplebuffers = 0;
     5.5      state->gl_multisamplesamples = 0;
     5.6      state->gl_retained_backing = 1;
     5.7 -    state->gl_accelerated = 1;
     5.8 +    state->gl_accelerated = -1;
     5.9      state->gl_major_version = 2;
    5.10      state->gl_minor_version = 1;
    5.11  
    5.12 @@ -659,7 +659,10 @@
    5.13          SDL_GL_SetAttribute(SDL_GL_STEREO, state->gl_stereo);
    5.14          SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, state->gl_multisamplebuffers);
    5.15          SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, state->gl_multisamplesamples);
    5.16 -        SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, state->gl_accelerated);
    5.17 +        if (state->gl_accelerated >= 0) {
    5.18 +            SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL,
    5.19 +                                state->gl_accelerated);
    5.20 +        }
    5.21          SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, state->gl_retained_backing);
    5.22          SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, state->gl_major_version);
    5.23          SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, state->gl_minor_version);
     6.1 --- a/test/testgl.c	Tue Dec 15 20:36:31 2009 +0000
     6.2 +++ b/test/testgl.c	Tue Dec 15 20:53:09 2009 +0000
     6.3 @@ -370,7 +370,7 @@
     6.4  int
     6.5  RunGLTest(int argc, char *argv[],
     6.6            int logo, int logocursor, int slowly, int bpp, float gamma,
     6.7 -          int noframe, int fsaa, int sync, int noaccel)
     6.8 +          int noframe, int fsaa, int sync, int accel)
     6.9  {
    6.10      int i;
    6.11      int rgb_size[3];
    6.12 @@ -454,7 +454,9 @@
    6.13          SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
    6.14          SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa);
    6.15      }
    6.16 -    SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, !noaccel);
    6.17 +    if (accel >= 0) {
    6.18 +        SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, accel);
    6.19 +    }
    6.20      if (SDL_SetVideoMode(w, h, bpp, video_flags) == NULL) {
    6.21          fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
    6.22          SDL_Quit();
    6.23 @@ -491,8 +493,11 @@
    6.24          printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
    6.25                 value);
    6.26      }
    6.27 -    SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
    6.28 -    printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", !noaccel, value);
    6.29 +    if (accel >= 0) {
    6.30 +        SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
    6.31 +        printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
    6.32 +               value);
    6.33 +    }
    6.34      if (sync) {
    6.35          printf("Buffer swap interval: requested 1, got %d\n",
    6.36                 SDL_GL_GetSwapInterval());
    6.37 @@ -703,7 +708,7 @@
    6.38      float gamma = 0.0;
    6.39      int noframe = 0;
    6.40      int fsaa = 0;
    6.41 -    int noaccel = 0;
    6.42 +    int accel = -1;
    6.43      int sync = 0;
    6.44  
    6.45      logo = 0;
    6.46 @@ -734,22 +739,22 @@
    6.47          if (strcmp(argv[i], "-fsaa") == 0) {
    6.48              ++fsaa;
    6.49          }
    6.50 -        if (strcmp(argv[i], "-noaccel") == 0) {
    6.51 -            ++noaccel;
    6.52 +        if (strcmp(argv[i], "-accel") == 0) {
    6.53 +            accel = atoi(argv[++i]);
    6.54          }
    6.55          if (strcmp(argv[i], "-sync") == 0) {
    6.56              ++sync;
    6.57          }
    6.58          if (strncmp(argv[i], "-h", 2) == 0) {
    6.59              printf
    6.60 -                ("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-noaccel] [-sync] [-fullscreen]\n",
    6.61 +                ("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-accel n] [-sync] [-fullscreen]\n",
    6.62                   argv[0]);
    6.63              exit(0);
    6.64          }
    6.65      }
    6.66      for (i = 0; i < numtests; ++i) {
    6.67          RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma,
    6.68 -                  noframe, fsaa, sync, noaccel);
    6.69 +                  noframe, fsaa, sync, accel);
    6.70      }
    6.71      return 0;
    6.72  }
     7.1 --- a/test/testgl2.c	Tue Dec 15 20:36:31 2009 +0000
     7.2 +++ b/test/testgl2.c	Tue Dec 15 20:53:09 2009 +0000
     7.3 @@ -162,7 +162,7 @@
     7.4  int
     7.5  main(int argc, char *argv[])
     7.6  {
     7.7 -    int fsaa, noaccel;
     7.8 +    int fsaa, accel;
     7.9      int value;
    7.10      int i, done;
    7.11      SDL_DisplayMode mode;
    7.12 @@ -172,7 +172,7 @@
    7.13  
    7.14      /* Initialize parameters */
    7.15      fsaa = 0;
    7.16 -    noaccel = 0;
    7.17 +    accel = -1;
    7.18  
    7.19      /* Initialize test framework */
    7.20      state = CommonCreateState(argv, SDL_INIT_VIDEO);
    7.21 @@ -187,15 +187,15 @@
    7.22              if (SDL_strcasecmp(argv[i], "--fsaa") == 0) {
    7.23                  ++fsaa;
    7.24                  consumed = 1;
    7.25 -            } else if (SDL_strcasecmp(argv[i], "--noaccel") == 0) {
    7.26 -                ++noaccel;
    7.27 -                consumed = 1;
    7.28 +            } else if (SDL_strcasecmp(argv[i], "--accel") == 0 && i+1 < argc) {
    7.29 +                accel = atoi(argv[i+1]);
    7.30 +                consumed = 2;
    7.31              } else {
    7.32                  consumed = -1;
    7.33              }
    7.34          }
    7.35          if (consumed < 0) {
    7.36 -            fprintf(stderr, "Usage: %s %s [--fsaa] [--noaccel]\n", argv[0],
    7.37 +            fprintf(stderr, "Usage: %s %s [--fsaa] [--accel n]\n", argv[0],
    7.38                      CommonUsage(state));
    7.39              quit(1);
    7.40          }
    7.41 @@ -213,7 +213,9 @@
    7.42          state->gl_multisamplebuffers = 1;
    7.43          state->gl_multisamplesamples = fsaa;
    7.44      }
    7.45 -    state->gl_accelerated = !noaccel;
    7.46 +    if (accel >= 0) {
    7.47 +        state->gl_accelerated = accel;
    7.48 +    }
    7.49  
    7.50      if (!CommonInit(state)) {
    7.51          quit(2);
    7.52 @@ -282,13 +284,15 @@
    7.53                     SDL_GetError());
    7.54          }
    7.55      }
    7.56 -    status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
    7.57 -    if (!status) {
    7.58 -        printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", !noaccel,
    7.59 -               value);
    7.60 -    } else {
    7.61 -        printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
    7.62 -               SDL_GetError());
    7.63 +    if (accel >= 0) {
    7.64 +        status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
    7.65 +        if (!status) {
    7.66 +            printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
    7.67 +                   value);
    7.68 +        } else {
    7.69 +            printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
    7.70 +                   SDL_GetError());
    7.71 +        }
    7.72      }
    7.73  
    7.74      /* Set rendering settings */