Added a hint to control whether the OpenGL driver uses shaders.
authorSam Lantinga <slouken@libsdl.org>
Tue, 08 Feb 2011 22:40:19 -0800
changeset 5233ce4f91138031
parent 5232 74bc160186a8
child 5234 af8ca17f6b7c
Added a hint to control whether the OpenGL driver uses shaders.
include/SDL_hints.h
src/render/opengl/SDL_render_gl.c
     1.1 --- a/include/SDL_hints.h	Tue Feb 08 22:11:16 2011 -0800
     1.2 +++ b/include/SDL_hints.h	Tue Feb 08 22:40:19 2011 -0800
     1.3 @@ -77,12 +77,27 @@
     1.4   *  This variable is case insensitive and can be set to the following values:
     1.5   *    "direct3d"
     1.6   *    "opengl"
     1.7 + *    "opengles2"
     1.8   *    "opengles"
     1.9   *    "software"
    1.10 + *
    1.11 + *  The default varies by platform, but it's the first one in the list that
    1.12 + *  is available on the current platform.
    1.13   */
    1.14  #define SDL_HINT_RENDER_DRIVER              "SDL_RENDER_DRIVER"
    1.15  
    1.16  /**
    1.17 + *  \brief  A variable controlling whether the OpenGL render driver uses shaders if they are available.
    1.18 + *
    1.19 + *  This variable can be set to the following values:
    1.20 + *    "0"       - Disable shaders
    1.21 + *    "1"       - Enable shaders
    1.22 + *
    1.23 + *  By default shaders are used if OpenGL supports them.
    1.24 + */
    1.25 +#define SDL_HINT_RENDER_OPENGL_SHADERS      "SDL_RENDER_OPENGL_SHADERS"
    1.26 +
    1.27 +/**
    1.28   *  \brief  A variable controlling whether updates to the SDL 1.2 screen surface should be synchronized with the vertical refresh, to avoid tearing.
    1.29   *
    1.30   *  This variable can be set to the following values:
     2.1 --- a/src/render/opengl/SDL_render_gl.c	Tue Feb 08 22:11:16 2011 -0800
     2.2 +++ b/src/render/opengl/SDL_render_gl.c	Tue Feb 08 22:40:19 2011 -0800
     2.3 @@ -23,6 +23,8 @@
     2.4  
     2.5  #if SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED
     2.6  
     2.7 +#include "SDL_hints.h"
     2.8 +#include "SDL_log.h"
     2.9  #include "SDL_opengl.h"
    2.10  #include "../SDL_sysrender.h"
    2.11  #include "SDL_shaders_gl.h"
    2.12 @@ -183,6 +185,7 @@
    2.13  {
    2.14      SDL_Renderer *renderer;
    2.15      GL_RenderData *data;
    2.16 +    const char *hint;
    2.17      GLint value;
    2.18      Uint32 window_flags;
    2.19  
    2.20 @@ -282,7 +285,12 @@
    2.21      }
    2.22  
    2.23      /* Check for shader support */
    2.24 -    data->shaders = GL_CreateShaderContext();
    2.25 +    hint = SDL_GetHint(SDL_HINT_RENDER_OPENGL_SHADERS);
    2.26 +    if (!hint || *hint != '0') {
    2.27 +        data->shaders = GL_CreateShaderContext();
    2.28 +    }
    2.29 +    SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, "OpenGL shaders: %s",
    2.30 +                data->shaders ? "ENABLED" : "DISABLED");
    2.31  
    2.32  #if 0
    2.33      /* We support YV12 textures using 3 textures and a shader */