test/testgles.c
changeset 3139 7f684f249ec9
parent 3110 e6c21c14ce3a
child 3194 c18c03927a77
     1.1 --- a/test/testgles.c	Fri May 15 15:47:37 2009 +0000
     1.2 +++ b/test/testgles.c	Sat May 23 22:41:08 2009 +0000
     1.3 @@ -14,7 +14,7 @@
     1.4  #include "SDL_opengles.h"
     1.5  
     1.6  static CommonState *state;
     1.7 -static SDL_GLContext *context=NULL;
     1.8 +static SDL_GLContext *context = NULL;
     1.9  
    1.10  /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
    1.11  static void
    1.12 @@ -22,10 +22,8 @@
    1.13  {
    1.14      int i;
    1.15  
    1.16 -    if (context!=NULL)
    1.17 -    {
    1.18 -        for (i=0; i<state->num_windows; i++)
    1.19 -        {
    1.20 +    if (context != NULL) {
    1.21 +        for (i = 0; i < state->num_windows; i++) {
    1.22              if (context[i]) {
    1.23                  SDL_GL_DeleteContext(context[i]);
    1.24              }
    1.25 @@ -149,16 +147,14 @@
    1.26          quit(2);
    1.27      }
    1.28  
    1.29 -    context=SDL_calloc(state->num_windows, sizeof(SDL_GLContext));
    1.30 -    if (context==NULL)
    1.31 -    {
    1.32 -       fprintf(stderr, "Out of memory!\n");
    1.33 -       quit(2);
    1.34 +    context = SDL_calloc(state->num_windows, sizeof(SDL_GLContext));
    1.35 +    if (context == NULL) {
    1.36 +        fprintf(stderr, "Out of memory!\n");
    1.37 +        quit(2);
    1.38      }
    1.39  
    1.40      /* Create OpenGL ES contexts */
    1.41 -    for (i=0; i<state->num_windows; i++)
    1.42 -    {
    1.43 +    for (i = 0; i < state->num_windows; i++) {
    1.44          context[i] = SDL_GL_CreateContext(state->windows[i]);
    1.45          if (!context[i]) {
    1.46              fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
    1.47 @@ -181,59 +177,65 @@
    1.48      printf("Extensions : %s\n", glGetString(GL_EXTENSIONS));
    1.49      printf("\n");
    1.50  
    1.51 -    status=SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
    1.52 +    status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
    1.53      if (!status) {
    1.54          printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
    1.55      } else {
    1.56 -        fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError());
    1.57 +        fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n",
    1.58 +                SDL_GetError());
    1.59      }
    1.60 -    status=SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
    1.61 +    status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
    1.62      if (!status) {
    1.63          printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
    1.64      } else {
    1.65 -        fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError());
    1.66 +        fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
    1.67 +                SDL_GetError());
    1.68      }
    1.69 -    status=SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
    1.70 +    status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
    1.71      if (!status) {
    1.72          printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
    1.73      } else {
    1.74 -        fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError());
    1.75 +        fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
    1.76 +                SDL_GetError());
    1.77      }
    1.78 -    status=SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
    1.79 +    status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
    1.80      if (!status) {
    1.81          printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
    1.82      } else {
    1.83 -        fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
    1.84 +        fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
    1.85 +                SDL_GetError());
    1.86      }
    1.87      if (fsaa) {
    1.88 -        status=SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
    1.89 +        status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
    1.90          if (!status) {
    1.91              printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
    1.92          } else {
    1.93 -            fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", SDL_GetError());
    1.94 +            fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
    1.95 +                    SDL_GetError());
    1.96          }
    1.97 -        status=SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
    1.98 +        status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
    1.99          if (!status) {
   1.100 -            printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value);
   1.101 +            printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
   1.102 +                   value);
   1.103          } else {
   1.104 -            fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", SDL_GetError());
   1.105 +            fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
   1.106 +                    SDL_GetError());
   1.107          }
   1.108      }
   1.109      if (accel) {
   1.110 -        status=SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
   1.111 -        if (!status)
   1.112 -        {
   1.113 +        status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
   1.114 +        if (!status) {
   1.115              printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
   1.116          } else {
   1.117 -            fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", SDL_GetError());
   1.118 +            fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
   1.119 +                    SDL_GetError());
   1.120          }
   1.121      }
   1.122  
   1.123      /* Set rendering settings for each context */
   1.124      for (i = 0; i < state->num_windows; ++i) {
   1.125 -        status=SDL_GL_MakeCurrent(state->windows[i], context[i]);
   1.126 -        if (status)
   1.127 -        {
   1.128 +        status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
   1.129 +        if (status) {
   1.130              printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
   1.131  
   1.132              /* Continue for next window */
   1.133 @@ -262,13 +264,12 @@
   1.134          }
   1.135          for (i = 0; i < state->num_windows; ++i) {
   1.136              int w, h;
   1.137 -            status=SDL_GL_MakeCurrent(state->windows[i], context[i]);
   1.138 -            if (status)
   1.139 -            {
   1.140 -               printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
   1.141 +            status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
   1.142 +            if (status) {
   1.143 +                printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
   1.144  
   1.145 -               /* Continue for next window */
   1.146 -               continue;
   1.147 +                /* Continue for next window */
   1.148 +                continue;
   1.149              }
   1.150              SDL_GetWindowSize(state->windows[i], &w, &h);
   1.151              glViewport(0, 0, w, h);