2012-09-24 23:26:22 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2016-01-10 03:41:52 +00:00
|
|
|
* Copyright (C) 2011-2016 - Daniel De Matteis
|
2012-09-24 23:26:22 +00:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2012-09-28 21:34:19 +00:00
|
|
|
#include <string.h>
|
2012-09-24 23:26:22 +00:00
|
|
|
|
2016-01-20 16:34:19 +00:00
|
|
|
#include <string/stdstring.h>
|
|
|
|
|
2015-11-23 11:03:38 +00:00
|
|
|
#include "video_context_driver.h"
|
|
|
|
|
2012-09-24 23:26:22 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../config.h"
|
|
|
|
#endif
|
|
|
|
|
2015-11-23 11:03:38 +00:00
|
|
|
#include "../general.h"
|
|
|
|
#include "../verbosity.h"
|
|
|
|
|
2012-09-24 23:26:22 +00:00
|
|
|
static const gfx_ctx_driver_t *gfx_ctx_drivers[] = {
|
|
|
|
#if defined(__CELLOS_LV2__)
|
|
|
|
&gfx_ctx_ps3,
|
|
|
|
#endif
|
2015-04-03 18:36:19 +00:00
|
|
|
#if defined(HAVE_D3D)
|
2014-09-14 04:45:47 +00:00
|
|
|
&gfx_ctx_d3d,
|
2014-01-18 17:43:07 +00:00
|
|
|
#endif
|
2012-09-24 23:26:22 +00:00
|
|
|
#if defined(HAVE_VIDEOCORE)
|
|
|
|
&gfx_ctx_videocore,
|
|
|
|
#endif
|
2014-06-05 10:28:17 +00:00
|
|
|
#if defined(HAVE_MALI_FBDEV)
|
|
|
|
&gfx_ctx_mali_fbdev,
|
|
|
|
#endif
|
2014-07-27 20:19:11 +00:00
|
|
|
#if defined(HAVE_VIVANTE_FBDEV)
|
|
|
|
&gfx_ctx_vivante_fbdev,
|
|
|
|
#endif
|
2016-03-01 20:50:23 +00:00
|
|
|
#if defined(HAVE_OPENDINGUX_FBDEV)
|
|
|
|
&gfx_ctx_opendingux_fbdev,
|
|
|
|
#endif
|
2016-05-16 06:36:22 +00:00
|
|
|
#if defined(_WIN32) && (defined(HAVE_OPENGL) || defined(HAVE_VULKAN))
|
2012-09-30 09:26:26 +00:00
|
|
|
&gfx_ctx_wgl,
|
|
|
|
#endif
|
2016-02-20 08:23:17 +00:00
|
|
|
#if defined(HAVE_WAYLAND)
|
|
|
|
&gfx_ctx_wayland,
|
|
|
|
#endif
|
2016-02-20 04:50:37 +00:00
|
|
|
#if defined(HAVE_X11) && !defined(HAVE_OPENGLES)
|
|
|
|
#if defined(HAVE_OPENGL) || defined(HAVE_VULKAN)
|
2016-02-20 04:48:45 +00:00
|
|
|
&gfx_ctx_x,
|
2012-09-24 23:26:22 +00:00
|
|
|
#endif
|
2016-02-20 04:50:37 +00:00
|
|
|
#endif
|
2012-09-29 09:59:08 +00:00
|
|
|
#if defined(HAVE_X11) && defined(HAVE_OPENGL) && defined(HAVE_EGL)
|
2012-09-24 23:26:22 +00:00
|
|
|
&gfx_ctx_x_egl,
|
|
|
|
#endif
|
|
|
|
#if defined(HAVE_KMS)
|
2016-02-22 11:59:13 +00:00
|
|
|
&gfx_ctx_drm,
|
2012-09-24 23:26:22 +00:00
|
|
|
#endif
|
2012-10-08 22:11:11 +00:00
|
|
|
#if defined(ANDROID)
|
|
|
|
&gfx_ctx_android,
|
|
|
|
#endif
|
2014-05-20 00:48:11 +00:00
|
|
|
#if defined(__QNX__)
|
2013-02-26 00:19:03 +00:00
|
|
|
&gfx_ctx_bbqnx,
|
|
|
|
#endif
|
2015-04-19 15:27:51 +00:00
|
|
|
#if defined(HAVE_COCOA) || defined(HAVE_COCOATOUCH)
|
2015-04-19 15:40:10 +00:00
|
|
|
&gfx_ctx_cocoagl,
|
2013-02-06 14:54:15 +00:00
|
|
|
#endif
|
2015-04-26 01:59:55 +00:00
|
|
|
#if defined(__APPLE__) && !defined(TARGET_IPHONE_SIMULATOR) && !defined(TARGET_OS_IPHONE)
|
2015-04-26 01:48:35 +00:00
|
|
|
&gfx_ctx_cgl,
|
|
|
|
#endif
|
2014-08-21 10:54:20 +00:00
|
|
|
#if (defined(HAVE_SDL) || defined(HAVE_SDL2)) && defined(HAVE_OPENGL)
|
2014-08-21 01:09:30 +00:00
|
|
|
&gfx_ctx_sdl_gl,
|
|
|
|
#endif
|
2016-07-30 14:37:22 +00:00
|
|
|
#ifdef HAVE_OSMESA
|
|
|
|
&gfx_ctx_osmesa,
|
|
|
|
#endif
|
2013-07-18 00:26:01 +00:00
|
|
|
#ifdef EMSCRIPTEN
|
|
|
|
&gfx_ctx_emscripten,
|
2016-07-07 16:50:41 +00:00
|
|
|
#endif
|
2016-07-07 20:03:30 +00:00
|
|
|
#if defined(HAVE_VULKAN) && defined(HAVE_VULKAN_KHR_DISPLAY)
|
2016-07-07 16:50:41 +00:00
|
|
|
&gfx_ctx_khr_display,
|
2013-07-18 00:26:01 +00:00
|
|
|
#endif
|
2014-10-07 12:31:10 +00:00
|
|
|
&gfx_ctx_null,
|
2014-03-09 15:50:18 +00:00
|
|
|
NULL
|
2012-09-24 23:26:22 +00:00
|
|
|
};
|
|
|
|
|
2016-05-08 17:18:17 +00:00
|
|
|
static const gfx_ctx_driver_t *current_video_context = NULL;
|
|
|
|
static void *video_context_data = NULL;
|
2015-04-09 19:58:58 +00:00
|
|
|
|
2015-01-09 22:32:32 +00:00
|
|
|
/**
|
2016-05-08 18:32:46 +00:00
|
|
|
* find_video_context_driver_driver_index:
|
2015-01-09 22:32:32 +00:00
|
|
|
* @ident : Identifier of resampler driver to find.
|
|
|
|
*
|
|
|
|
* Finds graphics context driver index by @ident name.
|
|
|
|
*
|
|
|
|
* Returns: graphics context driver index if driver was found, otherwise
|
|
|
|
* -1.
|
|
|
|
**/
|
2016-05-08 18:32:46 +00:00
|
|
|
static int find_video_context_driver_index(const char *ident)
|
2012-09-24 23:26:22 +00:00
|
|
|
{
|
2013-10-22 13:08:17 +00:00
|
|
|
unsigned i;
|
2014-10-23 21:55:30 +00:00
|
|
|
for (i = 0; gfx_ctx_drivers[i]; i++)
|
2016-01-20 16:34:19 +00:00
|
|
|
if (string_is_equal_noncase(ident, gfx_ctx_drivers[i]->ident))
|
2014-10-23 21:55:30 +00:00
|
|
|
return i;
|
|
|
|
return -1;
|
|
|
|
}
|
2012-09-24 23:26:22 +00:00
|
|
|
|
2015-01-09 22:32:32 +00:00
|
|
|
/**
|
|
|
|
* find_prev_context_driver:
|
|
|
|
*
|
|
|
|
* Finds previous driver in graphics context driver array.
|
|
|
|
**/
|
2016-05-08 18:32:46 +00:00
|
|
|
bool video_context_driver_find_prev_driver(void)
|
2014-10-23 21:55:30 +00:00
|
|
|
{
|
2015-03-20 19:43:22 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2016-05-08 18:32:46 +00:00
|
|
|
int i = find_video_context_driver_index(
|
2016-02-13 22:20:04 +00:00
|
|
|
settings->video.context_driver);
|
2015-01-09 22:32:32 +00:00
|
|
|
|
2014-10-23 21:55:30 +00:00
|
|
|
if (i > 0)
|
2014-12-14 13:31:13 +00:00
|
|
|
{
|
2016-02-13 22:20:04 +00:00
|
|
|
strlcpy(settings->video.context_driver,
|
|
|
|
gfx_ctx_drivers[i - 1]->ident,
|
2015-03-20 19:43:22 +00:00
|
|
|
sizeof(settings->video.context_driver));
|
2016-02-13 18:12:08 +00:00
|
|
|
return true;
|
2014-12-14 13:31:13 +00:00
|
|
|
}
|
2016-02-13 18:12:08 +00:00
|
|
|
|
|
|
|
RARCH_WARN("Couldn't find any previous video context driver.\n");
|
|
|
|
return false;
|
2014-10-23 21:55:30 +00:00
|
|
|
}
|
|
|
|
|
2015-01-09 22:32:32 +00:00
|
|
|
/**
|
|
|
|
* find_next_context_driver:
|
|
|
|
*
|
|
|
|
* Finds next driver in graphics context driver array.
|
|
|
|
**/
|
2016-05-08 18:32:46 +00:00
|
|
|
bool video_context_driver_find_next_driver(void)
|
2014-10-23 21:55:30 +00:00
|
|
|
{
|
2015-03-20 19:43:22 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
2016-05-08 18:32:46 +00:00
|
|
|
int i = find_video_context_driver_index(settings->video.context_driver);
|
2015-01-09 22:32:32 +00:00
|
|
|
|
2014-10-23 21:55:30 +00:00
|
|
|
if (i >= 0 && gfx_ctx_drivers[i + 1])
|
2014-12-14 13:31:13 +00:00
|
|
|
{
|
2016-02-13 22:20:04 +00:00
|
|
|
strlcpy(settings->video.context_driver,
|
|
|
|
gfx_ctx_drivers[i + 1]->ident,
|
2015-03-20 19:43:22 +00:00
|
|
|
sizeof(settings->video.context_driver));
|
2016-02-13 18:12:08 +00:00
|
|
|
return true;
|
2014-12-14 13:31:13 +00:00
|
|
|
}
|
2016-02-13 18:12:08 +00:00
|
|
|
|
|
|
|
RARCH_WARN("Couldn't find any next video context driver.\n");
|
|
|
|
return false;
|
2012-09-24 23:26:22 +00:00
|
|
|
}
|
|
|
|
|
2015-01-09 22:32:32 +00:00
|
|
|
/**
|
2016-05-08 18:32:46 +00:00
|
|
|
* video_context_driver_init:
|
2015-01-09 22:32:32 +00:00
|
|
|
* @data : Input data.
|
|
|
|
* @ctx : Graphics context driver to initialize.
|
|
|
|
* @ident : Identifier of graphics context driver to find.
|
|
|
|
* @api : API of higher-level graphics API.
|
|
|
|
* @major : Major version number of higher-level graphics API.
|
|
|
|
* @minor : Minor version number of higher-level graphics API.
|
|
|
|
* @hw_render_ctx : Request a graphics context driver capable of
|
|
|
|
* hardware rendering?
|
|
|
|
*
|
|
|
|
* Initialize graphics context driver.
|
|
|
|
*
|
|
|
|
* Returns: graphics context driver if successfully initialized, otherwise NULL.
|
|
|
|
**/
|
2016-05-08 18:32:46 +00:00
|
|
|
static const gfx_ctx_driver_t *video_context_driver_init(
|
2016-05-08 17:24:23 +00:00
|
|
|
void *data,
|
2014-10-23 21:09:37 +00:00
|
|
|
const gfx_ctx_driver_t *ctx,
|
2015-01-09 22:32:32 +00:00
|
|
|
const char *ident,
|
2014-10-23 21:09:37 +00:00
|
|
|
enum gfx_ctx_api api, unsigned major,
|
|
|
|
unsigned minor, bool hw_render_ctx)
|
|
|
|
{
|
2015-03-20 19:43:22 +00:00
|
|
|
settings_t *settings = config_get_ptr();
|
|
|
|
|
2014-10-23 21:09:37 +00:00
|
|
|
if (ctx->bind_api(data, api, major, minor))
|
|
|
|
{
|
2015-12-08 15:18:57 +00:00
|
|
|
void *ctx_data = ctx->init(data);
|
2014-10-24 01:12:08 +00:00
|
|
|
|
2015-12-08 15:18:57 +00:00
|
|
|
if (!ctx_data)
|
2014-10-24 01:12:08 +00:00
|
|
|
return NULL;
|
|
|
|
|
2014-10-23 21:09:37 +00:00
|
|
|
if (ctx->bind_hw_render)
|
2015-12-08 15:18:57 +00:00
|
|
|
ctx->bind_hw_render(ctx_data,
|
2015-03-20 19:43:22 +00:00
|
|
|
settings->video.shared_context && hw_render_ctx);
|
2014-10-23 21:09:37 +00:00
|
|
|
|
2016-05-08 18:32:46 +00:00
|
|
|
video_context_driver_set_data(ctx_data);
|
2014-10-24 01:12:08 +00:00
|
|
|
return ctx;
|
2014-10-23 21:09:37 +00:00
|
|
|
}
|
2015-01-09 22:32:32 +00:00
|
|
|
|
2015-01-31 05:01:27 +00:00
|
|
|
#ifndef _WIN32
|
2015-01-31 05:00:31 +00:00
|
|
|
RARCH_WARN("Failed to bind API (#%u, version %u.%u) on context driver \"%s\".\n",
|
2015-01-09 22:32:32 +00:00
|
|
|
(unsigned)api, major, minor, ctx->ident);
|
2015-01-31 05:01:27 +00:00
|
|
|
#endif
|
2014-10-23 21:09:37 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-01-09 22:32:32 +00:00
|
|
|
/**
|
2016-05-08 18:32:46 +00:00
|
|
|
* video_context_driver_find_driver:
|
2015-01-09 22:32:32 +00:00
|
|
|
* @data : Input data.
|
|
|
|
* @ident : Identifier of graphics context driver to find.
|
|
|
|
* @api : API of higher-level graphics API.
|
|
|
|
* @major : Major version number of higher-level graphics API.
|
|
|
|
* @minor : Minor version number of higher-level graphics API.
|
|
|
|
* @hw_render_ctx : Request a graphics context driver capable of
|
|
|
|
* hardware rendering?
|
|
|
|
*
|
2015-01-11 19:20:34 +00:00
|
|
|
* Finds graphics context driver and initializes.
|
2015-01-09 22:32:32 +00:00
|
|
|
*
|
|
|
|
* Returns: graphics context driver if found, otherwise NULL.
|
|
|
|
**/
|
2016-05-08 18:32:46 +00:00
|
|
|
static const gfx_ctx_driver_t *video_context_driver_find_driver(void *data,
|
2014-10-23 21:55:30 +00:00
|
|
|
const char *ident,
|
2014-09-08 15:57:18 +00:00
|
|
|
enum gfx_ctx_api api, unsigned major,
|
|
|
|
unsigned minor, bool hw_render_ctx)
|
2012-09-24 23:26:22 +00:00
|
|
|
{
|
2016-05-08 18:32:46 +00:00
|
|
|
int i = find_video_context_driver_index(ident);
|
2014-12-14 13:31:13 +00:00
|
|
|
|
2014-10-23 21:55:30 +00:00
|
|
|
if (i >= 0)
|
2016-05-08 18:32:46 +00:00
|
|
|
return video_context_driver_init(data, gfx_ctx_drivers[i], ident,
|
2014-10-23 21:55:30 +00:00
|
|
|
api, major, minor, hw_render_ctx);
|
2015-01-09 22:32:32 +00:00
|
|
|
|
|
|
|
for (i = 0; gfx_ctx_drivers[i]; i++)
|
2012-09-24 23:26:22 +00:00
|
|
|
{
|
2015-09-29 15:35:28 +00:00
|
|
|
const gfx_ctx_driver_t *ctx =
|
2016-05-08 18:32:46 +00:00
|
|
|
video_context_driver_init(data, gfx_ctx_drivers[i], ident,
|
2015-01-09 22:32:32 +00:00
|
|
|
api, major, minor, hw_render_ctx);
|
2015-09-29 15:35:28 +00:00
|
|
|
|
2015-01-09 22:32:32 +00:00
|
|
|
if (ctx)
|
|
|
|
return ctx;
|
2014-12-14 13:31:13 +00:00
|
|
|
}
|
2015-01-09 22:32:32 +00:00
|
|
|
|
|
|
|
return NULL;
|
2012-09-24 23:26:22 +00:00
|
|
|
}
|
2014-10-23 21:55:30 +00:00
|
|
|
|
2015-01-09 22:32:32 +00:00
|
|
|
/**
|
2016-05-08 18:32:46 +00:00
|
|
|
* video_context_driver_init_first:
|
2015-01-09 22:32:32 +00:00
|
|
|
* @data : Input data.
|
|
|
|
* @ident : Identifier of graphics context driver to find.
|
|
|
|
* @api : API of higher-level graphics API.
|
|
|
|
* @major : Major version number of higher-level graphics API.
|
|
|
|
* @minor : Minor version number of higher-level graphics API.
|
|
|
|
* @hw_render_ctx : Request a graphics context driver capable of
|
|
|
|
* hardware rendering?
|
|
|
|
*
|
|
|
|
* Finds first suitable graphics context driver and initializes.
|
|
|
|
*
|
|
|
|
* Returns: graphics context driver if found, otherwise NULL.
|
|
|
|
**/
|
2016-05-08 18:32:46 +00:00
|
|
|
const gfx_ctx_driver_t *video_context_driver_init_first(void *data,
|
2015-01-09 22:32:32 +00:00
|
|
|
const char *ident, enum gfx_ctx_api api, unsigned major,
|
2014-10-23 21:55:30 +00:00
|
|
|
unsigned minor, bool hw_render_ctx)
|
|
|
|
{
|
2016-05-08 18:32:46 +00:00
|
|
|
return video_context_driver_find_driver(data, ident, api,
|
2016-02-06 20:51:37 +00:00
|
|
|
major, minor, hw_render_ctx);
|
2014-10-23 21:55:30 +00:00
|
|
|
}
|
2016-02-13 07:21:35 +00:00
|
|
|
|
2016-05-08 18:32:46 +00:00
|
|
|
bool video_context_driver_check_window(gfx_ctx_size_t *size_data)
|
2016-02-13 07:21:35 +00:00
|
|
|
{
|
2016-05-08 18:32:46 +00:00
|
|
|
uint64_t *frame_count = NULL;
|
|
|
|
frame_count = video_driver_get_frame_count_ptr();
|
|
|
|
|
|
|
|
if (!video_context_data || !size_data)
|
|
|
|
return false;
|
|
|
|
if (!current_video_context || !current_video_context->check_window)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
current_video_context->check_window(video_context_data,
|
|
|
|
size_data->quit,
|
|
|
|
size_data->resize,
|
|
|
|
size_data->width,
|
|
|
|
size_data->height, (unsigned int)*frame_count);
|
|
|
|
return true;
|
|
|
|
}
|
2016-02-14 01:30:24 +00:00
|
|
|
|
2016-05-08 18:32:46 +00:00
|
|
|
bool video_context_driver_init_image_buffer(const video_info_t *data)
|
|
|
|
{
|
|
|
|
if (!current_video_context || !current_video_context->image_buffer_init)
|
|
|
|
return false;
|
|
|
|
if (!current_video_context->image_buffer_init(video_context_data, data))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_write_to_image_buffer(gfx_ctx_image_t *img)
|
|
|
|
{
|
|
|
|
if (!current_video_context || !current_video_context->image_buffer_write)
|
|
|
|
return false;
|
|
|
|
if (!current_video_context->image_buffer_write(video_context_data,
|
|
|
|
img->frame, img->width, img->height, img->pitch,
|
|
|
|
img->rgb32, img->index, img->handle))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_get_video_output_prev(void)
|
|
|
|
{
|
|
|
|
if (!current_video_context
|
|
|
|
|| !current_video_context->get_video_output_prev)
|
|
|
|
return false;
|
|
|
|
current_video_context->get_video_output_prev(video_context_data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_get_video_output_next(void)
|
|
|
|
{
|
|
|
|
if (!current_video_context ||
|
|
|
|
!current_video_context->get_video_output_next)
|
|
|
|
return false;
|
|
|
|
current_video_context->get_video_output_next(video_context_data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_bind_hw_render(bool *enable)
|
|
|
|
{
|
|
|
|
if (!current_video_context || !current_video_context->bind_hw_render)
|
|
|
|
return false;
|
|
|
|
current_video_context->bind_hw_render(video_context_data, *enable);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_set(const gfx_ctx_driver_t *data)
|
|
|
|
{
|
|
|
|
if (!data)
|
|
|
|
return false;
|
|
|
|
current_video_context = data;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void video_context_driver_destroy(void)
|
|
|
|
{
|
|
|
|
current_video_context = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_update_window_title(void)
|
|
|
|
{
|
|
|
|
if (!current_video_context || !current_video_context->update_window_title)
|
|
|
|
return false;
|
|
|
|
current_video_context->update_window_title(video_context_data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_swap_buffers(void)
|
|
|
|
{
|
|
|
|
if (!current_video_context || !current_video_context->swap_buffers)
|
|
|
|
return false;
|
|
|
|
current_video_context->swap_buffers(video_context_data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_focus(void)
|
|
|
|
{
|
|
|
|
if (!video_context_data || !current_video_context->has_focus)
|
|
|
|
return false;
|
|
|
|
if (!current_video_context->has_focus(video_context_data))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
2016-02-13 07:21:35 +00:00
|
|
|
|
2016-05-08 18:32:46 +00:00
|
|
|
bool video_context_driver_translate_aspect(gfx_ctx_aspect_t *aspect)
|
|
|
|
{
|
|
|
|
if (!video_context_data || !aspect)
|
|
|
|
return false;
|
|
|
|
if (!current_video_context->translate_aspect)
|
|
|
|
return false;
|
|
|
|
*aspect->aspect = current_video_context->translate_aspect(
|
|
|
|
video_context_data, aspect->width, aspect->height);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_has_windowed(void)
|
|
|
|
{
|
|
|
|
if (!video_context_data)
|
|
|
|
return false;
|
|
|
|
if (!current_video_context->has_windowed(video_context_data))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void video_context_driver_free(void)
|
|
|
|
{
|
|
|
|
if (current_video_context->destroy)
|
|
|
|
current_video_context->destroy(video_context_data);
|
|
|
|
current_video_context = NULL;
|
|
|
|
video_context_data = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_get_video_output_size(gfx_ctx_size_t *size_data)
|
|
|
|
{
|
|
|
|
if (!size_data)
|
|
|
|
return false;
|
|
|
|
if (!current_video_context || !current_video_context->get_video_output_size)
|
|
|
|
return false;
|
|
|
|
current_video_context->get_video_output_size(video_context_data,
|
|
|
|
size_data->width, size_data->height);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_swap_interval(unsigned *interval)
|
|
|
|
{
|
|
|
|
if (!current_video_context || !current_video_context->swap_interval)
|
|
|
|
return false;
|
|
|
|
current_video_context->swap_interval(video_context_data, *interval);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_get_proc_address(gfx_ctx_proc_address_t *proc)
|
|
|
|
{
|
|
|
|
if (!current_video_context || !current_video_context->get_proc_address)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
proc->addr = current_video_context->get_proc_address(proc->sym);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_get_metrics(gfx_ctx_metrics_t *metrics)
|
|
|
|
{
|
|
|
|
if (!current_video_context || !current_video_context->get_metrics)
|
|
|
|
return false;
|
|
|
|
if (!current_video_context->get_metrics(video_context_data,
|
|
|
|
metrics->type,
|
|
|
|
metrics->value))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_input_driver(gfx_ctx_input_t *inp)
|
|
|
|
{
|
|
|
|
if (!current_video_context || !current_video_context->input_driver)
|
|
|
|
return false;
|
|
|
|
current_video_context->input_driver(
|
|
|
|
video_context_data, inp->input, inp->input_data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_suppress_screensaver(bool *bool_data)
|
|
|
|
{
|
|
|
|
if (!video_context_data || !current_video_context)
|
|
|
|
return false;
|
|
|
|
if (!current_video_context->suppress_screensaver(
|
|
|
|
video_context_data, *bool_data))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_get_ident(gfx_ctx_ident_t *ident)
|
|
|
|
{
|
|
|
|
if (!ident)
|
|
|
|
return false;
|
|
|
|
ident->ident = NULL;
|
|
|
|
if (current_video_context)
|
|
|
|
ident->ident = current_video_context->ident;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_set_video_mode(gfx_ctx_mode_t *mode_info)
|
|
|
|
{
|
|
|
|
if (!current_video_context || !current_video_context->set_video_mode)
|
|
|
|
return false;
|
|
|
|
if (!current_video_context->set_video_mode(
|
|
|
|
video_context_data, mode_info->width,
|
|
|
|
mode_info->height, mode_info->fullscreen))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_set_resize(gfx_ctx_mode_t *mode_info)
|
|
|
|
{
|
|
|
|
if (!current_video_context)
|
|
|
|
return false;
|
|
|
|
if (!current_video_context->set_resize(
|
|
|
|
video_context_data, mode_info->width, mode_info->height))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_get_video_size(gfx_ctx_mode_t *mode_info)
|
|
|
|
{
|
|
|
|
if (!current_video_context || !current_video_context->get_video_size)
|
|
|
|
return false;
|
|
|
|
current_video_context->get_video_size(video_context_data,
|
|
|
|
&mode_info->width, &mode_info->height);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_get_context_data(void *data)
|
|
|
|
{
|
|
|
|
if (!current_video_context || !current_video_context->get_context_data)
|
|
|
|
return false;
|
|
|
|
*(void**)data = current_video_context->get_context_data(video_context_data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_show_mouse(bool *bool_data)
|
|
|
|
{
|
|
|
|
if (!current_video_context || !current_video_context->show_mouse)
|
|
|
|
return false;
|
|
|
|
current_video_context->show_mouse(video_context_data, *bool_data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void video_context_driver_set_data(void *data)
|
|
|
|
{
|
|
|
|
video_context_data = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_get_flags(gfx_ctx_flags_t *flags)
|
|
|
|
{
|
|
|
|
if (!flags)
|
|
|
|
return false;
|
|
|
|
if (!current_video_context || !current_video_context->get_flags)
|
|
|
|
return false;
|
|
|
|
flags->flags = current_video_context->get_flags(video_context_data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool video_context_driver_set_flags(gfx_ctx_flags_t *flags)
|
|
|
|
{
|
|
|
|
if (!flags)
|
|
|
|
return false;
|
|
|
|
if (!current_video_context || !current_video_context->set_flags)
|
|
|
|
return false;
|
|
|
|
current_video_context->set_flags(video_context_data, flags->flags);
|
2016-02-13 07:21:35 +00:00
|
|
|
return true;
|
|
|
|
}
|