Implemented multi-window OpenGL program with test framework.
authorSam Lantinga <slouken@libsdl.org>
Wed, 19 Jul 2006 04:24:41 +0000
changeset 1915a228436a2404
parent 1914 051df511279c
child 1916 c773b0c0ac89
Implemented multi-window OpenGL program with test framework.
src/events/SDL_windowevents.c
test/Makefile.in
test/testgl2.c
test/testsprite2.c
     1.1 --- a/src/events/SDL_windowevents.c	Tue Jul 18 07:49:51 2006 +0000
     1.2 +++ b/src/events/SDL_windowevents.c	Wed Jul 19 04:24:41 2006 +0000
     1.3 @@ -60,6 +60,8 @@
     1.4          if (data1 == window->x && data2 == window->y) {
     1.5              return 0;
     1.6          }
     1.7 +        window->x = data1;
     1.8 +        window->y = data2;
     1.9          break;
    1.10      case SDL_WINDOWEVENT_RESIZED:
    1.11          if (window->flags & SDL_WINDOW_FULLSCREEN) {
    1.12 @@ -68,6 +70,8 @@
    1.13          if (data1 == window->w && data2 == window->h) {
    1.14              return 0;
    1.15          }
    1.16 +        window->w = data1;
    1.17 +        window->h = data2;
    1.18          break;
    1.19      case SDL_WINDOWEVENT_MINIMIZED:
    1.20          if (window->flags & SDL_WINDOW_MINIMIZED) {
     2.1 --- a/test/Makefile.in	Tue Jul 18 07:49:51 2006 +0000
     2.2 +++ b/test/Makefile.in	Wed Jul 19 04:24:41 2006 +0000
     2.3 @@ -53,8 +53,8 @@
     2.4  testgl$(EXE): $(srcdir)/testgl.c
     2.5  	$(CC) -o $@ $? $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
     2.6  
     2.7 -testgl2$(EXE): $(srcdir)/testgl2.c
     2.8 -	$(CC) -o $@ $? $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
     2.9 +testgl2$(EXE): $(srcdir)/testgl2.c $(srcdir)/common.c
    2.10 +	$(CC) -o $@ $(srcdir)/testgl2.c $(srcdir)/common.c $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
    2.11  
    2.12  testhread$(EXE): $(srcdir)/testhread.c
    2.13  	$(CC) -o $@ $? $(CFLAGS) $(LIBS)
     3.1 --- a/test/testgl2.c	Tue Jul 18 07:49:51 2006 +0000
     3.2 +++ b/test/testgl2.c	Wed Jul 19 04:24:41 2006 +0000
     3.3 @@ -3,7 +3,7 @@
     3.4  #include <string.h>
     3.5  #include <math.h>
     3.6  
     3.7 -#include "SDL.h"
     3.8 +#include "common.h"
     3.9  
    3.10  #ifdef __MACOS__
    3.11  #define HAVE_OPENGL
    3.12 @@ -16,438 +16,195 @@
    3.13  /* Undefine this if you want a flat cube instead of a rainbow cube */
    3.14  #define SHADED_CUBE
    3.15  
    3.16 -/* Define this to be the name of the logo image to use with -logo */
    3.17 -#define LOGO_FILE	"icon.bmp"
    3.18 +static CommonState *state;
    3.19 +static SDL_GLContext context;
    3.20  
    3.21 -static SDL_Surface *global_image = NULL;
    3.22 -static GLuint global_texture = 0;
    3.23 -static GLuint cursor_texture = 0;
    3.24 -
    3.25 -/**********************************************************************/
    3.26 -
    3.27 -void
    3.28 -HotKey_ToggleFullScreen(void)
    3.29 +/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
    3.30 +static void
    3.31 +quit(int rc)
    3.32  {
    3.33 -    SDL_Surface *screen;
    3.34 -
    3.35 -    screen = SDL_GetVideoSurface();
    3.36 -    if (SDL_WM_ToggleFullScreen(screen)) {
    3.37 -        printf("Toggled fullscreen mode - now %s\n",
    3.38 -               (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed");
    3.39 -    } else {
    3.40 -        printf("Unable to toggle fullscreen mode\n");
    3.41 +    if (context) {
    3.42 +        SDL_GL_MakeCurrent(0, NULL);
    3.43 +        SDL_GL_DeleteContext(context);
    3.44      }
    3.45 +    CommonQuit(state);
    3.46 +    exit(rc);
    3.47  }
    3.48  
    3.49 -void
    3.50 -HotKey_ToggleGrab(void)
    3.51 +static void
    3.52 +Render()
    3.53  {
    3.54 -    SDL_GrabMode mode;
    3.55 +    static float color[8][3] = {
    3.56 +        {1.0, 1.0, 0.0},
    3.57 +        {1.0, 0.0, 0.0},
    3.58 +        {0.0, 0.0, 0.0},
    3.59 +        {0.0, 1.0, 0.0},
    3.60 +        {0.0, 1.0, 1.0},
    3.61 +        {1.0, 1.0, 1.0},
    3.62 +        {1.0, 0.0, 1.0},
    3.63 +        {0.0, 0.0, 1.0}
    3.64 +    };
    3.65 +    static float cube[8][3] = {
    3.66 +        {0.5, 0.5, -0.5},
    3.67 +        {0.5, -0.5, -0.5},
    3.68 +        {-0.5, -0.5, -0.5},
    3.69 +        {-0.5, 0.5, -0.5},
    3.70 +        {-0.5, 0.5, 0.5},
    3.71 +        {0.5, 0.5, 0.5},
    3.72 +        {0.5, -0.5, 0.5},
    3.73 +        {-0.5, -0.5, 0.5}
    3.74 +    };
    3.75  
    3.76 -    printf("Ctrl-G: toggling input grab!\n");
    3.77 -    mode = SDL_WM_GrabInput(SDL_GRAB_QUERY);
    3.78 -    if (mode == SDL_GRAB_ON) {
    3.79 -        printf("Grab was on\n");
    3.80 -    } else {
    3.81 -        printf("Grab was off\n");
    3.82 -    }
    3.83 -    mode = SDL_WM_GrabInput(!mode);
    3.84 -    if (mode == SDL_GRAB_ON) {
    3.85 -        printf("Grab is now on\n");
    3.86 -    } else {
    3.87 -        printf("Grab is now off\n");
    3.88 -    }
    3.89 -}
    3.90 +    /* Do our drawing, too. */
    3.91 +    glClearColor(0.0, 0.0, 0.0, 1.0);
    3.92 +    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    3.93  
    3.94 -void
    3.95 -HotKey_Iconify(void)
    3.96 -{
    3.97 -    printf("Ctrl-Z: iconifying window!\n");
    3.98 -    SDL_WM_IconifyWindow();
    3.99 +    glBegin(GL_QUADS);
   3.100 +
   3.101 +#ifdef SHADED_CUBE
   3.102 +    glColor3fv(color[0]);
   3.103 +    glVertex3fv(cube[0]);
   3.104 +    glColor3fv(color[1]);
   3.105 +    glVertex3fv(cube[1]);
   3.106 +    glColor3fv(color[2]);
   3.107 +    glVertex3fv(cube[2]);
   3.108 +    glColor3fv(color[3]);
   3.109 +    glVertex3fv(cube[3]);
   3.110 +
   3.111 +    glColor3fv(color[3]);
   3.112 +    glVertex3fv(cube[3]);
   3.113 +    glColor3fv(color[4]);
   3.114 +    glVertex3fv(cube[4]);
   3.115 +    glColor3fv(color[7]);
   3.116 +    glVertex3fv(cube[7]);
   3.117 +    glColor3fv(color[2]);
   3.118 +    glVertex3fv(cube[2]);
   3.119 +
   3.120 +    glColor3fv(color[0]);
   3.121 +    glVertex3fv(cube[0]);
   3.122 +    glColor3fv(color[5]);
   3.123 +    glVertex3fv(cube[5]);
   3.124 +    glColor3fv(color[6]);
   3.125 +    glVertex3fv(cube[6]);
   3.126 +    glColor3fv(color[1]);
   3.127 +    glVertex3fv(cube[1]);
   3.128 +
   3.129 +    glColor3fv(color[5]);
   3.130 +    glVertex3fv(cube[5]);
   3.131 +    glColor3fv(color[4]);
   3.132 +    glVertex3fv(cube[4]);
   3.133 +    glColor3fv(color[7]);
   3.134 +    glVertex3fv(cube[7]);
   3.135 +    glColor3fv(color[6]);
   3.136 +    glVertex3fv(cube[6]);
   3.137 +
   3.138 +    glColor3fv(color[5]);
   3.139 +    glVertex3fv(cube[5]);
   3.140 +    glColor3fv(color[0]);
   3.141 +    glVertex3fv(cube[0]);
   3.142 +    glColor3fv(color[3]);
   3.143 +    glVertex3fv(cube[3]);
   3.144 +    glColor3fv(color[4]);
   3.145 +    glVertex3fv(cube[4]);
   3.146 +
   3.147 +    glColor3fv(color[6]);
   3.148 +    glVertex3fv(cube[6]);
   3.149 +    glColor3fv(color[1]);
   3.150 +    glVertex3fv(cube[1]);
   3.151 +    glColor3fv(color[2]);
   3.152 +    glVertex3fv(cube[2]);
   3.153 +    glColor3fv(color[7]);
   3.154 +    glVertex3fv(cube[7]);
   3.155 +#else /* flat cube */
   3.156 +    glColor3f(1.0, 0.0, 0.0);
   3.157 +    glVertex3fv(cube[0]);
   3.158 +    glVertex3fv(cube[1]);
   3.159 +    glVertex3fv(cube[2]);
   3.160 +    glVertex3fv(cube[3]);
   3.161 +
   3.162 +    glColor3f(0.0, 1.0, 0.0);
   3.163 +    glVertex3fv(cube[3]);
   3.164 +    glVertex3fv(cube[4]);
   3.165 +    glVertex3fv(cube[7]);
   3.166 +    glVertex3fv(cube[2]);
   3.167 +
   3.168 +    glColor3f(0.0, 0.0, 1.0);
   3.169 +    glVertex3fv(cube[0]);
   3.170 +    glVertex3fv(cube[5]);
   3.171 +    glVertex3fv(cube[6]);
   3.172 +    glVertex3fv(cube[1]);
   3.173 +
   3.174 +    glColor3f(0.0, 1.0, 1.0);
   3.175 +    glVertex3fv(cube[5]);
   3.176 +    glVertex3fv(cube[4]);
   3.177 +    glVertex3fv(cube[7]);
   3.178 +    glVertex3fv(cube[6]);
   3.179 +
   3.180 +    glColor3f(1.0, 1.0, 0.0);
   3.181 +    glVertex3fv(cube[5]);
   3.182 +    glVertex3fv(cube[0]);
   3.183 +    glVertex3fv(cube[3]);
   3.184 +    glVertex3fv(cube[4]);
   3.185 +
   3.186 +    glColor3f(1.0, 0.0, 1.0);
   3.187 +    glVertex3fv(cube[6]);
   3.188 +    glVertex3fv(cube[1]);
   3.189 +    glVertex3fv(cube[2]);
   3.190 +    glVertex3fv(cube[7]);
   3.191 +#endif /* SHADED_CUBE */
   3.192 +
   3.193 +    glEnd();
   3.194 +
   3.195 +    glMatrixMode(GL_MODELVIEW);
   3.196 +    glRotatef(5.0, 1.0, 1.0, 1.0);
   3.197  }
   3.198  
   3.199  int
   3.200 -HandleEvent(SDL_Event * event)
   3.201 +main(int argc, char *argv[])
   3.202  {
   3.203 -    int done;
   3.204 +    int fsaa, accel;
   3.205 +    int value;
   3.206 +    int i, done;
   3.207 +    SDL_Event event;
   3.208 +    Uint32 then, now, frames;
   3.209  
   3.210 -    done = 0;
   3.211 -    switch (event->type) {
   3.212 -    case SDL_ACTIVEEVENT:
   3.213 -        /* See what happened */
   3.214 -        printf("app %s ", event->active.gain ? "gained" : "lost");
   3.215 -        if (event->active.state & SDL_APPACTIVE) {
   3.216 -            printf("active ");
   3.217 -        } else if (event->active.state & SDL_APPMOUSEFOCUS) {
   3.218 -            printf("mouse ");
   3.219 -        } else if (event->active.state & SDL_APPINPUTFOCUS) {
   3.220 -            printf("input ");
   3.221 +    /* Initialize parameters */
   3.222 +    fsaa = 0;
   3.223 +    accel = 0;
   3.224 +
   3.225 +    /* Initialize test framework */
   3.226 +    state = CommonCreateState(argv, SDL_INIT_VIDEO);
   3.227 +    if (!state) {
   3.228 +        return 1;
   3.229 +    }
   3.230 +    for (i = 1; i < argc;) {
   3.231 +        int consumed;
   3.232 +
   3.233 +        consumed = CommonArg(state, i);
   3.234 +        if (consumed == 0) {
   3.235 +            if (SDL_strcasecmp(argv[i], "--fsaa") == 0) {
   3.236 +                ++fsaa;
   3.237 +                consumed = 1;
   3.238 +            } else if (SDL_strcasecmp(argv[i], "--accel") == 0) {
   3.239 +                ++accel;
   3.240 +                consumed = 1;
   3.241 +            } else {
   3.242 +                consumed = -1;
   3.243 +            }
   3.244          }
   3.245 -        printf("focus\n");
   3.246 -        break;
   3.247 -
   3.248 -
   3.249 -    case SDL_KEYDOWN:
   3.250 -        if (event->key.keysym.sym == SDLK_ESCAPE) {
   3.251 -            done = 1;
   3.252 +        if (consumed < 0) {
   3.253 +            fprintf(stderr, "Usage: %s [--fsaa] [--accel] %s", argv[0],
   3.254 +                    CommonUsage(state));
   3.255 +            quit(1);
   3.256          }
   3.257 -        if ((event->key.keysym.sym == SDLK_g) &&
   3.258 -            (event->key.keysym.mod & KMOD_CTRL)) {
   3.259 -            HotKey_ToggleGrab();
   3.260 -        }
   3.261 -        if ((event->key.keysym.sym == SDLK_z) &&
   3.262 -            (event->key.keysym.mod & KMOD_CTRL)) {
   3.263 -            HotKey_Iconify();
   3.264 -        }
   3.265 -        if ((event->key.keysym.sym == SDLK_RETURN) &&
   3.266 -            (event->key.keysym.mod & KMOD_ALT)) {
   3.267 -            HotKey_ToggleFullScreen();
   3.268 -        }
   3.269 -        printf("key '%s' pressed\n", SDL_GetKeyName(event->key.keysym.sym));
   3.270 -        break;
   3.271 -    case SDL_QUIT:
   3.272 -        done = 1;
   3.273 -        break;
   3.274 -    }
   3.275 -    return (done);
   3.276 -}
   3.277 -
   3.278 -void
   3.279 -SDL_GL_Enter2DMode()
   3.280 -{
   3.281 -    SDL_Surface *screen = SDL_GetVideoSurface();
   3.282 -
   3.283 -    /* Note, there may be other things you need to change,
   3.284 -       depending on how you have your OpenGL state set up.
   3.285 -     */
   3.286 -    glPushAttrib(GL_ENABLE_BIT);
   3.287 -    glDisable(GL_DEPTH_TEST);
   3.288 -    glDisable(GL_CULL_FACE);
   3.289 -    glEnable(GL_TEXTURE_2D);
   3.290 -
   3.291 -    /* This allows alpha blending of 2D textures with the scene */
   3.292 -    glEnable(GL_BLEND);
   3.293 -    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   3.294 -
   3.295 -    glViewport(0, 0, screen->w, screen->h);
   3.296 -
   3.297 -    glMatrixMode(GL_PROJECTION);
   3.298 -    glPushMatrix();
   3.299 -    glLoadIdentity();
   3.300 -
   3.301 -    glOrtho(0.0, (GLdouble) screen->w, (GLdouble) screen->h, 0.0, 0.0, 1.0);
   3.302 -
   3.303 -    glMatrixMode(GL_MODELVIEW);
   3.304 -    glPushMatrix();
   3.305 -    glLoadIdentity();
   3.306 -
   3.307 -    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
   3.308 -}
   3.309 -
   3.310 -void
   3.311 -SDL_GL_Leave2DMode()
   3.312 -{
   3.313 -    glMatrixMode(GL_MODELVIEW);
   3.314 -    glPopMatrix();
   3.315 -
   3.316 -    glMatrixMode(GL_PROJECTION);
   3.317 -    glPopMatrix();
   3.318 -
   3.319 -    glPopAttrib();
   3.320 -}
   3.321 -
   3.322 -/* Quick utility function for texture creation */
   3.323 -static int
   3.324 -power_of_two(int input)
   3.325 -{
   3.326 -    int value = 1;
   3.327 -
   3.328 -    while (value < input) {
   3.329 -        value <<= 1;
   3.330 -    }
   3.331 -    return value;
   3.332 -}
   3.333 -
   3.334 -GLuint
   3.335 -SDL_GL_LoadTexture(SDL_Surface * surface, GLfloat * texcoord)
   3.336 -{
   3.337 -    GLuint texture;
   3.338 -    int w, h;
   3.339 -    SDL_Surface *image;
   3.340 -    SDL_Rect area;
   3.341 -    Uint32 saved_flags;
   3.342 -    Uint8 saved_alpha;
   3.343 -
   3.344 -    /* Use the surface width and height expanded to powers of 2 */
   3.345 -    w = power_of_two(surface->w);
   3.346 -    h = power_of_two(surface->h);
   3.347 -    texcoord[0] = 0.0f;         /* Min X */
   3.348 -    texcoord[1] = 0.0f;         /* Min Y */
   3.349 -    texcoord[2] = (GLfloat) surface->w / w;     /* Max X */
   3.350 -    texcoord[3] = (GLfloat) surface->h / h;     /* Max Y */
   3.351 -
   3.352 -    image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32,
   3.353 -#if SDL_BYTEORDER == SDL_LIL_ENDIAN     /* OpenGL RGBA masks */
   3.354 -                                 0x000000FF,
   3.355 -                                 0x0000FF00, 0x00FF0000, 0xFF000000
   3.356 -#else
   3.357 -                                 0xFF000000,
   3.358 -                                 0x00FF0000, 0x0000FF00, 0x000000FF
   3.359 -#endif
   3.360 -        );
   3.361 -    if (image == NULL) {
   3.362 -        return 0;
   3.363 +        i += consumed;
   3.364      }
   3.365  
   3.366 -    /* Save the alpha blending attributes */
   3.367 -    saved_flags = surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK);
   3.368 -    saved_alpha = surface->format->alpha;
   3.369 -    if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
   3.370 -        SDL_SetAlpha(surface, 0, 0);
   3.371 -    }
   3.372 -
   3.373 -    /* Copy the surface into the GL texture image */
   3.374 -    area.x = 0;
   3.375 -    area.y = 0;
   3.376 -    area.w = surface->w;
   3.377 -    area.h = surface->h;
   3.378 -    SDL_BlitSurface(surface, &area, image, &area);
   3.379 -
   3.380 -    /* Restore the alpha blending attributes */
   3.381 -    if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
   3.382 -        SDL_SetAlpha(surface, saved_flags, saved_alpha);
   3.383 -    }
   3.384 -
   3.385 -    /* Create an OpenGL texture for the image */
   3.386 -    glGenTextures(1, &texture);
   3.387 -    glBindTexture(GL_TEXTURE_2D, texture);
   3.388 -    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
   3.389 -    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
   3.390 -    glTexImage2D(GL_TEXTURE_2D,
   3.391 -                 0,
   3.392 -                 GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels);
   3.393 -    SDL_FreeSurface(image);     /* No longer needed */
   3.394 -
   3.395 -    return texture;
   3.396 -}
   3.397 -
   3.398 -void
   3.399 -DrawLogoCursor(void)
   3.400 -{
   3.401 -    static GLfloat texMinX, texMinY;
   3.402 -    static GLfloat texMaxX, texMaxY;
   3.403 -    static int w, h;
   3.404 -    int x, y;
   3.405 -
   3.406 -    if (!cursor_texture) {
   3.407 -        SDL_Surface *image;
   3.408 -        GLfloat texcoord[4];
   3.409 -
   3.410 -        /* Load the image (could use SDL_image library here) */
   3.411 -        image = SDL_LoadBMP(LOGO_FILE);
   3.412 -        if (image == NULL) {
   3.413 -            return;
   3.414 -        }
   3.415 -        w = image->w;
   3.416 -        h = image->h;
   3.417 -
   3.418 -        /* Convert the image into an OpenGL texture */
   3.419 -        cursor_texture = SDL_GL_LoadTexture(image, texcoord);
   3.420 -
   3.421 -        /* Make texture coordinates easy to understand */
   3.422 -        texMinX = texcoord[0];
   3.423 -        texMinY = texcoord[1];
   3.424 -        texMaxX = texcoord[2];
   3.425 -        texMaxY = texcoord[3];
   3.426 -
   3.427 -        /* We don't need the original image anymore */
   3.428 -        SDL_FreeSurface(image);
   3.429 -
   3.430 -        /* Make sure that the texture conversion is okay */
   3.431 -        if (!cursor_texture) {
   3.432 -            return;
   3.433 -        }
   3.434 -    }
   3.435 -
   3.436 -    /* Move the image around */
   3.437 -    SDL_GetMouseState(&x, &y);
   3.438 -    x -= w / 2;
   3.439 -    y -= h / 2;
   3.440 -
   3.441 -    /* Show the image on the screen */
   3.442 -    SDL_GL_Enter2DMode();
   3.443 -    glBindTexture(GL_TEXTURE_2D, cursor_texture);
   3.444 -    glBegin(GL_TRIANGLE_STRIP);
   3.445 -    glTexCoord2f(texMinX, texMinY);
   3.446 -    glVertex2i(x, y);
   3.447 -    glTexCoord2f(texMaxX, texMinY);
   3.448 -    glVertex2i(x + w, y);
   3.449 -    glTexCoord2f(texMinX, texMaxY);
   3.450 -    glVertex2i(x, y + h);
   3.451 -    glTexCoord2f(texMaxX, texMaxY);
   3.452 -    glVertex2i(x + w, y + h);
   3.453 -    glEnd();
   3.454 -    SDL_GL_Leave2DMode();
   3.455 -}
   3.456 -
   3.457 -void
   3.458 -DrawLogoTexture(void)
   3.459 -{
   3.460 -    static GLfloat texMinX, texMinY;
   3.461 -    static GLfloat texMaxX, texMaxY;
   3.462 -    static int x = 0;
   3.463 -    static int y = 0;
   3.464 -    static int w, h;
   3.465 -    static int delta_x = 1;
   3.466 -    static int delta_y = 1;
   3.467 -
   3.468 -    SDL_Surface *screen = SDL_GetVideoSurface();
   3.469 -
   3.470 -    if (!global_texture) {
   3.471 -        SDL_Surface *image;
   3.472 -        GLfloat texcoord[4];
   3.473 -
   3.474 -        /* Load the image (could use SDL_image library here) */
   3.475 -        image = SDL_LoadBMP(LOGO_FILE);
   3.476 -        if (image == NULL) {
   3.477 -            return;
   3.478 -        }
   3.479 -        w = image->w;
   3.480 -        h = image->h;
   3.481 -
   3.482 -        /* Convert the image into an OpenGL texture */
   3.483 -        global_texture = SDL_GL_LoadTexture(image, texcoord);
   3.484 -
   3.485 -        /* Make texture coordinates easy to understand */
   3.486 -        texMinX = texcoord[0];
   3.487 -        texMinY = texcoord[1];
   3.488 -        texMaxX = texcoord[2];
   3.489 -        texMaxY = texcoord[3];
   3.490 -
   3.491 -        /* We don't need the original image anymore */
   3.492 -        SDL_FreeSurface(image);
   3.493 -
   3.494 -        /* Make sure that the texture conversion is okay */
   3.495 -        if (!global_texture) {
   3.496 -            return;
   3.497 -        }
   3.498 -    }
   3.499 -
   3.500 -    /* Move the image around */
   3.501 -    x += delta_x;
   3.502 -    if (x < 0) {
   3.503 -        x = 0;
   3.504 -        delta_x = -delta_x;
   3.505 -    } else if ((x + w) > screen->w) {
   3.506 -        x = screen->w - w;
   3.507 -        delta_x = -delta_x;
   3.508 -    }
   3.509 -    y += delta_y;
   3.510 -    if (y < 0) {
   3.511 -        y = 0;
   3.512 -        delta_y = -delta_y;
   3.513 -    } else if ((y + h) > screen->h) {
   3.514 -        y = screen->h - h;
   3.515 -        delta_y = -delta_y;
   3.516 -    }
   3.517 -
   3.518 -    /* Show the image on the screen */
   3.519 -    SDL_GL_Enter2DMode();
   3.520 -    glBindTexture(GL_TEXTURE_2D, global_texture);
   3.521 -    glBegin(GL_TRIANGLE_STRIP);
   3.522 -    glTexCoord2f(texMinX, texMinY);
   3.523 -    glVertex2i(x, y);
   3.524 -    glTexCoord2f(texMaxX, texMinY);
   3.525 -    glVertex2i(x + w, y);
   3.526 -    glTexCoord2f(texMinX, texMaxY);
   3.527 -    glVertex2i(x, y + h);
   3.528 -    glTexCoord2f(texMaxX, texMaxY);
   3.529 -    glVertex2i(x + w, y + h);
   3.530 -    glEnd();
   3.531 -    SDL_GL_Leave2DMode();
   3.532 -}
   3.533 -
   3.534 -int
   3.535 -RunGLTest(int argc, char *argv[],
   3.536 -          int logo, int logocursor, int slowly, int bpp, float gamma,
   3.537 -          int noframe, int fsaa, int sync, int accel)
   3.538 -{
   3.539 -    int i;
   3.540 -    int rgb_size[3];
   3.541 -    int w = 640;
   3.542 -    int h = 480;
   3.543 -    int done = 0;
   3.544 -    int frames;
   3.545 -    Uint32 start_time, this_time;
   3.546 -    float color[8][3] = { {1.0, 1.0, 0.0},
   3.547 -    {1.0, 0.0, 0.0},
   3.548 -    {0.0, 0.0, 0.0},
   3.549 -    {0.0, 1.0, 0.0},
   3.550 -    {0.0, 1.0, 1.0},
   3.551 -    {1.0, 1.0, 1.0},
   3.552 -    {1.0, 0.0, 1.0},
   3.553 -    {0.0, 0.0, 1.0}
   3.554 -    };
   3.555 -    float cube[8][3] = { {0.5, 0.5, -0.5},
   3.556 -    {0.5, -0.5, -0.5},
   3.557 -    {-0.5, -0.5, -0.5},
   3.558 -    {-0.5, 0.5, -0.5},
   3.559 -    {-0.5, 0.5, 0.5},
   3.560 -    {0.5, 0.5, 0.5},
   3.561 -    {0.5, -0.5, 0.5},
   3.562 -    {-0.5, -0.5, 0.5}
   3.563 -    };
   3.564 -    Uint32 video_flags;
   3.565 -    int value;
   3.566 -
   3.567 -    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
   3.568 -        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   3.569 -        exit(1);
   3.570 -    }
   3.571 -
   3.572 -    /* See if we should detect the display depth */
   3.573 -    if (bpp == 0) {
   3.574 -        if (SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8) {
   3.575 -            bpp = 8;
   3.576 -        } else {
   3.577 -            bpp = 16;           /* More doesn't seem to work */
   3.578 -        }
   3.579 -    }
   3.580 -
   3.581 -    /* Set the flags we want to use for setting the video mode */
   3.582 -    video_flags = SDL_OPENGL;
   3.583 -    for (i = 1; argv[i]; ++i) {
   3.584 -        if (strcmp(argv[i], "-fullscreen") == 0) {
   3.585 -            video_flags |= SDL_FULLSCREEN;
   3.586 -        }
   3.587 -    }
   3.588 -
   3.589 -    if (noframe) {
   3.590 -        video_flags |= SDL_NOFRAME;
   3.591 -    }
   3.592 -
   3.593 -    /* Initialize the display */
   3.594 -    switch (bpp) {
   3.595 -    case 8:
   3.596 -        rgb_size[0] = 3;
   3.597 -        rgb_size[1] = 3;
   3.598 -        rgb_size[2] = 2;
   3.599 -        break;
   3.600 -    case 15:
   3.601 -    case 16:
   3.602 -        rgb_size[0] = 5;
   3.603 -        rgb_size[1] = 5;
   3.604 -        rgb_size[2] = 5;
   3.605 -        break;
   3.606 -    default:
   3.607 -        rgb_size[0] = 8;
   3.608 -        rgb_size[1] = 8;
   3.609 -        rgb_size[2] = 8;
   3.610 -        break;
   3.611 -    }
   3.612 -    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, rgb_size[0]);
   3.613 -    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, rgb_size[1]);
   3.614 -    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, rgb_size[2]);
   3.615 +    /* Set OpenGL parameters */
   3.616 +    state->window_flags |= SDL_WINDOW_OPENGL;
   3.617 +    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
   3.618 +    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
   3.619 +    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
   3.620      SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
   3.621      SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
   3.622      if (fsaa) {
   3.623 @@ -457,18 +214,29 @@
   3.624      if (accel) {
   3.625          SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
   3.626      }
   3.627 -    if (SDL_SetVideoMode(w, h, bpp, video_flags) == NULL) {
   3.628 -        fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
   3.629 -        SDL_Quit();
   3.630 -        exit(1);
   3.631 +    if (!CommonInit(state)) {
   3.632 +        quit(2);
   3.633      }
   3.634 -    if (sync) {
   3.635 +
   3.636 +    /* Create OpenGL context */
   3.637 +    context = SDL_GL_CreateContext(state->windows[0]);
   3.638 +    if (!context) {
   3.639 +        fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
   3.640 +        quit(2);
   3.641 +    }
   3.642 +    if (SDL_GL_MakeCurrent(state->windows[0], context) < 0) {
   3.643 +        fprintf(stderr, "SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
   3.644 +        quit(2);
   3.645 +    }
   3.646 +
   3.647 +    if (state->render_flags & SDL_Renderer_PresentVSync) {
   3.648          SDL_GL_SetSwapInterval(1);
   3.649      } else {
   3.650          SDL_GL_SetSwapInterval(0);
   3.651      }
   3.652  
   3.653 -    printf("Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel);
   3.654 +    printf("Screen BPP: %d\n",
   3.655 +           SDL_BITSPERPIXEL(SDL_GetCurrentDisplayMode()->format));
   3.656      printf("\n");
   3.657      printf("Vendor     : %s\n", glGetString(GL_VENDOR));
   3.658      printf("Renderer   : %s\n", glGetString(GL_RENDERER));
   3.659 @@ -476,286 +244,68 @@
   3.660      printf("Extensions : %s\n", glGetString(GL_EXTENSIONS));
   3.661      printf("\n");
   3.662  
   3.663 -    SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
   3.664 -    printf("SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0], value);
   3.665 -    SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
   3.666 -    printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1], value);
   3.667 -    SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
   3.668 -    printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2], value);
   3.669 -    SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
   3.670 -    printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value);
   3.671 -    SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &value);
   3.672 +    SDL_GL_GetWindowAttribute(state->windows[0], SDL_GL_RED_SIZE, &value);
   3.673 +    printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
   3.674 +    SDL_GL_GetWindowAttribute(state->windows[0], SDL_GL_GREEN_SIZE, &value);
   3.675 +    printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
   3.676 +    SDL_GL_GetWindowAttribute(state->windows[0], SDL_GL_BLUE_SIZE, &value);
   3.677 +    printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
   3.678 +    SDL_GL_GetWindowAttribute(state->windows[0], SDL_GL_DEPTH_SIZE, &value);
   3.679 +    printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value);
   3.680 +    SDL_GL_GetWindowAttribute(state->windows[0], SDL_GL_DOUBLEBUFFER, &value);
   3.681      printf("SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value);
   3.682      if (fsaa) {
   3.683 -        SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
   3.684 +        SDL_GL_GetWindowAttribute(state->windows[0],
   3.685 +                                  SDL_GL_MULTISAMPLEBUFFERS, &value);
   3.686          printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
   3.687 -        SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
   3.688 +        SDL_GL_GetWindowAttribute(state->windows[0],
   3.689 +                                  SDL_GL_MULTISAMPLESAMPLES, &value);
   3.690          printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
   3.691                 value);
   3.692      }
   3.693      if (accel) {
   3.694 -        SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
   3.695 +        SDL_GL_GetWindowAttribute(state->windows[0],
   3.696 +                                  SDL_GL_ACCELERATED_VISUAL, &value);
   3.697          printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
   3.698      }
   3.699 -    if (sync) {
   3.700 -        printf("Buffer swap interval: requested 1, got %d\n",
   3.701 -               SDL_GL_GetSwapInterval());
   3.702 +
   3.703 +    /* Set rendering settings */
   3.704 +    glMatrixMode(GL_PROJECTION);
   3.705 +    glLoadIdentity();
   3.706 +    glOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0);
   3.707 +    glMatrixMode(GL_MODELVIEW);
   3.708 +    glLoadIdentity();
   3.709 +    glEnable(GL_DEPTH_TEST);
   3.710 +    glDepthFunc(GL_LESS);
   3.711 +    glShadeModel(GL_SMOOTH);
   3.712 +
   3.713 +    /* Main render loop */
   3.714 +    frames = 0;
   3.715 +    then = SDL_GetTicks();
   3.716 +    done = 0;
   3.717 +    while (!done) {
   3.718 +        /* Check for events */
   3.719 +        ++frames;
   3.720 +        while (SDL_PollEvent(&event)) {
   3.721 +            CommonEvent(state, &event, &done);
   3.722 +        }
   3.723 +        for (i = 0; i < state->num_windows; ++i) {
   3.724 +            int w, h;
   3.725 +            SDL_GL_MakeCurrent(state->windows[i], context);
   3.726 +            SDL_GetWindowSize(state->windows[i], &w, &h);
   3.727 +            glViewport(0, 0, w, h);
   3.728 +            Render();
   3.729 +            SDL_GL_SwapWindow(state->windows[i]);
   3.730 +        }
   3.731      }
   3.732  
   3.733 -    /* Set the window manager title bar */
   3.734 -    SDL_WM_SetCaption("SDL GL test", "testgl");
   3.735 -
   3.736 -    /* Set the gamma for the window */
   3.737 -    if (gamma != 0.0) {
   3.738 -        SDL_SetGamma(gamma, gamma, gamma);
   3.739 +    /* Print out some timing information */
   3.740 +    now = SDL_GetTicks();
   3.741 +    if (now > then) {
   3.742 +        printf("%2.2f frames per second\n",
   3.743 +               ((double) frames * 1000) / (now - then));
   3.744      }
   3.745 -
   3.746 -    glViewport(0, 0, w, h);
   3.747 -    glMatrixMode(GL_PROJECTION);
   3.748 -    glLoadIdentity();
   3.749 -
   3.750 -    glOrtho(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0);
   3.751 -
   3.752 -    glMatrixMode(GL_MODELVIEW);
   3.753 -    glLoadIdentity();
   3.754 -
   3.755 -    glEnable(GL_DEPTH_TEST);
   3.756 -
   3.757 -    glDepthFunc(GL_LESS);
   3.758 -
   3.759 -    glShadeModel(GL_SMOOTH);
   3.760 -
   3.761 -    /* Loop until done. */
   3.762 -    start_time = SDL_GetTicks();
   3.763 -    frames = 0;
   3.764 -    while (!done) {
   3.765 -        GLenum gl_error;
   3.766 -        char *sdl_error;
   3.767 -        SDL_Event event;
   3.768 -
   3.769 -        /* Do our drawing, too. */
   3.770 -        glClearColor(0.0, 0.0, 0.0, 1.0);
   3.771 -        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   3.772 -
   3.773 -        glBegin(GL_QUADS);
   3.774 -
   3.775 -#ifdef SHADED_CUBE
   3.776 -        glColor3fv(color[0]);
   3.777 -        glVertex3fv(cube[0]);
   3.778 -        glColor3fv(color[1]);
   3.779 -        glVertex3fv(cube[1]);
   3.780 -        glColor3fv(color[2]);
   3.781 -        glVertex3fv(cube[2]);
   3.782 -        glColor3fv(color[3]);
   3.783 -        glVertex3fv(cube[3]);
   3.784 -
   3.785 -        glColor3fv(color[3]);
   3.786 -        glVertex3fv(cube[3]);
   3.787 -        glColor3fv(color[4]);
   3.788 -        glVertex3fv(cube[4]);
   3.789 -        glColor3fv(color[7]);
   3.790 -        glVertex3fv(cube[7]);
   3.791 -        glColor3fv(color[2]);
   3.792 -        glVertex3fv(cube[2]);
   3.793 -
   3.794 -        glColor3fv(color[0]);
   3.795 -        glVertex3fv(cube[0]);
   3.796 -        glColor3fv(color[5]);
   3.797 -        glVertex3fv(cube[5]);
   3.798 -        glColor3fv(color[6]);
   3.799 -        glVertex3fv(cube[6]);
   3.800 -        glColor3fv(color[1]);
   3.801 -        glVertex3fv(cube[1]);
   3.802 -
   3.803 -        glColor3fv(color[5]);
   3.804 -        glVertex3fv(cube[5]);
   3.805 -        glColor3fv(color[4]);
   3.806 -        glVertex3fv(cube[4]);
   3.807 -        glColor3fv(color[7]);
   3.808 -        glVertex3fv(cube[7]);
   3.809 -        glColor3fv(color[6]);
   3.810 -        glVertex3fv(cube[6]);
   3.811 -
   3.812 -        glColor3fv(color[5]);
   3.813 -        glVertex3fv(cube[5]);
   3.814 -        glColor3fv(color[0]);
   3.815 -        glVertex3fv(cube[0]);
   3.816 -        glColor3fv(color[3]);
   3.817 -        glVertex3fv(cube[3]);
   3.818 -        glColor3fv(color[4]);
   3.819 -        glVertex3fv(cube[4]);
   3.820 -
   3.821 -        glColor3fv(color[6]);
   3.822 -        glVertex3fv(cube[6]);
   3.823 -        glColor3fv(color[1]);
   3.824 -        glVertex3fv(cube[1]);
   3.825 -        glColor3fv(color[2]);
   3.826 -        glVertex3fv(cube[2]);
   3.827 -        glColor3fv(color[7]);
   3.828 -        glVertex3fv(cube[7]);
   3.829 -#else /* flat cube */
   3.830 -        glColor3f(1.0, 0.0, 0.0);
   3.831 -        glVertex3fv(cube[0]);
   3.832 -        glVertex3fv(cube[1]);
   3.833 -        glVertex3fv(cube[2]);
   3.834 -        glVertex3fv(cube[3]);
   3.835 -
   3.836 -        glColor3f(0.0, 1.0, 0.0);
   3.837 -        glVertex3fv(cube[3]);
   3.838 -        glVertex3fv(cube[4]);
   3.839 -        glVertex3fv(cube[7]);
   3.840 -        glVertex3fv(cube[2]);
   3.841 -
   3.842 -        glColor3f(0.0, 0.0, 1.0);
   3.843 -        glVertex3fv(cube[0]);
   3.844 -        glVertex3fv(cube[5]);
   3.845 -        glVertex3fv(cube[6]);
   3.846 -        glVertex3fv(cube[1]);
   3.847 -
   3.848 -        glColor3f(0.0, 1.0, 1.0);
   3.849 -        glVertex3fv(cube[5]);
   3.850 -        glVertex3fv(cube[4]);
   3.851 -        glVertex3fv(cube[7]);
   3.852 -        glVertex3fv(cube[6]);
   3.853 -
   3.854 -        glColor3f(1.0, 1.0, 0.0);
   3.855 -        glVertex3fv(cube[5]);
   3.856 -        glVertex3fv(cube[0]);
   3.857 -        glVertex3fv(cube[3]);
   3.858 -        glVertex3fv(cube[4]);
   3.859 -
   3.860 -        glColor3f(1.0, 0.0, 1.0);
   3.861 -        glVertex3fv(cube[6]);
   3.862 -        glVertex3fv(cube[1]);
   3.863 -        glVertex3fv(cube[2]);
   3.864 -        glVertex3fv(cube[7]);
   3.865 -#endif /* SHADED_CUBE */
   3.866 -
   3.867 -        glEnd();
   3.868 -
   3.869 -        glMatrixMode(GL_MODELVIEW);
   3.870 -        glRotatef(5.0, 1.0, 1.0, 1.0);
   3.871 -
   3.872 -        /* Draw 2D logo onto the 3D display */
   3.873 -        if (logo) {
   3.874 -            DrawLogoTexture();
   3.875 -        }
   3.876 -        if (logocursor) {
   3.877 -            DrawLogoCursor();
   3.878 -        }
   3.879 -
   3.880 -        SDL_GL_SwapBuffers();
   3.881 -
   3.882 -        /* Check for error conditions. */
   3.883 -        gl_error = glGetError();
   3.884 -
   3.885 -        if (gl_error != GL_NO_ERROR) {
   3.886 -            fprintf(stderr, "testgl: OpenGL error: %d\n", gl_error);
   3.887 -        }
   3.888 -
   3.889 -        sdl_error = SDL_GetError();
   3.890 -
   3.891 -        if (sdl_error[0] != '\0') {
   3.892 -            fprintf(stderr, "testgl: SDL error '%s'\n", sdl_error);
   3.893 -            SDL_ClearError();
   3.894 -        }
   3.895 -
   3.896 -        /* Allow the user to see what's happening */
   3.897 -        if (slowly) {
   3.898 -            SDL_Delay(20);
   3.899 -        }
   3.900 -
   3.901 -        /* Check if there's a pending event. */
   3.902 -        while (SDL_PollEvent(&event)) {
   3.903 -            done = HandleEvent(&event);
   3.904 -        }
   3.905 -        ++frames;
   3.906 -    }
   3.907 -
   3.908 -    /* Print out the frames per second */
   3.909 -    this_time = SDL_GetTicks();
   3.910 -    if (this_time != start_time) {
   3.911 -        printf("%2.2f FPS\n",
   3.912 -               ((float) frames / (this_time - start_time)) * 1000.0);
   3.913 -    }
   3.914 -
   3.915 -    if (global_image) {
   3.916 -        SDL_FreeSurface(global_image);
   3.917 -        global_image = NULL;
   3.918 -    }
   3.919 -    if (global_texture) {
   3.920 -        glDeleteTextures(1, &global_texture);
   3.921 -        global_texture = 0;
   3.922 -    }
   3.923 -    if (cursor_texture) {
   3.924 -        glDeleteTextures(1, &cursor_texture);
   3.925 -        cursor_texture = 0;
   3.926 -    }
   3.927 -
   3.928 -    /* Destroy our GL context, etc. */
   3.929 -    SDL_Quit();
   3.930 -    return (0);
   3.931 -}
   3.932 -
   3.933 -int
   3.934 -main(int argc, char *argv[])
   3.935 -{
   3.936 -    int i, logo, logocursor = 0;
   3.937 -    int numtests;
   3.938 -    int bpp = 0;
   3.939 -    int slowly;
   3.940 -    float gamma = 0.0;
   3.941 -    int noframe = 0;
   3.942 -    int fsaa = 0;
   3.943 -    int accel = 0;
   3.944 -    int sync = 0;
   3.945 -
   3.946 -    logo = 0;
   3.947 -    slowly = 0;
   3.948 -    numtests = 1;
   3.949 -    for (i = 1; argv[i]; ++i) {
   3.950 -        if (strcmp(argv[i], "-twice") == 0) {
   3.951 -            ++numtests;
   3.952 -        }
   3.953 -        if (strcmp(argv[i], "-logo") == 0) {
   3.954 -            logo = 1;
   3.955 -        }
   3.956 -        if (strcmp(argv[i], "-logocursor") == 0) {
   3.957 -            logocursor = 1;
   3.958 -        }
   3.959 -        if (strcmp(argv[i], "-slow") == 0) {
   3.960 -            slowly = 1;
   3.961 -        }
   3.962 -        if (strcmp(argv[i], "-bpp") == 0) {
   3.963 -            bpp = atoi(argv[++i]);
   3.964 -        }
   3.965 -        if (strcmp(argv[i], "-gamma") == 0) {
   3.966 -            gamma = (float) atof(argv[++i]);
   3.967 -        }
   3.968 -        if (strcmp(argv[i], "-noframe") == 0) {
   3.969 -            noframe = 1;
   3.970 -        }
   3.971 -        if (strcmp(argv[i], "-fsaa") == 0) {
   3.972 -            ++fsaa;
   3.973 -        }
   3.974 -        if (strcmp(argv[i], "-accel") == 0) {
   3.975 -            ++accel;
   3.976 -        }
   3.977 -        if (strcmp(argv[i], "-sync") == 0) {
   3.978 -            ++sync;
   3.979 -        }
   3.980 -        if (strncmp(argv[i], "-h", 2) == 0) {
   3.981 -            printf
   3.982 -                ("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-accel] [-sync] [-fullscreen]\n",
   3.983 -                 argv[0]);
   3.984 -            exit(0);
   3.985 -        }
   3.986 -    }
   3.987 -    for (i = 0; i < numtests; ++i) {
   3.988 -        RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma,
   3.989 -                  noframe, fsaa, sync, accel);
   3.990 -    }
   3.991 -    return 0;
   3.992 +    quit(0);
   3.993  }
   3.994  
   3.995  #else /* HAVE_OPENGL */
     4.1 --- a/test/testsprite2.c	Tue Jul 18 07:49:51 2006 +0000
     4.2 +++ b/test/testsprite2.c	Wed Jul 19 04:24:41 2006 +0000
     4.3 @@ -134,14 +134,14 @@
     4.4          int consumed;
     4.5  
     4.6          consumed = CommonArg(state, i);
     4.7 +        if (consumed == 0) {
     4.8 +            num_sprites = SDL_atoi(argv[i]);
     4.9 +            consumed = 1;
    4.10 +        }
    4.11          if (consumed < 0) {
    4.12              fprintf(stderr, "Usage: %s %s", argv[0], CommonUsage(state));
    4.13              quit(1);
    4.14          }
    4.15 -        if (consumed == 0) {
    4.16 -            num_sprites = SDL_atoi(argv[i]);
    4.17 -            consumed = 1;
    4.18 -        }
    4.19          i += consumed;
    4.20      }
    4.21      if (!CommonInit(state)) {
    4.22 @@ -184,7 +184,7 @@
    4.23          }
    4.24      }
    4.25  
    4.26 -    /* Loop, blitting sprites and waiting for a keystroke */
    4.27 +    /* Main render loop */
    4.28      frames = 0;
    4.29      then = SDL_GetTicks();
    4.30      done = 0;