Support for GL initialization parameters has been added.
authorMike Gorchak <lestat@i.com.ua>
Wed, 21 Oct 2009 14:51:42 +0000
changeset 340855541ddf13e3
parent 3407 d3baf5ac4e37
child 3409 c8f580ebc96a
Support for GL initialization parameters has been added.
test/common.c
test/common.h
test/testgl2.c
test/testgles.c
     1.1 --- a/test/common.c	Mon Oct 19 13:31:58 2009 +0000
     1.2 +++ b/test/common.c	Wed Oct 21 14:51:42 2009 +0000
     1.3 @@ -86,6 +86,28 @@
     1.4      state->audiospec.format = AUDIO_S16;
     1.5      state->audiospec.channels = 2;
     1.6      state->audiospec.samples = 2048;
     1.7 +
     1.8 +    /* Set some very sane GL defaults */
     1.9 +    state->gl_red_size = 3;
    1.10 +    state->gl_green_size = 3;
    1.11 +    state->gl_blue_size = 2;
    1.12 +    state->gl_alpha_size = 0;
    1.13 +    state->gl_buffer_size = 0;
    1.14 +    state->gl_depth_size = 16;
    1.15 +    state->gl_stencil_size = 0;
    1.16 +    state->gl_double_buffer = 1;
    1.17 +    state->gl_accum_red_size = 0;
    1.18 +    state->gl_accum_green_size = 0;
    1.19 +    state->gl_accum_blue_size = 0;
    1.20 +    state->gl_accum_alpha_size = 0;
    1.21 +    state->gl_stereo = 0;
    1.22 +    state->gl_multisamplebuffers = 0;
    1.23 +    state->gl_multisamplesamples = 0;
    1.24 +    state->gl_retained_backing = 1;
    1.25 +    state->gl_accelerated = 1;
    1.26 +    state->gl_major_version = 2;
    1.27 +    state->gl_minor_version = 1;
    1.28 +
    1.29      return state;
    1.30  }
    1.31  
    1.32 @@ -621,6 +643,27 @@
    1.33                      SDL_GetCurrentVideoDriver());
    1.34          }
    1.35  
    1.36 +        /* Upload GL settings */
    1.37 +        SDL_GL_SetAttribute(SDL_GL_RED_SIZE, state->gl_red_size);
    1.38 +        SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, state->gl_green_size);
    1.39 +        SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, state->gl_blue_size);
    1.40 +        SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, state->gl_alpha_size);
    1.41 +        SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, state->gl_double_buffer);
    1.42 +        SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, state->gl_buffer_size);
    1.43 +        SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, state->gl_depth_size);
    1.44 +        SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, state->gl_stencil_size);
    1.45 +        SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, state->gl_accum_red_size);
    1.46 +        SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, state->gl_accum_green_size);
    1.47 +        SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, state->gl_accum_blue_size);
    1.48 +        SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, state->gl_accum_alpha_size);
    1.49 +        SDL_GL_SetAttribute(SDL_GL_STEREO, state->gl_stereo);
    1.50 +        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, state->gl_multisamplebuffers);
    1.51 +        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, state->gl_multisamplesamples);
    1.52 +        SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, state->gl_accelerated);
    1.53 +        SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, state->gl_retained_backing);
    1.54 +        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, state->gl_major_version);
    1.55 +        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, state->gl_minor_version);
    1.56 +
    1.57          if (state->verbose & VERBOSE_MODES) {
    1.58              SDL_DisplayMode mode;
    1.59              int bpp;
     2.1 --- a/test/common.h	Mon Oct 19 13:31:58 2009 +0000
     2.2 +++ b/test/common.h	Wed Oct 21 14:51:42 2009 +0000
     2.3 @@ -41,6 +41,27 @@
     2.4      /* Audio info */
     2.5      const char *audiodriver;
     2.6      SDL_AudioSpec audiospec;
     2.7 +
     2.8 +    /* GL settings */
     2.9 +    int gl_red_size;
    2.10 +    int gl_green_size;
    2.11 +    int gl_blue_size;
    2.12 +    int gl_alpha_size;
    2.13 +    int gl_buffer_size;
    2.14 +    int gl_depth_size;
    2.15 +    int gl_stencil_size;
    2.16 +    int gl_double_buffer;
    2.17 +    int gl_accum_red_size;
    2.18 +    int gl_accum_green_size;
    2.19 +    int gl_accum_blue_size;
    2.20 +    int gl_accum_alpha_size;
    2.21 +    int gl_stereo;
    2.22 +    int gl_multisamplebuffers;
    2.23 +    int gl_multisamplesamples;
    2.24 +    int gl_retained_backing;
    2.25 +    int gl_accelerated;
    2.26 +    int gl_major_version;
    2.27 +    int gl_minor_version;
    2.28  } CommonState;
    2.29  
    2.30  extern CommonState *CommonCreateState(char **argv, Uint32 flags);
     3.1 --- a/test/testgl2.c	Mon Oct 19 13:31:58 2009 +0000
     3.2 +++ b/test/testgl2.c	Wed Oct 21 14:51:42 2009 +0000
     3.3 @@ -204,18 +204,19 @@
     3.4  
     3.5      /* Set OpenGL parameters */
     3.6      state->window_flags |= SDL_WINDOW_OPENGL;
     3.7 -    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
     3.8 -    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
     3.9 -    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
    3.10 -    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
    3.11 -    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    3.12 +    state->gl_red_size = 5;
    3.13 +    state->gl_green_size = 5;
    3.14 +    state->gl_blue_size = 5;
    3.15 +    state->gl_depth_size = 16;
    3.16 +    state->gl_doublebuffer = 1;
    3.17      if (fsaa) {
    3.18 -        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
    3.19 -        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa);
    3.20 +        state->gl_multisamplebuffers = 1;
    3.21 +        state->gl_multisamplesamples = fsaa;
    3.22      }
    3.23      if (accel) {
    3.24 -        SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
    3.25 +        state->gl_accelerated=1;
    3.26      }
    3.27 +
    3.28      if (!CommonInit(state)) {
    3.29          quit(2);
    3.30      }
     4.1 --- a/test/testgles.c	Mon Oct 19 13:31:58 2009 +0000
     4.2 +++ b/test/testgles.c	Wed Oct 21 14:51:42 2009 +0000
     4.3 @@ -15,6 +15,7 @@
     4.4  
     4.5  static CommonState *state;
     4.6  static SDL_GLContext *context = NULL;
     4.7 +static int depth = 16;
     4.8  
     4.9  /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
    4.10  static void
    4.11 @@ -118,12 +119,20 @@
    4.12              } else if (SDL_strcasecmp(argv[i], "--accel") == 0) {
    4.13                  ++accel;
    4.14                  consumed = 1;
    4.15 +            } else if (SDL_strcasecmp(argv[i], "--zdepth") == 0) {
    4.16 +                i++;
    4.17 +                if (!argv[i]) {
    4.18 +                    consumed = -1;
    4.19 +                } else {
    4.20 +                    depth = SDL_atoi(argv[i]);
    4.21 +                    consumed = 1;
    4.22 +                }
    4.23              } else {
    4.24                  consumed = -1;
    4.25              }
    4.26          }
    4.27          if (consumed < 0) {
    4.28 -            fprintf(stderr, "Usage: %s %s [--fsaa] [--accel]\n", argv[0],
    4.29 +            fprintf(stderr, "Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
    4.30                      CommonUsage(state));
    4.31              quit(1);
    4.32          }
    4.33 @@ -132,16 +141,16 @@
    4.34  
    4.35      /* Set OpenGL parameters */
    4.36      state->window_flags |= SDL_WINDOW_OPENGL;
    4.37 -    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
    4.38 -    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
    4.39 -    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
    4.40 -    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
    4.41 +    state->gl_red_size = 5;
    4.42 +    state->gl_green_size = 5;
    4.43 +    state->gl_blue_size = 5;
    4.44 +    state->gl_depth_size = depth;
    4.45      if (fsaa) {
    4.46 -        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
    4.47 -        SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa);
    4.48 +        state->gl_multisamplebuffers=1;
    4.49 +        state->gl_multisamplesamples=fsaa;
    4.50      }
    4.51      if (accel) {
    4.52 -        SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
    4.53 +        state->gl_accelerated=1;
    4.54      }
    4.55      if (!CommonInit(state)) {
    4.56          quit(2);
    4.57 @@ -169,7 +178,7 @@
    4.58      }
    4.59  
    4.60      SDL_GetCurrentDisplayMode(&mode);
    4.61 -    printf("Screen BPP: %d\n", SDL_BITSPERPIXEL(mode.format));
    4.62 +    printf("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
    4.63      printf("\n");
    4.64      printf("Vendor     : %s\n", glGetString(GL_VENDOR));
    4.65      printf("Renderer   : %s\n", glGetString(GL_RENDERER));
    4.66 @@ -200,7 +209,7 @@
    4.67      }
    4.68      status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
    4.69      if (!status) {
    4.70 -        printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
    4.71 +        printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
    4.72      } else {
    4.73          fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
    4.74                  SDL_GetError());