test/testgles2.c
author Gabriel Jacobo <gabomdq@gmail.com>
Tue, 19 Nov 2013 10:56:38 -0300
changeset 8014 0a4b6dec7de5
child 8021 f96e12e0ade9
permissions -rw-r--r--
Adds testgles2

Source code copied from: https://github.com/fantasydr/sdl-2.0-gles (thanks!)

Minor fixes, configure script changes done by me.
     1 /*
     2   Copyright (r) 1997-2011 Sam Lantinga <slouken@libsdl.org>
     3 
     4   This software is provided 'as-is', without any express or implied
     5   warranty.  In no event will the authors be held liable for any damages
     6   arising from the use of this software.
     7 
     8   Permission is granted to anyone to use this software for any purpose,
     9   including commercial applications, and to alter it and redistribute it
    10   freely.
    11 */
    12 #include <stdlib.h>
    13 #include <stdio.h>
    14 #include <string.h>
    15 #include <math.h>
    16 
    17 #include "SDL_test_common.h"
    18 
    19 #if defined(__IPHONEOS__) || defined(__ANDROID__)
    20 #define HAVE_OPENGLES2
    21 #endif
    22 
    23 #ifdef HAVE_OPENGLES2
    24 
    25 #include "SDL_opengles2.h"
    26 
    27 static SDLTest_CommonState *state;
    28 static SDL_GLContext *context = NULL;
    29 static int depth = 16;
    30 
    31 /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
    32 static void
    33 quit(int rc)
    34 {
    35     int i;
    36 
    37     if (context != NULL) {
    38         for (i = 0; i < state->num_windows; i++) {
    39             if (context[i]) {
    40                 SDL_GL_DeleteContext(context[i]);
    41             }
    42         }
    43 
    44         SDL_free(context);
    45     }
    46 
    47     SDLTest_CommonQuit(state);
    48     exit(rc);
    49 }
    50 
    51 #define GL_CHECK(x) \
    52         x; \
    53         { \
    54           GLenum glError = glGetError(); \
    55           if(glError != GL_NO_ERROR) { \
    56             fprintf(stderr, "glGetError() = %i (0x%.8x) at line %i\n", glError, glError, __LINE__); \
    57             quit(1); \
    58           } \
    59         }
    60 
    61 /* 
    62  * Simulates desktop's glRotatef. The matrix is returned in column-major 
    63  * order. 
    64  */
    65 static void
    66 rotate_matrix(double angle, double x, double y, double z, float *r)
    67 {
    68     double radians, c, s, c1, u[3], length;
    69     int i, j;
    70 
    71     radians = (angle * M_PI) / 180.0;
    72 
    73     c = cos(radians);
    74     s = sin(radians);
    75 
    76     c1 = 1.0 - cos(radians);
    77 
    78     length = sqrt(x * x + y * y + z * z);
    79 
    80     u[0] = x / length;
    81     u[1] = y / length;
    82     u[2] = z / length;
    83 
    84     for (i = 0; i < 16; i++) {
    85         r[i] = 0.0;
    86     }
    87 
    88     r[15] = 1.0;
    89 
    90     for (i = 0; i < 3; i++) {
    91         r[i * 4 + (i + 1) % 3] = u[(i + 2) % 3] * s;
    92         r[i * 4 + (i + 2) % 3] = -u[(i + 1) % 3] * s;
    93     }
    94 
    95     for (i = 0; i < 3; i++) {
    96         for (j = 0; j < 3; j++) {
    97             r[i * 4 + j] += c1 * u[i] * u[j] + (i == j ? c : 0.0);
    98         }
    99     }
   100 }
   101 
   102 /* 
   103  * Simulates gluPerspectiveMatrix 
   104  */
   105 static void 
   106 perspective_matrix(double fovy, double aspect, double znear, double zfar, float *r)
   107 {
   108     int i;
   109     double f;
   110 
   111     f = 1.0/tan(fovy * 0.5);
   112 
   113     for (i = 0; i < 16; i++) {
   114         r[i] = 0.0;
   115     }
   116 
   117     r[0] = f / aspect;
   118     r[5] = f;
   119     r[10] = (znear + zfar) / (znear - zfar);
   120     r[11] = -1.0;
   121     r[14] = (2.0 * znear * zfar) / (znear - zfar);
   122     r[15] = 0.0;
   123 }
   124 
   125 /* 
   126  * Multiplies lhs by rhs and writes out to r. All matrices are 4x4 and column
   127  * major. In-place multiplication is supported.
   128  */
   129 static void
   130 multiply_matrix(float *lhs, float *rhs, float *r)
   131 {
   132 	int i, j, k;
   133     float tmp[16];
   134 
   135     for (i = 0; i < 4; i++) {
   136         for (j = 0; j < 4; j++) {
   137             tmp[j * 4 + i] = 0.0;
   138 
   139             for (k = 0; k < 4; k++) {
   140                 tmp[j * 4 + i] += lhs[k * 4 + i] * rhs[j * 4 + k];
   141             }
   142         }
   143     }
   144 
   145     for (i = 0; i < 16; i++) {
   146         r[i] = tmp[i];
   147     }
   148 }
   149 
   150 /* 
   151  * Create shader, load in source, compile, dump debug as necessary.
   152  *
   153  * shader: Pointer to return created shader ID.
   154  * source: Passed-in shader source code.
   155  * shader_type: Passed to GL, e.g. GL_VERTEX_SHADER.
   156  */
   157 void 
   158 process_shader(GLuint *shader, const char * source, GLint shader_type)
   159 {
   160     GLint status;
   161     const char *shaders[1] = { NULL };
   162 
   163     /* Create shader and load into GL. */
   164     *shader = GL_CHECK(glCreateShader(shader_type));
   165 
   166     shaders[0] = source;
   167 
   168     GL_CHECK(glShaderSource(*shader, 1, shaders, NULL));
   169 
   170     /* Clean up shader source. */
   171     shaders[0] = NULL;
   172 
   173     /* Try compiling the shader. */
   174     GL_CHECK(glCompileShader(*shader));
   175     GL_CHECK(glGetShaderiv(*shader, GL_COMPILE_STATUS, &status));
   176 
   177     // Dump debug info (source and log) if compilation failed.
   178     if(status != GL_TRUE) {
   179         quit(-1);
   180     }
   181 }
   182 
   183 /* 3D data. Vertex range -0.5..0.5 in all axes.
   184 * Z -0.5 is near, 0.5 is far. */
   185 const float _vertices[] =
   186 {
   187     /* Front face. */
   188     /* Bottom left */
   189     -0.5,  0.5, -0.5,
   190     0.5, -0.5, -0.5,
   191     -0.5, -0.5, -0.5,
   192     /* Top right */
   193     -0.5,  0.5, -0.5,
   194     0.5,  0.5, -0.5,
   195     0.5, -0.5, -0.5,
   196     /* Left face */
   197     /* Bottom left */
   198     -0.5,  0.5,  0.5,
   199     -0.5, -0.5, -0.5,
   200     -0.5, -0.5,  0.5,
   201     /* Top right */
   202     -0.5,  0.5,  0.5,
   203     -0.5,  0.5, -0.5,
   204     -0.5, -0.5, -0.5,
   205     /* Top face */
   206     /* Bottom left */
   207     -0.5,  0.5,  0.5,
   208     0.5,  0.5, -0.5,
   209     -0.5,  0.5, -0.5,
   210     /* Top right */
   211     -0.5,  0.5,  0.5,
   212     0.5,  0.5,  0.5,
   213     0.5,  0.5, -0.5,
   214     /* Right face */
   215     /* Bottom left */
   216     0.5,  0.5, -0.5,
   217     0.5, -0.5,  0.5,
   218     0.5, -0.5, -0.5,
   219     /* Top right */
   220     0.5,  0.5, -0.5,
   221     0.5,  0.5,  0.5,
   222     0.5, -0.5,  0.5,
   223     /* Back face */
   224     /* Bottom left */
   225     0.5,  0.5,  0.5,
   226     -0.5, -0.5,  0.5,
   227     0.5, -0.5,  0.5,
   228     /* Top right */
   229     0.5,  0.5,  0.5,
   230     -0.5,  0.5,  0.5,
   231     -0.5, -0.5,  0.5,
   232     /* Bottom face */
   233     /* Bottom left */
   234     -0.5, -0.5, -0.5,
   235     0.5, -0.5,  0.5,
   236     -0.5, -0.5,  0.5,
   237     /* Top right */
   238     -0.5, -0.5, -0.5,
   239     0.5, -0.5, -0.5,
   240     0.5, -0.5,  0.5,
   241 };
   242 
   243 const float _colors[] =
   244 {
   245     /* Front face */
   246     /* Bottom left */
   247     1.0, 0.0, 0.0, /* red */
   248     0.0, 0.0, 1.0, /* blue */
   249     0.0, 1.0, 0.0, /* green */
   250     /* Top right */
   251     1.0, 0.0, 0.0, /* red */
   252     1.0, 1.0, 0.0, /* yellow */
   253     0.0, 0.0, 1.0, /* blue */
   254     /* Left face */
   255     /* Bottom left */
   256     1.0, 1.0, 1.0, /* white */
   257     0.0, 1.0, 0.0, /* green */
   258     0.0, 1.0, 1.0, /* cyan */
   259     /* Top right */
   260     1.0, 1.0, 1.0, /* white */
   261     1.0, 0.0, 0.0, /* red */
   262     0.0, 1.0, 0.0, /* green */
   263     /* Top face */
   264     /* Bottom left */
   265     1.0, 1.0, 1.0, /* white */
   266     1.0, 1.0, 0.0, /* yellow */
   267     1.0, 0.0, 0.0, /* red */
   268     /* Top right */
   269     1.0, 1.0, 1.0, /* white */
   270     0.0, 0.0, 0.0, /* black */
   271     1.0, 1.0, 0.0, /* yellow */
   272     /* Right face */
   273     /* Bottom left */
   274     1.0, 1.0, 0.0, /* yellow */
   275     1.0, 0.0, 1.0, /* magenta */
   276     0.0, 0.0, 1.0, /* blue */
   277     /* Top right */
   278     1.0, 1.0, 0.0, /* yellow */
   279     0.0, 0.0, 0.0, /* black */
   280     1.0, 0.0, 1.0, /* magenta */
   281     /* Back face */
   282     /* Bottom left */
   283     0.0, 0.0, 0.0, /* black */
   284     0.0, 1.0, 1.0, /* cyan */
   285     1.0, 0.0, 1.0, /* magenta */
   286     /* Top right */
   287     0.0, 0.0, 0.0, /* black */
   288     1.0, 1.0, 1.0, /* white */
   289     0.0, 1.0, 1.0, /* cyan */
   290     /* Bottom face */
   291     /* Bottom left */
   292     0.0, 1.0, 0.0, /* green */
   293     1.0, 0.0, 1.0, /* magenta */
   294     0.0, 1.0, 1.0, /* cyan */
   295     /* Top right */
   296     0.0, 1.0, 0.0, /* green */
   297     0.0, 0.0, 1.0, /* blue */
   298     1.0, 0.0, 1.0, /* magenta */
   299 };
   300 
   301 const char* _shader_vert_src = 
   302 " attribute vec4 av4position; "
   303 " attribute vec3 av3color; "
   304 " uniform mat4 mvp; "
   305 " varying vec3 vv3color; "
   306 " void main() { "
   307 "    vv3color = av3color; "
   308 "    gl_Position = mvp * av4position; "
   309 " } ";
   310 
   311 const char* _shader_frag_src = 
   312 " precision lowp float; "
   313 " varying vec3 vv3color; "
   314 " void main() { "
   315 "    gl_FragColor = vec4(vv3color, 1.0); "
   316 " } ";
   317 
   318 typedef struct shader_data
   319 {
   320     GLuint shader_program, shader_frag, shader_vert;
   321 
   322     GLint attr_position;
   323     GLint attr_color, attr_mvp;
   324 
   325     int angle_x, angle_y, angle_z;
   326 
   327 } shader_data;
   328 
   329 static void
   330 Render(unsigned int width, unsigned int height, shader_data* data)
   331 {
   332     float matrix_rotate[16], matrix_modelview[16], matrix_perspective[16], matrix_mvp[16];
   333 
   334     /* 
   335     * Do some rotation with Euler angles. It is not a fixed axis as
   336     * quaterions would be, but the effect is cool. 
   337     */
   338     rotate_matrix(data->angle_x, 1.0, 0.0, 0.0, matrix_modelview);
   339     rotate_matrix(data->angle_y, 0.0, 1.0, 0.0, matrix_rotate);
   340 
   341     multiply_matrix(matrix_rotate, matrix_modelview, matrix_modelview);
   342 
   343     rotate_matrix(data->angle_z, 0.0, 1.0, 0.0, matrix_rotate);
   344 
   345     multiply_matrix(matrix_rotate, matrix_modelview, matrix_modelview);
   346 
   347     /* Pull the camera back from the cube */
   348     matrix_modelview[14] -= 2.5;
   349 
   350     perspective_matrix(45.0, (double)width/(double)height, 0.01, 100.0, matrix_perspective);
   351     multiply_matrix(matrix_perspective, matrix_modelview, matrix_mvp);
   352 
   353     GL_CHECK(glUniformMatrix4fv(data->attr_mvp, 1, GL_FALSE, matrix_mvp));
   354 
   355     data->angle_x += 3;
   356     data->angle_y += 2;
   357     data->angle_z += 1;
   358 
   359     if(data->angle_x >= 360) data->angle_x -= 360;
   360     if(data->angle_x < 0) data->angle_x += 360;
   361     if(data->angle_y >= 360) data->angle_y -= 360;
   362     if(data->angle_y < 0) data->angle_y += 360;
   363     if(data->angle_z >= 360) data->angle_z -= 360;
   364     if(data->angle_z < 0) data->angle_z += 360;
   365 
   366     GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT));
   367     GL_CHECK(glDrawArrays(GL_TRIANGLES, 0, 36));
   368 }
   369 
   370 int
   371 main(int argc, char *argv[])
   372 {
   373     int fsaa, accel;
   374     int value;
   375     int i, done;
   376     SDL_DisplayMode mode;
   377     SDL_Event event;
   378     Uint32 then, now, frames;
   379     int status;
   380     shader_data *datas, *data;
   381 
   382     /* Initialize parameters */
   383     fsaa = 0;
   384     accel = 0;
   385 
   386     /* Initialize test framework */
   387     state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
   388     if (!state) {
   389         return 1;
   390     }
   391     for (i = 1; i < argc;) {
   392         int consumed;
   393 
   394         consumed = SDLTest_CommonArg(state, i);
   395         if (consumed == 0) {
   396             if (SDL_strcasecmp(argv[i], "--fsaa") == 0) {
   397                 ++fsaa;
   398                 consumed = 1;
   399             } else if (SDL_strcasecmp(argv[i], "--accel") == 0) {
   400                 ++accel;
   401                 consumed = 1;
   402             } else if (SDL_strcasecmp(argv[i], "--zdepth") == 0) {
   403                 i++;
   404                 if (!argv[i]) {
   405                     consumed = -1;
   406                 } else {
   407                     depth = SDL_atoi(argv[i]);
   408                     consumed = 1;
   409                 }
   410             } else {
   411                 consumed = -1;
   412             }
   413         }
   414         if (consumed < 0) {
   415             fprintf(stderr, "Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
   416                     SDLTest_CommonUsage(state));
   417             quit(1);
   418         }
   419         i += consumed;
   420     }
   421 
   422     /* Set OpenGL parameters */
   423     state->window_flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
   424     state->gl_red_size = 5;
   425     state->gl_green_size = 5;
   426     state->gl_blue_size = 5;
   427     state->gl_depth_size = depth;
   428     state->gl_major_version = 2;
   429     state->gl_minor_version = 0;
   430     state->gl_profile_mask = SDL_GL_CONTEXT_PROFILE_ES;
   431 
   432     if (fsaa) {
   433         state->gl_multisamplebuffers=1;
   434         state->gl_multisamplesamples=fsaa;
   435     }
   436     if (accel) {
   437         state->gl_accelerated=1;
   438     }
   439     if (!SDLTest_CommonInit(state)) {
   440         return;
   441         quit(2);
   442     }
   443 
   444     context = SDL_calloc(state->num_windows, sizeof(context));
   445     if (context == NULL) {
   446         fprintf(stderr, "Out of memory!\n");
   447         quit(2);
   448     }
   449     
   450     /* Create OpenGL ES contexts */
   451     for (i = 0; i < state->num_windows; i++) {
   452         context[i] = SDL_GL_CreateContext(state->windows[i]);
   453         if (!context[i]) {
   454             fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
   455             quit(2);
   456         }
   457     }
   458 
   459     if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) {
   460         SDL_GL_SetSwapInterval(1);
   461     } else {
   462         SDL_GL_SetSwapInterval(0);
   463     }
   464 
   465     SDL_GetCurrentDisplayMode(0, &mode);
   466     printf("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
   467     printf("\n");
   468     printf("Vendor     : %s\n", glGetString(GL_VENDOR));
   469     printf("Renderer   : %s\n", glGetString(GL_RENDERER));
   470     printf("Version    : %s\n", glGetString(GL_VERSION));
   471     printf("Extensions : %s\n", glGetString(GL_EXTENSIONS));
   472     printf("\n");
   473 
   474     status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
   475     if (!status) {
   476         printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
   477     } else {
   478         fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n",
   479                 SDL_GetError());
   480     }
   481     status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
   482     if (!status) {
   483         printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
   484     } else {
   485         fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
   486                 SDL_GetError());
   487     }
   488     status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
   489     if (!status) {
   490         printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
   491     } else {
   492         fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
   493                 SDL_GetError());
   494     }
   495     status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
   496     if (!status) {
   497         printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
   498     } else {
   499         fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
   500                 SDL_GetError());
   501     }
   502     if (fsaa) {
   503         status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
   504         if (!status) {
   505             printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
   506         } else {
   507             fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
   508                     SDL_GetError());
   509         }
   510         status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
   511         if (!status) {
   512             printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
   513                    value);
   514         } else {
   515             fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
   516                     SDL_GetError());
   517         }
   518     }
   519     if (accel) {
   520         status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
   521         if (!status) {
   522             printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
   523         } else {
   524             fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
   525                     SDL_GetError());
   526         }
   527     }
   528 
   529     datas = SDL_calloc(state->num_windows, sizeof(shader_data));
   530 
   531     /* Set rendering settings for each context */
   532     for (i = 0; i < state->num_windows; ++i) {
   533 
   534         status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
   535         if (status) {
   536             printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
   537 
   538             /* Continue for next window */
   539             continue;
   540         }
   541         glViewport(0, 0, state->window_w, state->window_h);
   542 
   543         data = &datas[i];
   544         data->angle_x = 0; data->angle_y = 0; data->angle_z = 0;
   545 
   546         /* Shader Initialization */
   547         process_shader(&data->shader_vert, _shader_vert_src, GL_VERTEX_SHADER);
   548         process_shader(&data->shader_frag, _shader_frag_src, GL_FRAGMENT_SHADER);
   549 
   550         /* Create shader_program (ready to attach shaders) */
   551         data->shader_program = GL_CHECK(glCreateProgram());
   552 
   553         /* Attach shaders and link shader_program */
   554         GL_CHECK(glAttachShader(data->shader_program, data->shader_vert));
   555         GL_CHECK(glAttachShader(data->shader_program, data->shader_frag));
   556         GL_CHECK(glLinkProgram(data->shader_program));
   557 
   558         /* Get attribute locations of non-fixed attributes like color and texture coordinates. */
   559         data->attr_position = GL_CHECK(glGetAttribLocation(data->shader_program, "av4position"));
   560         data->attr_color = GL_CHECK(glGetAttribLocation(data->shader_program, "av3color"));
   561 
   562         /* Get uniform locations */
   563         data->attr_mvp = GL_CHECK(glGetUniformLocation(data->shader_program, "mvp"));
   564 
   565         GL_CHECK(glUseProgram(data->shader_program));
   566 
   567         /* Enable attributes for position, color and texture coordinates etc. */
   568         GL_CHECK(glEnableVertexAttribArray(data->attr_position));
   569         GL_CHECK(glEnableVertexAttribArray(data->attr_color));
   570 
   571         /* Populate attributes for position, color and texture coordinates etc. */
   572         GL_CHECK(glVertexAttribPointer(data->attr_position, 3, GL_FLOAT, GL_FALSE, 0, _vertices));
   573         GL_CHECK(glVertexAttribPointer(data->attr_color, 3, GL_FLOAT, GL_FALSE, 0, _colors));
   574 
   575         GL_CHECK(glEnable(GL_CULL_FACE));
   576         GL_CHECK(glEnable(GL_DEPTH_TEST));
   577     }
   578 
   579     /* Main render loop */
   580     frames = 0;
   581     then = SDL_GetTicks();
   582     done = 0;
   583     while (!done) {
   584         /* Check for events */
   585         ++frames;
   586         while (SDL_PollEvent(&event)) {
   587             switch (event.type) {
   588             case SDL_WINDOWEVENT:
   589                 switch (event.window.event) {
   590                     case SDL_WINDOWEVENT_RESIZED:
   591                         for (i = 0; i < state->num_windows; ++i) {
   592                             if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
   593                                 status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
   594                                 if (status) {
   595                                     printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
   596                                     break;
   597                                 }
   598                                 /* Change view port to the new window dimensions */
   599                                 glViewport(0, 0, event.window.data1, event.window.data2);
   600                                 /* Update window content */
   601                                 Render(event.window.data1, event.window.data2, &datas[i]);
   602                                 SDL_GL_SwapWindow(state->windows[i]);
   603                                 break;
   604                             }
   605                         }
   606                         break;
   607                 }
   608             }
   609             SDLTest_CommonEvent(state, &event, &done);
   610         }
   611         for (i = 0; i < state->num_windows; ++i) {
   612             status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
   613             if (status) {
   614                 printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
   615 
   616                 /* Continue for next window */
   617                 continue;
   618             }
   619             Render(state->window_w, state->window_h, &datas[i]);
   620             SDL_GL_SwapWindow(state->windows[i]);
   621         }
   622     }
   623 
   624     /* Print out some timing information */
   625     now = SDL_GetTicks();
   626     if (now > then) {
   627         printf("%2.2f frames per second\n",
   628                ((double) frames * 1000) / (now - then));
   629     }
   630 #if !defined(__ANDROID__)    
   631     quit(0);
   632 #endif    
   633     return 0;
   634 }
   635 
   636 #else /* HAVE_OPENGLES2 */
   637 
   638 int
   639 main(int argc, char *argv[])
   640 {
   641     printf("No OpenGL ES support on this system\n");
   642     return 1;
   643 }
   644 
   645 #endif /* HAVE_OPENGLES2 */
   646 
   647 /* vi: set ts=4 sw=4 expandtab: */