Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Added a hint to control whether the OpenGL driver uses shaders.
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Feb 9, 2011
1 parent 76e3d99 commit 180d6b2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
15 changes: 15 additions & 0 deletions include/SDL_hints.h
Expand Up @@ -77,11 +77,26 @@ extern "C" {
* This variable is case insensitive and can be set to the following values:
* "direct3d"
* "opengl"
* "opengles2"
* "opengles"
* "software"
*
* The default varies by platform, but it's the first one in the list that
* is available on the current platform.
*/
#define SDL_HINT_RENDER_DRIVER "SDL_RENDER_DRIVER"

/**
* \brief A variable controlling whether the OpenGL render driver uses shaders if they are available.
*
* This variable can be set to the following values:
* "0" - Disable shaders
* "1" - Enable shaders
*
* By default shaders are used if OpenGL supports them.
*/
#define SDL_HINT_RENDER_OPENGL_SHADERS "SDL_RENDER_OPENGL_SHADERS"

/**
* \brief A variable controlling whether updates to the SDL 1.2 screen surface should be synchronized with the vertical refresh, to avoid tearing.
*
Expand Down
10 changes: 9 additions & 1 deletion src/render/opengl/SDL_render_gl.c
Expand Up @@ -23,6 +23,8 @@

#if SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED

#include "SDL_hints.h"
#include "SDL_log.h"
#include "SDL_opengl.h"
#include "../SDL_sysrender.h"
#include "SDL_shaders_gl.h"
Expand Down Expand Up @@ -183,6 +185,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
{
SDL_Renderer *renderer;
GL_RenderData *data;
const char *hint;
GLint value;
Uint32 window_flags;

Expand Down Expand Up @@ -282,7 +285,12 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
}

/* Check for shader support */
data->shaders = GL_CreateShaderContext();
hint = SDL_GetHint(SDL_HINT_RENDER_OPENGL_SHADERS);
if (!hint || *hint != '0') {
data->shaders = GL_CreateShaderContext();
}
SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, "OpenGL shaders: %s",
data->shaders ? "ENABLED" : "DISABLED");

#if 0
/* We support YV12 textures using 3 textures and a shader */
Expand Down

0 comments on commit 180d6b2

Please sign in to comment.