This commit is contained in:
twinaphex 2018-02-24 14:34:03 +01:00
parent c5c2053913
commit 665aa372e0
2 changed files with 27 additions and 14 deletions

View File

@ -112,8 +112,14 @@ else
endif endif
OBJECTS := mpv-libretro.o OBJECTS := mpv-libretro.o
LDFLAGS += -lmpv -ldl -lm LDFLAGS += -lmpv
CFLAGS += -Wall -pedantic -std=gnu99 CFLAGS += -Wall -pedantic -std=c99
ifneq (,$(findstring gles,$(platform)))
LDFLAGS += -ldl
endif
LDFLAGS += -lm
all: $(TARGET) all: $(TARGET)

View File

@ -14,8 +14,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <dlfcn.h>
#include <math.h> #include <math.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
@ -23,6 +22,10 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#ifdef HAVE_OPENGLES
#include <dlfcn.h>
#endif
#ifdef HAVE_LOCALE #ifdef HAVE_LOCALE
#include <locale.h> #include <locale.h>
#endif #endif
@ -30,7 +33,7 @@
#include <mpv/client.h> #include <mpv/client.h>
#include <mpv/opengl_cb.h> #include <mpv/opengl_cb.h>
#include "libretro.h" #include <libretro.h>
#include "version.h" #include "version.h"
static struct retro_hw_render_callback hw_render; static struct retro_hw_render_callback hw_render;
@ -131,20 +134,24 @@ static void *get_proc_address_mpv(void *fn_ctx, const char *name)
void *proc_addr = (void *) hw_render.get_proc_address(name); void *proc_addr = (void *) hw_render.get_proc_address(name);
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#ifdef HAVE_OPENGLES
/* EGL 1.4 (supported by the RPI firmware) does not necessarily return /* EGL 1.4 (supported by the RPI firmware) does not necessarily return
* function pointers for core functions. * function pointers for core functions.
*/ */
if (!proc_addr) { if (!proc_addr)
void *h = dlopen("/opt/vc/lib/libGLESv2.so", RTLD_LAZY); {
void *h = dlopen("/opt/vc/lib/libGLESv2.so", RTLD_LAZY);
if (!h) if (!h)
h = dlopen("/usr/lib/libGLESv2.so", RTLD_LAZY); h = dlopen("/usr/lib/libGLESv2.so", RTLD_LAZY);
if (h) { if (h)
proc_addr = dlsym(h, name); {
dlclose(h); proc_addr = dlsym(h, name);
} dlclose(h);
} }
}
#endif
if(proc_addr == NULL) if(proc_addr == NULL)
log_cb(RETRO_LOG_ERROR, "Failure obtaining %s proc address\n", name); log_cb(RETRO_LOG_ERROR, "Failure obtaining %s proc address\n", name);