diff --git a/Makefile.common b/Makefile.common index 772516fcf5..9ba1c61c80 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1444,6 +1444,7 @@ ifeq ($(HAVE_VITAGLES), 1) endif ifeq ($(HAVE_GL_CONTEXT), 1) + OBJ += gfx/common/gl_common.o ifeq ($(HAVE_GL_MODERN), 1) DEFINES += -DHAVE_OPENGL OBJ += gfx/drivers/gl2.o \ diff --git a/gfx/common/gl_common.c b/gfx/common/gl_common.c new file mode 100644 index 0000000000..17f3bcb715 --- /dev/null +++ b/gfx/common/gl_common.c @@ -0,0 +1,35 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * copyright (c) 2011-2017 - Daniel De Matteis + * copyright (c) 2016-2019 - Brad Parker + * + * 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 + +void gl_disable(unsigned _cap) +{ + GLenum cap = (GLenum)_cap; + glDisable(cap); +} + +void gl_enable(unsigned _cap) +{ + GLenum cap = (GLenum)_cap; + glEnable(cap); +} + +void gl_finish(void) +{ + glFinish(); +} diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h new file mode 100644 index 0000000000..7cfcfb7c2c --- /dev/null +++ b/gfx/common/gl_common.h @@ -0,0 +1,26 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * copyright (c) 2011-2021 - 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 __GL_COMMON_H +#define __GL_COMMON_H + +void gl_enable(unsigned cap); + +void gl_disable(unsigned cap); + +void gl_finish(void); + +#endif diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index c547b5d130..0293e32568 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -142,9 +142,9 @@ static void gfx_ctx_ps3_set_swap_interval(void *data, int interval) { #if defined(HAVE_PSGL) if (interval == 1) - glEnable(GL_VSYNC_SCE); + gl_enable(GL_VSYNC_SCE); else - glDisable(GL_VSYNC_SCE); + gl_disable(GL_VSYNC_SCE); #endif } diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 470df096fa..a5d1233c46 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -54,12 +54,8 @@ #endif #endif -#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) -#include "../common/gl2_common.h" -#elif defined(HAVE_OPENGL_CORE) -#include "../common/gl3_common.h" -#elif defined(HAVE_OPENGL1) -#include "../common/gl1_common.h" +#if (defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)) && !defined(HAVE_OPENGLES) +#include "../common/gl_common.h" #endif #if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE) @@ -548,7 +544,7 @@ static void gfx_ctx_wgl_destroy(void *data) #if (defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_OPENGL_CORE)) && !defined(HAVE_OPENGLES) if (win32_hrc) { - glFinish(); + gl_finish(); wglMakeCurrent(NULL, NULL); if (!video_driver_is_video_cache_context()) diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 3699705d62..cd02af7894 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -44,8 +44,7 @@ #include "../../frontend/frontend_driver.h" #include "../../input/input_driver.h" #include "../../verbosity.h" -/* TODO/FIXME - we should have a gl_common.h for functions like glFinish so we don't have to include gl2_common.h here */ -#include "../common/gl2_common.h" +#include "../common/gl_common.h" #include "../common/x11_common.h" #ifdef HAVE_XINERAMA @@ -173,7 +172,7 @@ static void gfx_ctx_x_destroy_resources(gfx_ctx_x_data_t *x) if (x->ctx) { glXSwapBuffers(g_x11_dpy, x->glx_win); - glFinish(); + gl_finish(); glXMakeContextCurrent(g_x11_dpy, None, None, NULL); if (!video_driver_is_video_cache_context()) diff --git a/griffin/griffin.c b/griffin/griffin.c index 9d642a55ae..004902364d 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -243,6 +243,10 @@ VIDEO CONTEXT ============================================================ */ #include "../gfx/drivers_context/gfx_null_ctx.c" +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_VULKAN) || defined(HAVE_OPENGLES) || defined(HAVE_OPENGL_CORE) +#include "../gfx/common/gl_common.c" +#endif + #if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__) #if defined(HAVE_OPENGL) || defined(HAVE_OPENGL1) || defined(HAVE_VULKAN) || defined(HAVE_OPENGLES)