Skip to content

Commit

Permalink
libretro: don't link with OpenGL libs on android, windows and linux
Browse files Browse the repository at this point in the history
Issue #1221
  • Loading branch information
flyinghead committed Nov 12, 2023
1 parent 535fbe2 commit 46eab50
Show file tree
Hide file tree
Showing 8 changed files with 5,336 additions and 3,936 deletions.
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ elseif(LIBRETRO)
endif()
if(ANDROID OR USE_GLES)
target_compile_definitions(${PROJECT_NAME} PRIVATE GLES GLES3 HAVE_OPENGLES HAVE_OPENGLES3)
find_library(GLES3_LIBRARIES NAMES GLESv3 GLESv2 NO_CACHE REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE ${GLES3_LIBRARIES})
elseif(IOS)
target_compile_definitions(${PROJECT_NAME} PRIVATE GLES GLES3 HAVE_OPENGLES HAVE_OPENGLES3)
find_library(OPENGLES OpenGLES)
Expand All @@ -173,9 +171,6 @@ elseif(LIBRETRO)
else()
target_compile_definitions(${PROJECT_NAME} PRIVATE HAVE_OIT)
endif()
if(WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE "-lopengl32")
endif()
endif()
elseif(ANDROID)
add_library(${PROJECT_NAME} SHARED core/emulator.cpp)
Expand Down Expand Up @@ -720,11 +715,6 @@ if(LIBRETRO)
core/deps/libretro-common/file/retro_dirent.c
core/deps/libretro-common/string/stdstring.c)
if(USE_OPENGL)
if(UNIX AND NOT APPLE AND NOT ANDROID)
find_package(OpenGL REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE OpenGL::GL)
endif()

target_sources(${PROJECT_NAME} PRIVATE
core/deps/libretro-common/glsm/glsm.c
core/deps/libretro-common/glsym/rglgen.c)
Expand Down
16 changes: 16 additions & 0 deletions core/deps/libretro-common/glsm/glsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2360,7 +2360,11 @@ void * rglMapBuffer( GLenum target, GLenum access)
log_cb(RETRO_LOG_INFO, "glMapBuffer.\n");
#endif
#if defined(HAVE_OPENGLES)
#ifdef glMapBufferOES
return glMapBufferOES(target, access);
#else
return NULL;
#endif
#else
return glMapBuffer(target, access);
#endif
Expand All @@ -2377,7 +2381,11 @@ GLboolean rglUnmapBuffer( GLenum target)
log_cb(RETRO_LOG_INFO, "glUnmapBuffer.\n");
#endif
#if defined(HAVE_OPENGLES)
#ifdef glUnmapBufferOES
return glUnmapBufferOES(target);
#else
return false;
#endif
#else
return glUnmapBuffer(target);
#endif
Expand Down Expand Up @@ -2735,6 +2743,14 @@ void rglPrimitiveRestartIndex(GLuint index)
#endif
}

void rglHint(GLenum target, GLenum mode)
{
#ifdef GLSM_DEBUG
log_cb(RETRO_LOG_INFO, "glHint.\n");
#endif
glHint(target, mode);
}

/* GLSM-side */

static void glsm_state_setup(void)
Expand Down
11 changes: 8 additions & 3 deletions core/deps/libretro-common/glsym/glgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import os
import re

banned_ext = [ 'AMD', 'APPLE', 'NV', 'NVX', 'ATI', '3DLABS', 'SUN', 'SGI', 'SGIX', 'SGIS', 'INTEL', '3DFX', 'IBM', 'MESA', 'GREMEDY', 'OML', 'PGI', 'I3D', 'INGL', 'MTX', 'QCOM', 'IMG', 'ANGLE', 'SUNX', 'INGR' ]
banned_ext = [ 'AMD', 'APPLE', 'NVX', 'ATI', '3DLABS', 'SUN', 'SGI', 'SGIX', 'SGIS', 'INTEL', '3DFX', 'IBM', 'MESA', 'GREMEDY', 'OML', 'PGI', 'I3D', 'INGL', 'MTX', 'QCOM', 'IMG', 'ANGLE', 'SUNX', 'INGR' ]

def noext(sym):
for ext in banned_ext:
Expand Down Expand Up @@ -57,7 +57,7 @@ def find_gl_symbols(lines):
syms = []
for line in lines:
m = re.search(r'^typedef.+PFN(\S+)PROC.+$', line)
g = re.search(r'^.+(gl\S+)\W*\(.+\).*$', line)
g = re.search(r'^.+\W(gl\S+)\W*\(.+\).*$', line)
if m and noext(m.group(1)):
typedefs.append(m.group(0).replace('PFN', 'RGLSYM').replace('GLDEBUGPROC', 'RGLGENGLDEBUGPROC'))
if g and noext(g.group(1)):
Expand All @@ -73,8 +73,13 @@ def generate_defines(gl_syms):
def generate_declarations(gl_syms):
return ['RGLSYM' + x.upper() + 'PROC ' + '__rglgen_' + x + ';' for x in gl_syms]

def remove_prefix(text, prefix):
if text.startswith(prefix):
return text[len(prefix):]
return text

def generate_macros(gl_syms):
return [' SYM(' + x.replace('gl', '') + '),' for x in gl_syms]
return [' SYM(' + remove_prefix(x, 'gl') + '),' for x in gl_syms]

def dump(f, lines):
f.write('\n'.join(lines))
Expand Down
Loading

0 comments on commit 46eab50

Please sign in to comment.