visualtest/src/variators.c
author Sam Lantinga
Tue, 10 Jan 2017 08:54:33 -0800
changeset 10806 36f40b8cc979
parent 7924 fcb86d323770
permissions -rw-r--r--
Fixed bugs 2570, 3145, improved OpenGL ES context support on Windows and X11

Mark Callow

The attached patch does the following for the X11 and Windows platforms, the only ones where SDL attempts to use context_create_es_profile:

- Adds SDL_HINT_OPENGL_ES_DRIVER by which the application can
say to use the OpenGL ES driver & EGL rather than the Open GL
driver. (For bug #2570)
- Adds code to {WIN,X11}_GL_InitExtensions to determine the maximum
OpenGL ES version supported by the OpenGL driver (for bug #3145)
- Modifies the test that determines whether to use the OpenGL
driver or the real OpenGL ES driver to take into account the
hint, the requested and supported ES version and whether ES 1.X
is being requested. (For bug #2570 & bug #3145)
- Enables the testgles2 test for __WINDOWS__ and __LINUX__ and adds
the test to the VisualC projects.

With the fix in place I have run testdraw2, testgl and testgles2 without any issues and have run my own apps that use OpenGL, OpenGL ES 3 and OpenGL ES 1.1.
icculus@7924
     1
/* See COPYING.txt for the full license governing this code. */
icculus@7924
     2
/**
icculus@7924
     3
 * \file variators.c
icculus@7924
     4
 *
icculus@7924
     5
 * Source file for the operations that act on variators.
icculus@7924
     6
 */
icculus@7924
     7
icculus@7924
     8
#include <SDL_test.h>
icculus@7924
     9
#include "SDL_visualtest_variators.h"
icculus@7924
    10
icculus@7924
    11
int
icculus@7924
    12
SDLVisualTest_InitVariator(SDLVisualTest_Variator* variator,
icculus@7924
    13
                           SDLVisualTest_SUTConfig* config,
icculus@7924
    14
                           SDLVisualTest_VariatorType type,
icculus@7924
    15
                           Uint64 seed)
icculus@7924
    16
{
icculus@7924
    17
    if(!variator)
icculus@7924
    18
    {
icculus@7924
    19
        SDLTest_LogError("variator argument cannot be NULL");
icculus@7924
    20
        return 0;
icculus@7924
    21
    }
icculus@7924
    22
    if(!config)
icculus@7924
    23
    {
icculus@7924
    24
        SDLTest_LogError("config argument cannot be NULL");
icculus@7924
    25
        return 0;
icculus@7924
    26
    }
icculus@7924
    27
icculus@7924
    28
    variator->type = type;
icculus@7924
    29
    switch(type)
icculus@7924
    30
    {
icculus@7924
    31
        case SDL_VARIATOR_EXHAUSTIVE:
icculus@7924
    32
            return SDLVisualTest_InitExhaustiveVariator(&variator->data.exhaustive,
icculus@7924
    33
                                                        config);
icculus@7924
    34
        break;
icculus@7924
    35
icculus@7924
    36
        case SDL_VARIATOR_RANDOM:
icculus@7924
    37
            return SDLVisualTest_InitRandomVariator(&variator->data.random,
icculus@7924
    38
                                                    config, seed);
icculus@7924
    39
        break;
icculus@7924
    40
icculus@7924
    41
        default:
icculus@7924
    42
            SDLTest_LogError("Invalid value for variator type");
icculus@7924
    43
            return 0;
icculus@7924
    44
    }
icculus@7924
    45
    return 0;
icculus@7924
    46
}
icculus@7924
    47
icculus@7924
    48
char*
icculus@7924
    49
SDLVisualTest_GetNextVariation(SDLVisualTest_Variator* variator)
icculus@7924
    50
{
icculus@7924
    51
    if(!variator)
icculus@7924
    52
    {
icculus@7924
    53
        SDLTest_LogError("variator argument cannot be NULL");
icculus@7924
    54
        return NULL;
icculus@7924
    55
    }
icculus@7924
    56
    switch(variator->type)
icculus@7924
    57
    {
icculus@7924
    58
        case SDL_VARIATOR_EXHAUSTIVE:
icculus@7924
    59
            return SDLVisualTest_GetNextExhaustiveVariation(&variator->data.exhaustive);
icculus@7924
    60
        break;
icculus@7924
    61
icculus@7924
    62
        case SDL_VARIATOR_RANDOM:
icculus@7924
    63
            return SDLVisualTest_GetNextRandomVariation(&variator->data.random);
icculus@7924
    64
        break;
icculus@7924
    65
icculus@7924
    66
        default:
icculus@7924
    67
            SDLTest_LogError("Invalid value for variator type");
icculus@7924
    68
            return NULL;
icculus@7924
    69
    }
icculus@7924
    70
    return NULL;
icculus@7924
    71
}
icculus@7924
    72
icculus@7924
    73
void SDLVisualTest_FreeVariator(SDLVisualTest_Variator* variator)
icculus@7924
    74
{
icculus@7924
    75
    if(!variator)
icculus@7924
    76
    {
icculus@7924
    77
        SDLTest_LogError("variator argument cannot be NULL");
icculus@7924
    78
        return;
icculus@7924
    79
    }
icculus@7924
    80
    switch(variator->type)
icculus@7924
    81
    {
icculus@7924
    82
        case SDL_VARIATOR_EXHAUSTIVE:
icculus@7924
    83
            SDLVisualTest_FreeExhaustiveVariator(&variator->data.exhaustive);
icculus@7924
    84
        break;
icculus@7924
    85
icculus@7924
    86
        case SDL_VARIATOR_RANDOM:
icculus@7924
    87
            SDLVisualTest_FreeRandomVariator(&variator->data.random);
icculus@7924
    88
        break;
icculus@7924
    89
icculus@7924
    90
        default:
icculus@7924
    91
            SDLTest_LogError("Invalid value for variator type");
icculus@7924
    92
    }
icculus@7924
    93
}