test/testgles.c
author Sam Lantinga <slouken@libsdl.org>
Sat, 05 Oct 2013 19:09:03 -0700
changeset 7787 e6f3e8fc96ea
parent 7639 9406b7dd2f2d
child 7794 7995e0920bf9
permissions -rw-r--r--
Fixed bug 2132 - Tests may use invalid SDL_window pointers when windows are closed norfanin Some of the tests keep using the pointers of a destroyed SDL_Window when the common event handling handled the close event. The event handler itself does not NULL the pointer after the destruction. The attached patch adds a loop in the handler that will assign NULL to the destroyed window. It also adds checks to some of the tests so they skip those windows by checking for NULL.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5520
diff changeset
     1
/*
7517
965d57022c01 Updated the copyright year for the test programs
Sam Lantinga <slouken@libsdl.org>
parents: 6785
diff changeset
     2
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5520
diff changeset
     3
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5520
diff changeset
     4
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5520
diff changeset
     5
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5520
diff changeset
     6
  arising from the use of this software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5520
diff changeset
     7
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5520
diff changeset
     8
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5520
diff changeset
     9
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5520
diff changeset
    10
  freely.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5520
diff changeset
    11
*/
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
#include <stdlib.h>
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
#include <stdio.h>
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
#include <string.h>
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
#include <math.h>
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
    17
#include "SDL_test_common.h"
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
4961
c92950635837 Android has OpenGL ES too...
Sam Lantinga <slouken@libsdl.org>
parents: 3408
diff changeset
    19
#if defined(__IPHONEOS__) || defined(__ANDROID__)
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
#define HAVE_OPENGLES
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
#endif
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
#ifdef HAVE_OPENGLES
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
#include "SDL_opengles.h"
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
    27
static SDLTest_CommonState *state;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
    28
static SDL_GLContext *context = NULL;
3408
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
    29
static int depth = 16;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
static void
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
quit(int rc)
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
{
3110
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
    35
    int i;
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
    36
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
    37
    if (context != NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
    38
        for (i = 0; i < state->num_windows; i++) {
3110
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
    39
            if (context[i]) {
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
    40
                SDL_GL_DeleteContext(context[i]);
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
    41
            }
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
    42
        }
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
    43
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
    44
        SDL_free(context);
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
    }
3110
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
    46
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
    47
    SDLTest_CommonQuit(state);
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
    exit(rc);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
static void
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
Render()
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
{
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
    static GLubyte color[8][4] = { {255, 0, 0, 0},
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
    {255, 0, 0, 255},
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
    {0, 255, 0, 255},
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
    {0, 255, 0, 255},
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
    {0, 255, 0, 255},
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
    {255, 255, 255, 255},
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
    {255, 0, 255, 255},
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
    {0, 0, 255, 255}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
    };
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
    static GLfloat cube[8][3] = { {0.5, 0.5, -0.5},
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
    {0.5f, -0.5f, -0.5f},
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
    {-0.5f, -0.5f, -0.5f},
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
    {-0.5f, 0.5f, -0.5f},
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
    {-0.5f, 0.5f, 0.5f},
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
    {0.5f, 0.5f, 0.5f},
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
    {0.5f, -0.5f, 0.5f},
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
    {-0.5f, -0.5f, 0.5f}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
    };
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
    static GLubyte indices[36] = { 0, 3, 4,
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
        4, 5, 0,
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
        0, 5, 6,
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
        6, 1, 0,
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
        6, 7, 2,
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
        2, 1, 6,
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
        7, 4, 3,
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
        3, 2, 7,
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
        5, 4, 7,
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
        7, 6, 5,
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
        2, 3, 1,
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
        3, 0, 1
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
    };
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
    /* Do our drawing, too. */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
    glClearColor(0.0, 0.0, 0.0, 1.0);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
    /* Draw the cube */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
    glColorPointer(4, GL_UNSIGNED_BYTE, 0, color);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
    glEnableClientState(GL_COLOR_ARRAY);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
    glVertexPointer(3, GL_FLOAT, 0, cube);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
    glEnableClientState(GL_VERTEX_ARRAY);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
    glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_BYTE, indices);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
    glMatrixMode(GL_MODELVIEW);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
    glRotatef(5.0, 1.0, 1.0, 1.0);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
int
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
main(int argc, char *argv[])
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
{
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
    int fsaa, accel;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
    int value;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
    int i, done;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
    SDL_DisplayMode mode;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
    SDL_Event event;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
    Uint32 then, now, frames;
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   111
    int status;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   113
    /* Enable standard application logging */
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   114
    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   115
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
    /* Initialize parameters */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
    fsaa = 0;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
    accel = 0;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
    /* Initialize test framework */
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   121
    state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
    if (!state) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
        return 1;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
    }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
    for (i = 1; i < argc;) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
        int consumed;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   128
        consumed = SDLTest_CommonArg(state, i);
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
        if (consumed == 0) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
            if (SDL_strcasecmp(argv[i], "--fsaa") == 0) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
                ++fsaa;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
                consumed = 1;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
            } else if (SDL_strcasecmp(argv[i], "--accel") == 0) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
                ++accel;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
                consumed = 1;
3408
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
   136
            } else if (SDL_strcasecmp(argv[i], "--zdepth") == 0) {
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
   137
                i++;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
   138
                if (!argv[i]) {
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
   139
                    consumed = -1;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
   140
                } else {
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
   141
                    depth = SDL_atoi(argv[i]);
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
   142
                    consumed = 1;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
   143
                }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
            } else {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
                consumed = -1;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
            }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
        }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
        if (consumed < 0) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   149
            SDL_Log("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   150
                    SDLTest_CommonUsage(state));
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
            quit(1);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
        }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
        i += consumed;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
    }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
    /* Set OpenGL parameters */
5520
09b500e0656d Added orientation rotation for iOS.
Ryan C. Gordon <icculus@icculus.org>
parents: 5363
diff changeset
   157
    state->window_flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS;
3408
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
   158
    state->gl_red_size = 5;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
   159
    state->gl_green_size = 5;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
   160
    state->gl_blue_size = 5;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
   161
    state->gl_depth_size = depth;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
    if (fsaa) {
3408
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
   163
        state->gl_multisamplebuffers=1;
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
   164
        state->gl_multisamplesamples=fsaa;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
    }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   166
    if (accel) {
3408
55541ddf13e3 Support for GL initialization parameters has been added.
Mike Gorchak <lestat@i.com.ua>
parents: 3398
diff changeset
   167
        state->gl_accelerated=1;
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
    }
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   169
    if (!SDLTest_CommonInit(state)) {
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
        quit(2);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
    }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
3398
5ecc05616f39 Fixed memory allocation size.
Mike Gorchak <lestat@i.com.ua>
parents: 3397
diff changeset
   173
    context = SDL_calloc(state->num_windows, sizeof(context));
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   174
    if (context == NULL) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   175
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   176
        quit(2);
3110
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   177
    }
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   178
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   179
    /* Create OpenGL ES contexts */
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   180
    for (i = 0; i < state->num_windows; i++) {
3110
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   181
        context[i] = SDL_GL_CreateContext(state->windows[i]);
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   182
        if (!context[i]) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   183
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GL_CreateContext(): %s\n", SDL_GetError());
3110
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   184
            quit(2);
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   185
        }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   186
    }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   188
    if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
        SDL_GL_SetSwapInterval(1);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
    } else {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
        SDL_GL_SetSwapInterval(0);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   192
    }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   193
5363
96799a165806 Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents: 4961
diff changeset
   194
    SDL_GetCurrentDisplayMode(0, &mode);
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   195
    SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   196
    SDL_Log("\n");
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   197
    SDL_Log("Vendor     : %s\n", glGetString(GL_VENDOR));
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   198
    SDL_Log("Renderer   : %s\n", glGetString(GL_RENDERER));
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   199
    SDL_Log("Version    : %s\n", glGetString(GL_VERSION));
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   200
    SDL_Log("Extensions : %s\n", glGetString(GL_EXTENSIONS));
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   201
    SDL_Log("\n");
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   202
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   203
    status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   204
    if (!status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   205
        SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   206
    } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   207
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_RED_SIZE: %s\n",
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   208
                SDL_GetError());
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   209
    }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   210
    status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   211
    if (!status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   212
        SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   213
    } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   214
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_GREEN_SIZE: %s\n",
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   215
                SDL_GetError());
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   216
    }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   217
    status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   218
    if (!status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   219
        SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   220
    } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   221
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_BLUE_SIZE: %s\n",
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   222
                SDL_GetError());
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   223
    }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   224
    status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   225
    if (!status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   226
        SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   227
    } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   228
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   229
                SDL_GetError());
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   230
    }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   231
    if (fsaa) {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   232
        status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   233
        if (!status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   234
            SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   235
        } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   236
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   237
                    SDL_GetError());
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   238
        }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   239
        status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   240
        if (!status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   241
            SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   242
                   value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   243
        } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   244
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   245
                    SDL_GetError());
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   246
        }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   247
    }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
    if (accel) {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   249
        status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   250
        if (!status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   251
            SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   252
        } else {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   253
            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   254
                    SDL_GetError());
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2765
diff changeset
   255
        }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
    }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   257
3110
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   258
    /* Set rendering settings for each context */
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   259
    for (i = 0; i < state->num_windows; ++i) {
5363
96799a165806 Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents: 4961
diff changeset
   260
        float aspectAdjust;
96799a165806 Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents: 4961
diff changeset
   261
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   262
        status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   263
        if (status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   264
            SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
3110
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   265
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   266
            /* Continue for next window */
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   267
            continue;
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   268
        }
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   269
5363
96799a165806 Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents: 4961
diff changeset
   270
        aspectAdjust = (4.0f / 3.0f) / ((float)state->window_w / state->window_h);
3397
c64ae6ee6a6d Fixed handling of the initial window size.
Mike Gorchak <lestat@i.com.ua>
parents: 3194
diff changeset
   271
        glViewport(0, 0, state->window_w, state->window_h);
3110
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   272
        glMatrixMode(GL_PROJECTION);
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   273
        glLoadIdentity();
5363
96799a165806 Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents: 4961
diff changeset
   274
        glOrthof(-2.0, 2.0, -2.0 * aspectAdjust, 2.0 * aspectAdjust, -20.0, 20.0);
3110
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   275
        glMatrixMode(GL_MODELVIEW);
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   276
        glLoadIdentity();
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   277
        glEnable(GL_DEPTH_TEST);
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   278
        glDepthFunc(GL_LESS);
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   279
        glShadeModel(GL_SMOOTH);
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   280
    }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   281
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   282
    /* Main render loop */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   283
    frames = 0;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   284
    then = SDL_GetTicks();
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   285
    done = 0;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   286
    while (!done) {
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   287
        /* Check for events */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   288
        ++frames;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   289
        while (SDL_PollEvent(&event)) {
3194
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   290
            switch (event.type) {
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   291
            case SDL_WINDOWEVENT:
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   292
                switch (event.window.event) {
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   293
                    case SDL_WINDOWEVENT_RESIZED:
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   294
                        for (i = 0; i < state->num_windows; ++i) {
5363
96799a165806 Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents: 4961
diff changeset
   295
                            if (event.window.windowID == SDL_GetWindowID(state->windows[i])) {
3194
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   296
                                status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   297
                                if (status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   298
                                    SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
3194
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   299
                                    break;
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   300
                                }
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   301
                                /* Change view port to the new window dimensions */
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   302
                                glViewport(0, 0, event.window.data1, event.window.data2);
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   303
                                /* Update window content */
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   304
                                Render();
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   305
                                SDL_GL_SwapWindow(state->windows[i]);
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   306
                                break;
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   307
                            }
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   308
                        }
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   309
                        break;
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   310
                }
c18c03927a77 Proper window resize handling in GLES test application.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   311
            }
6785
c094c438c0a6 Switched the test code over to use the common functions in the test library.
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   312
            SDLTest_CommonEvent(state, &event, &done);
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   313
        }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   314
        for (i = 0; i < state->num_windows; ++i) {
7787
e6f3e8fc96ea Fixed bug 2132 - Tests may use invalid SDL_window pointers when windows are closed
Sam Lantinga <slouken@libsdl.org>
parents: 7639
diff changeset
   315
            if (state->windows[i] == NULL)
e6f3e8fc96ea Fixed bug 2132 - Tests may use invalid SDL_window pointers when windows are closed
Sam Lantinga <slouken@libsdl.org>
parents: 7639
diff changeset
   316
                continue;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   317
            status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   318
            if (status) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   319
                SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
3110
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   320
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   321
                /* Continue for next window */
Sam Lantinga <slouken@libsdl.org>
parents: 3110
diff changeset
   322
                continue;
3110
e6c21c14ce3a Added OpenGL ES context creation for the each window which has been created (for --windows=N option).
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
   323
            }
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   324
            Render();
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   325
            SDL_GL_SwapWindow(state->windows[i]);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   326
        }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   327
    }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   328
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   329
    /* Print out some timing information */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   330
    now = SDL_GetTicks();
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   331
    if (now > then) {
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   332
        SDL_Log("%2.2f frames per second\n",
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   333
               ((double) frames * 1000) / (now - then));
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   334
    }
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   335
    quit(0);
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   336
    return 0;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   337
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   338
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   339
#else /* HAVE_OPENGLES */
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   340
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   341
int
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   342
main(int argc, char *argv[])
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   343
{
7639
9406b7dd2f2d Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7517
diff changeset
   344
    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL ES support on this system\n");
2765
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   345
    return 1;
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   346
}
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   347
f55c87ae336b Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   348
#endif /* HAVE_OPENGLES */
5363
96799a165806 Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents: 4961
diff changeset
   349
96799a165806 Fixed testgles on iOS (bug 1136)
Sam Lantinga <slouken@libsdl.org>
parents: 4961
diff changeset
   350
/* vi: set ts=4 sw=4 expandtab: */