Create gl_common.c/gl_common.h

This commit is contained in:
twinaphex 2021-09-26 19:57:08 +02:00
parent 4b5951bda3
commit 4aafbf2340
7 changed files with 73 additions and 12 deletions

View File

@ -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 \

35
gfx/common/gl_common.c Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <glsym/rglgen.h>
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();
}

26
gfx/common/gl_common.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef __GL_COMMON_H
#define __GL_COMMON_H
void gl_enable(unsigned cap);
void gl_disable(unsigned cap);
void gl_finish(void);
#endif

View File

@ -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
}

View File

@ -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())

View File

@ -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())

View File

@ -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)