RetroArch
egl_common.h
Go to the documentation of this file.
1 /* RetroArch - A frontend for libretro.
2  * Copyright (c) 2011-2017 - Daniel De Matteis
3  *
4  * RetroArch is free software: you can redistribute it and/or modify it under the terms
5  * of the GNU General Public License as published by the Free Software Found-
6  * ation, either version 3 of the License, or (at your option) any later version.
7  *
8  * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10  * PURPOSE. See the GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License along with RetroArch.
13  * If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 #ifndef __EGL_COMMON_H
17 #define __EGL_COMMON_H
18 
19 #ifdef HAVE_GBM
20 /* presense or absense of this include makes egl.h change NativeWindowType between gbm_device* and _XDisplay* */
21 #include <gbm.h>
22 #endif
23 #include <EGL/egl.h>
24 #include <EGL/eglext.h>
25 
26 #include <boolean.h>
27 #include <retro_common_api.h>
28 
29 #include "../video_driver.h"
30 
31 #ifndef EGL_CONTEXT_FLAGS_KHR
32 #define EGL_CONTEXT_FLAGS_KHR 0x30FC
33 #endif
34 
35 #ifndef EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR
36 #define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
37 #endif
38 
40 
41 /* Put this structure as the first member of egl-based contexts
42  * like this:
43  * typedef struct
44  * {
45  * egl_ctx_data_t egl;
46  * int member0;
47  * char member1;
48  * ....
49  * } my_ctx_data_t;
50  *
51  * You can call egl functions passing the data pointer you receive
52  * or using &ctx_data->egl. It's up to you.
53  */
54 typedef struct
55 {
56  EGLContext ctx;
57  EGLContext hw_ctx;
58  EGLSurface surf;
59  EGLDisplay dpy;
60  EGLConfig config;
61  int interval;
62 
63  unsigned major;
64  unsigned minor;
65 
66  /* egl "private" */
67  bool use_hw_ctx;
69 
70 extern bool g_egl_inited;
71 
72 /* bind_api is called before init so we need these, please
73  * try no to use them outside of bind_api() and init() */
74 extern unsigned g_egl_major;
75 extern unsigned g_egl_minor;
76 
77 void egl_report_error(void);
78 
79 void egl_destroy(egl_ctx_data_t *egl);
80 
81 gfx_ctx_proc_t egl_get_proc_address(const char *symbol);
82 
84 
85 void egl_swap_buffers(void *data);
86 
87 void egl_set_swap_interval(egl_ctx_data_t *egl, int interval);
88 
89 void egl_get_video_size(egl_ctx_data_t *egl, unsigned *width, unsigned *height);
90 
91 typedef bool (*egl_accept_config_cb_t)(void *display_data, EGLDisplay dpy, EGLConfig config);
92 bool egl_default_accept_config_cb(void *display_data, EGLDisplay dpy, EGLConfig config);
93 
95  EGLenum platform,
96  void *display_data,
97  EGLint *major,
98  EGLint *minor,
99  EGLint *n,
100  const EGLint *attrib_ptr,
102 
103 bool egl_create_context(egl_ctx_data_t *egl, const EGLint *egl_attribs);
104 
105 bool egl_create_surface(egl_ctx_data_t *egl, void *native_window);
106 
107 bool egl_get_native_visual_id(egl_ctx_data_t *egl, EGLint *value);
108 
109 bool egl_has_config(egl_ctx_data_t *egl);
110 
112 
113 #endif
int interval
Definition: egl_common.h:61
#define RETRO_BEGIN_DECLS
Definition: retro_common_api.h:41
unsigned g_egl_minor
Definition: egl_common.c:35
gfx_ctx_proc_t egl_get_proc_address(const char *symbol)
Definition: egl_common.c:103
void egl_set_swap_interval(egl_ctx_data_t *egl, int interval)
Definition: egl_common.c:174
void egl_destroy(egl_ctx_data_t *egl)
Definition: egl_common.c:108
void(* gfx_ctx_proc_t)(void)
Definition: video_driver.h:330
GLboolean enable
Definition: glext.h:12027
EGLContext ctx
Definition: egl_common.h:56
EGLSurface surf
Definition: egl_common.h:58
bool use_hw_ctx
Definition: egl_common.h:67
unsigned major
Definition: egl_common.h:63
EGLDisplay dpy
Definition: egl_common.h:59
Definition: ibxm.h:9
typedef bool(RETRO_CALLCONV *retro_replace_image_index_t)(unsigned index
bool egl_create_surface(egl_ctx_data_t *egl, void *native_window)
Definition: egl_common.c:420
EGLContext hw_ctx
Definition: egl_common.h:57
bool egl_create_context(egl_ctx_data_t *egl, const EGLint *egl_attribs)
Definition: egl_common.c:396
void egl_bind_hw_render(egl_ctx_data_t *egl, bool enable)
Definition: egl_common.c:149
void egl_report_error(void)
Definition: egl_common.c:37
bool egl_init_context(egl_ctx_data_t *egl, EGLenum platform, void *display_data, EGLint *major, EGLint *minor, EGLint *n, const EGLint *attrib_ptr, egl_accept_config_cb_t cb)
Definition: egl_common.c:329
Definition: deflate.c:120
struct config_s config
#define RETRO_END_DECLS
Definition: retro_common_api.h:42
unsigned minor
Definition: egl_common.h:64
EGLConfig config
Definition: egl_common.h:60
void egl_get_video_size(egl_ctx_data_t *egl, unsigned *width, unsigned *height)
Definition: egl_common.c:195
GLint GLint GLsizei width
Definition: glext.h:6293
GLsizei const GLfloat * value
Definition: glext.h:6709
Definition: egl_common.h:54
bool egl_default_accept_config_cb(void *display_data, EGLDisplay dpy, EGLConfig config)
Definition: egl_common.c:312
bool egl_has_config(egl_ctx_data_t *egl)
Definition: egl_common.c:448
void egl_swap_buffers(void *data)
Definition: egl_common.c:163
GLdouble n
Definition: glext.h:8396
unsigned g_egl_major
Definition: egl_common.c:34
bool egl_get_native_visual_id(egl_ctx_data_t *egl, EGLint *value)
Definition: egl_common.c:436
bool(* egl_accept_config_cb_t)(void *display_data, EGLDisplay dpy, EGLConfig config)
Definition: egl_common.h:91
GLint GLint GLsizei GLsizei height
Definition: glext.h:6293
bool g_egl_inited
Definition: egl_common.c:32