2012-05-26 04:47:24 +02:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 01:50:59 +01:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2016-01-10 04:41:52 +01:00
|
|
|
* Copyright (C) 2011-2016 - Daniel De Matteis
|
2012-05-26 04:47:24 +02: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/>.
|
|
|
|
*/
|
|
|
|
|
2015-01-12 21:53:04 +01:00
|
|
|
#ifndef __VIDEO_CONTEXT_DRIVER_H
|
|
|
|
#define __VIDEO_CONTEXT_DRIVER_H
|
2012-05-26 04:47:24 +02:00
|
|
|
|
2014-10-21 05:05:52 +02:00
|
|
|
#include <boolean.h>
|
2015-11-29 01:15:40 +01:00
|
|
|
|
2015-12-05 07:45:36 +01:00
|
|
|
#include "video_driver.h"
|
2012-05-26 04:47:24 +02:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../config.h"
|
|
|
|
#endif
|
|
|
|
|
2014-01-22 16:38:42 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-01-12 04:19:57 +01:00
|
|
|
#ifndef MAX_EGLIMAGE_TEXTURES
|
2012-10-19 23:08:53 -04:00
|
|
|
#define MAX_EGLIMAGE_TEXTURES 32
|
2015-01-12 04:19:57 +01:00
|
|
|
#endif
|
2012-10-19 23:08:53 -04:00
|
|
|
|
2012-09-25 01:26:22 +02:00
|
|
|
enum gfx_ctx_api
|
|
|
|
{
|
2015-11-20 13:27:31 +01:00
|
|
|
GFX_CTX_NONE = 0,
|
2012-09-25 01:26:22 +02:00
|
|
|
GFX_CTX_OPENGL_API,
|
|
|
|
GFX_CTX_OPENGL_ES_API,
|
2012-09-30 17:10:04 +02:00
|
|
|
GFX_CTX_DIRECT3D8_API,
|
|
|
|
GFX_CTX_DIRECT3D9_API,
|
2016-02-16 20:24:00 +01:00
|
|
|
GFX_CTX_OPENVG_API,
|
|
|
|
GFX_CTX_VULKAN_API
|
2012-09-25 01:26:22 +02:00
|
|
|
};
|
2015-04-08 09:02:47 +02:00
|
|
|
|
|
|
|
enum display_metric_types
|
|
|
|
{
|
|
|
|
DISPLAY_METRIC_NONE = 0,
|
|
|
|
DISPLAY_METRIC_MM_WIDTH,
|
|
|
|
DISPLAY_METRIC_MM_HEIGHT,
|
2015-06-26 17:46:13 +02:00
|
|
|
DISPLAY_METRIC_DPI
|
2015-04-08 09:02:47 +02:00
|
|
|
};
|
2012-09-25 01:26:22 +02:00
|
|
|
|
2016-05-05 05:35:35 +02:00
|
|
|
enum display_flags
|
|
|
|
{
|
|
|
|
GFX_CTX_FLAGS_NONE = 0,
|
2016-05-05 05:46:00 +02:00
|
|
|
GFX_CTX_FLAGS_GL_CORE_CONTEXT
|
2016-05-05 05:35:35 +02:00
|
|
|
};
|
|
|
|
|
2012-09-25 01:26:22 +02:00
|
|
|
typedef void (*gfx_ctx_proc_t)(void);
|
|
|
|
|
|
|
|
typedef struct gfx_ctx_driver
|
|
|
|
{
|
2015-12-08 12:18:57 -03:00
|
|
|
/* The opaque pointer is the underlying video driver data (e.g. gl_t for
|
|
|
|
* OpenGL contexts). Although not advised, the context driver is allowed
|
|
|
|
* to hold a pointer to it as the context never outlives the video driver.
|
|
|
|
*
|
|
|
|
* The context driver is responsible for it's own data.*/
|
|
|
|
void* (*init)(void *video_driver);
|
2014-03-09 16:50:18 +01:00
|
|
|
void (*destroy)(void *data);
|
2012-09-25 01:26:22 +02:00
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Which API to bind to. */
|
2015-12-08 13:54:03 -03:00
|
|
|
bool (*bind_api)(void *video_driver, enum gfx_ctx_api,
|
2014-09-08 17:57:18 +02:00
|
|
|
unsigned major, unsigned minor);
|
2012-09-25 01:26:22 +02:00
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Sets the swap interval. */
|
2014-03-09 16:50:18 +01:00
|
|
|
void (*swap_interval)(void *data, unsigned);
|
2012-09-25 01:26:22 +02:00
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Sets video mode. Creates a window, etc. */
|
2014-03-09 16:50:18 +01:00
|
|
|
bool (*set_video_mode)(void*, unsigned, unsigned, bool);
|
2012-09-25 01:26:22 +02:00
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Gets current window size.
|
|
|
|
* If not initialized yet, it returns current screen size. */
|
2014-03-09 16:50:18 +01:00
|
|
|
void (*get_video_size)(void*, unsigned*, unsigned*);
|
2012-09-25 01:26:22 +02:00
|
|
|
|
2015-02-24 19:58:14 +01:00
|
|
|
void (*get_video_output_size)(void*, unsigned*, unsigned*);
|
|
|
|
|
2015-02-24 21:36:23 +01:00
|
|
|
void (*get_video_output_prev)(void*);
|
|
|
|
|
|
|
|
void (*get_video_output_next)(void*);
|
|
|
|
|
2015-04-08 20:10:30 +02:00
|
|
|
bool (*get_metrics)(void *data, enum display_metric_types type,
|
|
|
|
float *value);
|
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Translates a window size to an aspect ratio.
|
|
|
|
* In most cases this will be just width / height, but
|
|
|
|
* some contexts will better know which actual aspect ratio is used.
|
|
|
|
* This can be NULL to assume the default behavior.
|
|
|
|
*/
|
2014-03-09 16:50:18 +01:00
|
|
|
float (*translate_aspect)(void*, unsigned, unsigned);
|
2012-09-25 13:51:44 +02:00
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Asks driver to update window title (FPS, etc). */
|
2014-03-09 16:50:18 +01:00
|
|
|
void (*update_window_title)(void*);
|
2012-09-25 01:26:22 +02:00
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Queries for resize and quit events.
|
|
|
|
* Also processes events. */
|
|
|
|
void (*check_window)(void*, bool*, bool*,
|
|
|
|
unsigned*, unsigned*, unsigned);
|
2012-09-25 01:26:22 +02:00
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Acknowledge a resize event. This is needed for some APIs.
|
|
|
|
* Most backends will ignore this. */
|
2016-01-07 00:58:33 +01:00
|
|
|
bool (*set_resize)(void*, unsigned, unsigned);
|
2012-09-25 01:26:22 +02:00
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Checks if window has input focus. */
|
2014-03-09 16:50:18 +01:00
|
|
|
bool (*has_focus)(void*);
|
2012-09-25 01:26:22 +02:00
|
|
|
|
2015-01-18 22:32:14 +01:00
|
|
|
/* Should the screensaver be suppressed? */
|
2015-04-10 08:05:31 +02:00
|
|
|
bool (*suppress_screensaver)(void *data, bool enable);
|
|
|
|
|
|
|
|
/* Checks if context driver has windowed support. */
|
2014-10-08 17:23:02 +02:00
|
|
|
bool (*has_windowed)(void*);
|
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Swaps buffers. VBlank sync depends on
|
|
|
|
* earlier calls to swap_interval. */
|
2014-03-09 16:50:18 +01:00
|
|
|
void (*swap_buffers)(void*);
|
2012-09-25 01:26:22 +02:00
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Most video backends will want to use a certain input driver.
|
|
|
|
* Checks for it here. */
|
2014-03-09 16:50:18 +01:00
|
|
|
void (*input_driver)(void*, const input_driver_t**, void**);
|
2012-09-25 01:26:22 +02:00
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Wraps whatever gl_proc_address() there is.
|
|
|
|
* Does not take opaque, to avoid lots of ugly wrapper code. */
|
2012-09-25 01:26:22 +02:00
|
|
|
gfx_ctx_proc_t (*get_proc_address)(const char*);
|
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Returns true if this context supports EGLImage buffers for
|
|
|
|
* screen drawing and was initalized correctly. */
|
2015-04-10 09:02:24 +02:00
|
|
|
bool (*image_buffer_init)(void*, const video_info_t*);
|
2014-09-08 17:57:18 +02:00
|
|
|
|
|
|
|
/* Writes the frame to the EGLImage and sets image_handle to it.
|
|
|
|
* Returns true if a new image handle is created.
|
|
|
|
* Always returns true the first time it's called for a new index.
|
|
|
|
* The graphics core must handle a change in the handle correctly. */
|
2015-04-10 09:02:24 +02:00
|
|
|
bool (*image_buffer_write)(void*, const void *frame, unsigned width,
|
2014-09-08 17:57:18 +02:00
|
|
|
unsigned height, unsigned pitch, bool rgb32,
|
|
|
|
unsigned index, void **image_handle);
|
2012-10-18 18:59:56 -04:00
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Shows or hides mouse. Can be NULL if context doesn't
|
|
|
|
* have a concept of mouse pointer. */
|
2015-01-18 22:32:14 +01:00
|
|
|
void (*show_mouse)(void *data, bool state);
|
2013-03-29 13:46:11 +01:00
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Human readable string. */
|
2012-09-25 01:26:22 +02:00
|
|
|
const char *ident;
|
2014-04-19 15:37:00 +02:00
|
|
|
|
2016-05-05 05:35:35 +02:00
|
|
|
uint32_t (*get_flags)(void *data);
|
|
|
|
|
2016-05-05 17:35:28 +02:00
|
|
|
void (*set_flags)(void *data, uint32_t flags);
|
|
|
|
|
2014-09-08 17:57:18 +02:00
|
|
|
/* Optional. Binds HW-render offscreen context. */
|
2014-04-19 15:37:00 +02:00
|
|
|
void (*bind_hw_render)(void *data, bool enable);
|
2016-02-16 20:24:00 +01:00
|
|
|
|
|
|
|
/* Optional. Gets base data for the context which is used by the driver.
|
|
|
|
* This is mostly relevant for graphics APIs such as Vulkan
|
|
|
|
* which do not have global context state. */
|
|
|
|
void *(*get_context_data)(void *data);
|
2012-09-25 01:26:22 +02:00
|
|
|
} gfx_ctx_driver_t;
|
|
|
|
|
2016-05-05 05:49:48 +02:00
|
|
|
typedef struct gfx_ctx_flags
|
|
|
|
{
|
|
|
|
uint32_t flags;
|
|
|
|
} gfx_ctx_flags_t;
|
|
|
|
|
2016-02-13 19:36:02 +01:00
|
|
|
typedef struct gfx_ctx_size
|
|
|
|
{
|
2016-02-13 19:53:14 +01:00
|
|
|
bool *quit;
|
|
|
|
bool *resize;
|
2016-02-13 19:36:02 +01:00
|
|
|
unsigned *width;
|
|
|
|
unsigned *height;
|
|
|
|
} gfx_ctx_size_t;
|
|
|
|
|
2016-02-14 02:12:18 +01:00
|
|
|
typedef struct gfx_ctx_mode
|
|
|
|
{
|
|
|
|
unsigned width;
|
|
|
|
unsigned height;
|
|
|
|
bool fullscreen;
|
|
|
|
} gfx_ctx_mode_t;
|
|
|
|
|
2016-02-13 21:58:35 +01:00
|
|
|
typedef struct gfx_ctx_metrics
|
|
|
|
{
|
|
|
|
enum display_metric_types type;
|
|
|
|
float *value;
|
|
|
|
} gfx_ctx_metrics_t;
|
|
|
|
|
|
|
|
typedef struct gfx_ctx_aspect
|
|
|
|
{
|
|
|
|
float *aspect;
|
2016-02-13 22:07:56 +01:00
|
|
|
unsigned width;
|
|
|
|
unsigned height;
|
2016-02-13 21:58:35 +01:00
|
|
|
} gfx_ctx_aspect_t;
|
|
|
|
|
|
|
|
typedef struct gfx_ctx_image
|
|
|
|
{
|
|
|
|
const void *frame;
|
|
|
|
unsigned width;
|
|
|
|
unsigned height;
|
|
|
|
unsigned pitch;
|
|
|
|
unsigned index;
|
|
|
|
bool rgb32;
|
|
|
|
void **handle;
|
|
|
|
} gfx_ctx_image_t;
|
|
|
|
|
|
|
|
typedef struct gfx_ctx_input
|
|
|
|
{
|
|
|
|
const input_driver_t **input;
|
|
|
|
void **input_data;
|
|
|
|
} gfx_ctx_input_t;
|
|
|
|
|
|
|
|
typedef struct gfx_ctx_proc_address
|
|
|
|
{
|
|
|
|
const char *sym;
|
|
|
|
retro_proc_address_t addr;
|
|
|
|
} gfx_ctx_proc_address_t;
|
|
|
|
|
2016-02-14 02:05:20 +01:00
|
|
|
typedef struct gfx_ctx_ident
|
|
|
|
{
|
|
|
|
const char *ident;
|
|
|
|
} gfx_ctx_ident_t;
|
|
|
|
|
2012-09-25 01:26:22 +02:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_sdl_gl;
|
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_x_egl;
|
2014-08-09 21:35:27 +02:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_wayland;
|
2016-02-20 05:48:45 +01:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_x;
|
2014-09-14 06:45:47 +02:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_d3d;
|
2016-02-22 12:59:13 +01:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_drm;
|
2014-06-05 12:28:17 +02:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_mali_fbdev;
|
2014-07-27 22:19:11 +02:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_vivante_fbdev;
|
2012-10-09 00:11:11 +02:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_android;
|
2012-09-25 01:26:22 +02:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_ps3;
|
2012-09-30 11:26:26 +02:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_wgl;
|
2012-09-25 01:26:22 +02:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_videocore;
|
2013-02-26 01:19:03 +01:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_bbqnx;
|
2015-04-26 03:31:02 +02:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_cgl;
|
2015-04-19 17:40:10 +02:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_cocoagl;
|
2013-07-17 20:26:01 -04:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_emscripten;
|
2016-03-01 21:50:23 +01:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev;
|
2013-07-04 15:01:38 +02:00
|
|
|
extern const gfx_ctx_driver_t gfx_ctx_null;
|
2012-09-25 01:26:22 +02:00
|
|
|
|
2015-01-09 23:32:32 +01:00
|
|
|
/**
|
2016-05-08 20:32:46 +02:00
|
|
|
* video_context_driver_init_first:
|
2015-01-09 23:32:32 +01: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 20:32:46 +02:00
|
|
|
const gfx_ctx_driver_t *video_context_driver_init_first(void *data, const char *ident,
|
2014-10-23 23:09:37 +02:00
|
|
|
enum gfx_ctx_api api, unsigned major, unsigned minor, bool hw_render_ctx);
|
2012-09-25 01:26:22 +02:00
|
|
|
|
2016-05-08 20:32:46 +02:00
|
|
|
bool video_context_driver_check_window(gfx_ctx_size_t *size_data);
|
|
|
|
|
|
|
|
bool video_context_driver_find_prev_driver(void);
|
|
|
|
|
|
|
|
bool video_context_driver_find_next_driver(void);
|
|
|
|
|
|
|
|
bool video_context_driver_init_image_buffer(const video_info_t *data);
|
|
|
|
|
|
|
|
bool video_context_driver_write_to_image_buffer(gfx_ctx_image_t *img);
|
|
|
|
|
|
|
|
bool video_context_driver_get_video_output_prev(void);
|
|
|
|
|
|
|
|
bool video_context_driver_get_video_output_next(void);
|
|
|
|
|
|
|
|
bool video_context_driver_bind_hw_render(bool *enable);
|
|
|
|
|
|
|
|
bool video_context_driver_set(const gfx_ctx_driver_t *data);
|
|
|
|
|
|
|
|
void video_context_driver_destroy(void);
|
|
|
|
|
|
|
|
bool video_context_driver_update_window_title(void);
|
|
|
|
|
|
|
|
bool video_context_driver_swap_buffers(void);
|
|
|
|
|
|
|
|
bool video_context_driver_focus(void);
|
|
|
|
|
|
|
|
bool video_context_driver_get_video_output_size(gfx_ctx_size_t *size_data);
|
|
|
|
|
|
|
|
bool video_context_driver_swap_interval(unsigned *interval);
|
|
|
|
|
|
|
|
bool video_context_driver_get_proc_address(gfx_ctx_proc_address_t *proc);
|
|
|
|
|
|
|
|
bool video_context_driver_suppress_screensaver(bool *bool_data);
|
|
|
|
|
|
|
|
bool video_context_driver_get_ident(gfx_ctx_ident_t *ident);
|
|
|
|
|
|
|
|
bool video_context_driver_set_video_mode(gfx_ctx_mode_t *mode_info);
|
|
|
|
|
|
|
|
bool video_context_driver_set_resize(gfx_ctx_mode_t *mode_info);
|
|
|
|
|
|
|
|
bool video_context_driver_get_video_size(gfx_ctx_mode_t *mode_info);
|
|
|
|
|
|
|
|
bool video_context_driver_get_context_data(void *data);
|
|
|
|
|
|
|
|
bool video_context_driver_show_mouse(bool *bool_data);
|
|
|
|
|
|
|
|
void video_context_driver_set_data(void *data);
|
|
|
|
|
|
|
|
bool video_context_driver_get_flags(gfx_ctx_flags_t *flags);
|
|
|
|
|
|
|
|
bool video_context_driver_set_flags(gfx_ctx_flags_t *flags);
|
|
|
|
|
|
|
|
bool video_context_driver_get_metrics(gfx_ctx_metrics_t *metrics);
|
|
|
|
|
|
|
|
bool video_context_driver_translate_aspect(gfx_ctx_aspect_t *aspect);
|
|
|
|
|
|
|
|
bool video_context_driver_input_driver(gfx_ctx_input_t *inp);
|
|
|
|
|
|
|
|
bool video_context_driver_has_windowed(void);
|
|
|
|
|
|
|
|
void video_context_driver_free(void);
|
2016-02-13 08:21:35 +01:00
|
|
|
|
2014-01-22 16:38:42 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-05-26 04:47:24 +02:00
|
|
|
#endif
|
|
|
|
|