Add configurable GL context.

This commit is contained in:
Themaister 2013-02-23 14:49:49 +01:00
parent 232706d665
commit eb0476ffab
6 changed files with 50 additions and 8 deletions

View File

@ -155,6 +155,7 @@ struct settings
struct
{
char driver[32];
char gl_context[32];
float xscale;
float yscale;
bool fullscreen;

View File

@ -630,6 +630,6 @@ const gfx_ctx_driver_t gfx_ctx_drm_egl = {
gfx_ctx_init_egl_image_buffer,
gfx_ctx_write_egl_image,
NULL,
"drm-egl",
"kms-egl",
};

View File

@ -369,7 +369,7 @@ static bool gfx_ctx_set_video_mode(
if (true_full)
{
RARCH_LOG("[GLX]: Using true fullscreen.\n");
RARCH_LOG("[X/EGL]: Using true fullscreen.\n");
XMapRaised(g_dpy, g_win);
}
else if (fullscreen) // We attempted true fullscreen, but failed. Attempt using windowed fullscreen.
@ -455,7 +455,7 @@ static void gfx_ctx_destroy(void)
g_screen = x11_get_xinerama_monitor(g_dpy, x, y,
target.width, target.height);
RARCH_LOG("[GLX]: Saved monitor #%u.\n", g_screen);
RARCH_LOG("[X/EGL]: Saved monitor #%u.\n", g_screen);
#endif
XUnmapWindow(g_dpy, g_win);

View File

@ -1569,6 +1569,45 @@ static void gl_init_pbo_readback(void *data)
#endif
}
static const gfx_ctx_driver_t *gl_get_context(void)
{
#ifdef HAVE_OPENGLES
enum gfx_ctx_api api = GFX_CTX_OPENGL_ES_API;
const char *api_name = "OpenGL ES";
#else
enum gfx_ctx_api api = GFX_CTX_OPENGL_API;
const char *api_name = "OpenGL";
#endif
if (*g_settings.video.gl_context)
{
const gfx_ctx_driver_t *ctx = gfx_ctx_find_driver(g_settings.video.gl_context);
if (ctx)
{
if (!ctx->bind_api(api))
{
RARCH_ERR("Failed to bind API %s to context %s.\n", api_name, g_settings.video.gl_context);
return NULL;
}
if (!ctx->init())
{
RARCH_ERR("Failed to init GL context: %s.\n", ctx->ident);
return NULL;
}
}
else
{
RARCH_ERR("Didn't find GL context: %s.\n", g_settings.video.gl_context);
return NULL;
}
return ctx;
}
else
return gfx_ctx_init_first(api);
}
static void *gl_init(const video_info_t *video, const input_driver_t **input, void **input_data)
{
#ifdef _WIN32
@ -1589,11 +1628,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
if (!gl)
return NULL;
#ifdef HAVE_OPENGLES
gl->ctx_driver = gfx_ctx_init_first(GFX_CTX_OPENGL_ES_API);
#else
gl->ctx_driver = gfx_ctx_init_first(GFX_CTX_OPENGL_API);
#endif
gl->ctx_driver = gl_get_context();
if (!gl->ctx_driver)
{
free(gl);

View File

@ -40,6 +40,11 @@
# Video driver to use. "gl", "xvideo", "sdl"
# video_driver = "gl"
# Which OpenGL context implementation to use.
# Possible ones for desktop are: glx, x-egl, kms-egl, sdl-gl, wgl.
# By default, tries to use first suitable driver.
# video_gl_context =
# Windowed xscale and yscale
# (Real x res: base_size * xscale * aspect_ratio, real y res: base_size * yscale)
# video_xscale = 3.0

View File

@ -648,6 +648,7 @@ bool config_load_file(const char *path)
CONFIG_GET_STRING(audio.resampler, "audio_resampler");
CONFIG_GET_STRING(video.driver, "video_driver");
CONFIG_GET_STRING(video.gl_context, "video_gl_context");
CONFIG_GET_STRING(audio.driver, "audio_driver");
CONFIG_GET_PATH(audio.dsp_plugin, "audio_dsp_plugin");
CONFIG_GET_STRING(input.driver, "input_driver");