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