diff --git a/libretro-test-gl/Makefile b/libretro-test-gl/Makefile index dd4bf79d17..30a0eaed59 100644 --- a/libretro-test-gl/Makefile +++ b/libretro-test-gl/Makefile @@ -16,17 +16,17 @@ ifeq ($(platform), unix) TARGET := libretro.so fpic := -fPIC SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined - LIBS := -lGL + GL_LIB := -lGL else ifeq ($(platform), osx) TARGET := libretro.dylib fpic := -fPIC SHARED := -dynamiclib - LIBS := -framework OpenGL + GL_LIB := -framework OpenGL else CC = gcc TARGET := retro.dll SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=link.T -Wl,--no-undefined - LIBS := -lopengl32 + GL_LIB := -lopengl32 endif ifeq ($(DEBUG), 1) @@ -38,6 +38,13 @@ endif OBJECTS := libretro-test.o CFLAGS += -std=gnu99 -Wall -pedantic $(fpic) +ifeq ($(GLES), 1) + CFLAGS += -DGLES + LIBS += -lGLESv2 +else + LIBS += $(GL_LIB) +endif + all: $(TARGET) $(TARGET): $(OBJECTS) diff --git a/libretro-test-gl/libretro-test.c b/libretro-test-gl/libretro-test.c index 5f43e6c9d2..e8ff2ff14e 100644 --- a/libretro-test-gl/libretro-test.c +++ b/libretro-test-gl/libretro-test.c @@ -4,6 +4,27 @@ #include #include #include + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +static struct retro_hw_render_callback hw_render; + +#ifdef GLES +#include +#define pglCreateProgram glCreateProgram +#define pglCreateShader glCreateShader +#define pglCompileShader glCompileShader +#define pglUseProgram glUseProgram +#define pglShaderSource glShaderSource +#define pglAttachShader glAttachShader +#define pglLinkProgram glLinkProgram +#define pglBindFramebuffer glBindFramebuffer +#define pglGetUniformLocation glGetUniformLocation +#define pglUniformMatrix4fv glUniformMatrix4fv +#define pglGetAttribLocation glGetAttribLocation +#define pglVertexAttribPointer glVertexAttribPointer +#define pglEnableVertexAttribArray glEnableVertexAttribArray +#define pglDisableVertexAttribArray glEnableVertexAttribArray +#else #include #define GL_GLEXT_PROTOTYPES #include @@ -23,7 +44,6 @@ static PFNGLVERTEXATTRIBPOINTERPROC pglVertexAttribPointer; static PFNGLENABLEVERTEXATTRIBARRAYPROC pglEnableVertexAttribArray; static PFNGLDISABLEVERTEXATTRIBARRAYPROC pglDisableVertexAttribArray; -static struct retro_hw_render_callback hw_render; struct gl_proc_map { @@ -32,7 +52,6 @@ struct gl_proc_map }; #define PROC_BIND(name) { &(pgl##name), "gl" #name } -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) static const struct gl_proc_map proc_map[] = { PROC_BIND(CreateProgram), PROC_BIND(CreateShader), @@ -60,6 +79,7 @@ static void init_gl_proc(void) memcpy(proc_map[i].proc, &proc, sizeof(proc)); } } +#endif static GLuint prog; @@ -237,7 +257,9 @@ void retro_run(void) static void context_reset(void) { fprintf(stderr, "Context reset!\n"); +#ifndef GLES init_gl_proc(); +#endif compile_program(); }