diff --git a/Makefile.common b/Makefile.common index 24c1ce551b..cdc22165f3 100644 --- a/Makefile.common +++ b/Makefile.common @@ -661,6 +661,10 @@ ifeq ($(HAVE_GL_CONTEXT), 1) DEFINES += -DHAVE_GLSL endif +ifeq ($(HAVE_EGL), 1) + OBJ += gfx/common/egl_common.o +endif + ifeq ($(HAVE_SDL2), 1) HAVE_SDL=0 endif diff --git a/gfx/common/egl_common.c b/gfx/common/egl_common.c new file mode 100644 index 0000000000..a77bbee65c --- /dev/null +++ b/gfx/common/egl_common.c @@ -0,0 +1,48 @@ +/* RetroArch - A frontend for libretro. + * copyright (c) 2011-2015 - Daniel De Matteis + * + * 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 . + */ + +#include + +#include "egl_common.h" + +void egl_report_error(void) +{ + EGLint error = eglGetError(); + const char *str = NULL; + switch (error) + { + case EGL_SUCCESS: + str = "EGL_SUCCESS"; + break; + + case EGL_BAD_DISPLAY: + str = "EGL_BAD_DISPLAY"; + break; + + case EGL_BAD_SURFACE: + str = "EGL_BAD_SURFACE"; + break; + + case EGL_BAD_CONTEXT: + str = "EGL_BAD_CONTEXT"; + break; + + default: + str = "Unknown"; + break; + } + + RARCH_ERR("[EGL]: #0x%x, %s\n", (unsigned)error, str); +} diff --git a/gfx/common/egl_common.h b/gfx/common/egl_common.h new file mode 100644 index 0000000000..92d87685c3 --- /dev/null +++ b/gfx/common/egl_common.h @@ -0,0 +1,24 @@ +/* RetroArch - A frontend for libretro. + * copyright (c) 2011-2015 - Daniel De Matteis + * + * 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 . + */ + +#ifndef __EGL_COMMON_H +#define __EGL_COMMON_H + +#include +#include + +void egl_report_error(void); + +#endif diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index a56d528c08..19a19f3de8 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -499,8 +499,7 @@ static float gfx_ctx_vc_translate_aspect(void *data, /* Check for SD televisions: they should always be 4:3. */ if ((width == 640 || width == 720) && (height == 480 || height == 576)) return 4.0f / 3.0f; - else - return (float)width / height; + return (float)width / height; } static bool gfx_ctx_vc_image_buffer_init(void *data, diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index a5e50c3a24..b0df73540b 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -18,9 +18,6 @@ #include #include -#include -#include - #include #include @@ -28,6 +25,7 @@ #include "../../general.h" #include "../../runloop.h" #include "../video_monitor.h" +#include "../common/egl_common.h" #include "../common/gl_common.h" typedef struct gfx_ctx_wayland_data @@ -206,37 +204,6 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl) wl->g_height = 0; } -static void egl_report_error(void) -{ - EGLint error = eglGetError(); - const char *str = NULL; - - switch (error) - { - case EGL_SUCCESS: - str = "EGL_SUCCESS"; - break; - - case EGL_BAD_DISPLAY: - str = "EGL_BAD_DISPLAY"; - break; - - case EGL_BAD_SURFACE: - str = "EGL_BAD_SURFACE"; - break; - - case EGL_BAD_CONTEXT: - str = "EGL_BAD_CONTEXT"; - break; - - default: - str = "Unknown"; - break; - } - - RARCH_ERR("[Wayland/EGL]: #0x%x, %s\n", (unsigned)error, str); -} - static void gfx_ctx_wl_swap_interval(void *data, unsigned interval) { driver_t *driver = driver_get_ptr(); diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 3109a60709..b75a9aea2b 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -14,17 +14,13 @@ * If not, see . */ -/* X/EGL context. Mostly used for testing GLES code paths. -* Should be its own file as it has lots of X11 stuff baked into it as well. -*/ +/* X/EGL context. Mostly used for testing GLES code paths. */ #include #include -#include -#include - #include "../../driver.h" +#include "../common/egl_common.h" #include "../common/gl_common.h" #include "../common/x11_common.h" @@ -66,36 +62,6 @@ static int egl_nul_handler(Display *dpy, XErrorEvent *event) static void gfx_ctx_xegl_destroy(void *data); -static void egl_report_error(void) -{ - EGLint error = eglGetError(); - const char *str = NULL; - switch (error) - { - case EGL_SUCCESS: - str = "EGL_SUCCESS"; - break; - - case EGL_BAD_DISPLAY: - str = "EGL_BAD_DISPLAY"; - break; - - case EGL_BAD_SURFACE: - str = "EGL_BAD_SURFACE"; - break; - - case EGL_BAD_CONTEXT: - str = "EGL_BAD_CONTEXT"; - break; - - default: - str = "Unknown"; - break; - } - - RARCH_ERR("[X/EGL]: #0x%x, %s\n", (unsigned)error, str); -} - static void gfx_ctx_xegl_swap_interval(void *data, unsigned interval) { (void)data; diff --git a/griffin/griffin.c b/griffin/griffin.c index af2ce98a36..2ac75e2944 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -139,6 +139,10 @@ VIDEO CONTEXT #endif +#if defined(HAVE_EGL) +#include "../gfx/common/egl_common.c" +#endif + #if defined(HAVE_X11) #include "../gfx/common/x11_common.c"