mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
Use glsym wrapper in libretro-test-gl.
This commit is contained in:
parent
2e397b1d6b
commit
d64c24248d
6
gfx/gl.c
6
gfx/gl.c
@ -94,15 +94,11 @@ static inline bool gl_query_extension(gl_t *gl, const char *ext)
|
|||||||
if (gl->core_context)
|
if (gl->core_context)
|
||||||
{
|
{
|
||||||
#ifdef GL_NUM_EXTENSIONS
|
#ifdef GL_NUM_EXTENSIONS
|
||||||
gl_get_stringi_proc proc = (gl_get_stringi_proc)gl->ctx_driver->get_proc_address("glGetStringi");
|
|
||||||
if (!proc)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
GLint exts = 0;
|
GLint exts = 0;
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &exts);
|
glGetIntegerv(GL_NUM_EXTENSIONS, &exts);
|
||||||
for (GLint i = 0; i < exts; i++)
|
for (GLint i = 0; i < exts; i++)
|
||||||
{
|
{
|
||||||
const char *str = (const char*)proc(GL_EXTENSIONS, i);
|
const char *str = (const char*)glGetStringi(GL_EXTENSIONS, i);
|
||||||
if (str && strstr(str, ext))
|
if (str && strstr(str, ext))
|
||||||
{
|
{
|
||||||
ret = true;
|
ret = true;
|
||||||
|
@ -91,18 +91,20 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(platform), qnx)
|
ifeq ($(platform), qnx)
|
||||||
CFLAGS += -Wc,-std=gnu99
|
CFLAGS += -Wc,-std=gnu99
|
||||||
else
|
else
|
||||||
CFLAGS += -std=gnu99
|
CFLAGS += -std=gnu99
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OBJECTS := libretro-test.o
|
OBJECTS := libretro-test.o rglgen.o
|
||||||
CFLAGS += -Wall -pedantic $(fpic)
|
CFLAGS += -Wall -pedantic $(fpic)
|
||||||
|
|
||||||
ifeq ($(GLES), 1)
|
ifeq ($(GLES), 1)
|
||||||
CFLAGS += -DGLES
|
CFLAGS += -DGLES -DHAVE_OPENGLES2
|
||||||
LIBS += -lGLESv2
|
LIBS += -lGLESv2
|
||||||
|
OBJECTS += glsym_es2.o
|
||||||
else
|
else
|
||||||
|
OBJECTS += glsym_gl.o
|
||||||
LIBS += $(GL_LIB)
|
LIBS += $(GL_LIB)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
13
libretro-test-gl/glsym.h
Normal file
13
libretro-test-gl/glsym.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef GLSYM_H__
|
||||||
|
#define GLSYM_H__
|
||||||
|
|
||||||
|
#include "rglgen.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENGLES2
|
||||||
|
#include "glsym_es2.h"
|
||||||
|
#else
|
||||||
|
#include "glsym_gl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
64
libretro-test-gl/glsym_es2.c
Normal file
64
libretro-test-gl/glsym_es2.c
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#include "glsym.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
#define SYM(x) { "gl" #x, &(gl##x) }
|
||||||
|
const struct rglgen_sym_map rglgen_symbol_map[] = {
|
||||||
|
SYM(EGLImageTargetTexture2DOES),
|
||||||
|
SYM(EGLImageTargetRenderbufferStorageOES),
|
||||||
|
SYM(GetProgramBinaryOES),
|
||||||
|
SYM(ProgramBinaryOES),
|
||||||
|
SYM(MapBufferOES),
|
||||||
|
SYM(UnmapBufferOES),
|
||||||
|
SYM(GetBufferPointervOES),
|
||||||
|
SYM(TexImage3DOES),
|
||||||
|
SYM(TexSubImage3DOES),
|
||||||
|
SYM(CopyTexSubImage3DOES),
|
||||||
|
SYM(CompressedTexImage3DOES),
|
||||||
|
SYM(CompressedTexSubImage3DOES),
|
||||||
|
SYM(FramebufferTexture3DOES),
|
||||||
|
SYM(BindVertexArrayOES),
|
||||||
|
SYM(DeleteVertexArraysOES),
|
||||||
|
SYM(GenVertexArraysOES),
|
||||||
|
SYM(IsVertexArrayOES),
|
||||||
|
SYM(DebugMessageControl),
|
||||||
|
SYM(DebugMessageInsert),
|
||||||
|
SYM(DebugMessageCallback),
|
||||||
|
SYM(GetDebugMessageLog),
|
||||||
|
SYM(PushDebugGroup),
|
||||||
|
SYM(PopDebugGroup),
|
||||||
|
SYM(ObjectLabel),
|
||||||
|
SYM(GetObjectLabel),
|
||||||
|
SYM(ObjectPtrLabel),
|
||||||
|
SYM(GetObjectPtrLabel),
|
||||||
|
SYM(GetPointerv),
|
||||||
|
|
||||||
|
{ NULL, NULL },
|
||||||
|
};
|
||||||
|
RGLSYMGLEGLIMAGETARGETTEXTURE2DOESPROC __rglgen_glEGLImageTargetTexture2DOES;
|
||||||
|
RGLSYMGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC __rglgen_glEGLImageTargetRenderbufferStorageOES;
|
||||||
|
RGLSYMGLGETPROGRAMBINARYOESPROC __rglgen_glGetProgramBinaryOES;
|
||||||
|
RGLSYMGLPROGRAMBINARYOESPROC __rglgen_glProgramBinaryOES;
|
||||||
|
RGLSYMGLMAPBUFFEROESPROC __rglgen_glMapBufferOES;
|
||||||
|
RGLSYMGLUNMAPBUFFEROESPROC __rglgen_glUnmapBufferOES;
|
||||||
|
RGLSYMGLGETBUFFERPOINTERVOESPROC __rglgen_glGetBufferPointervOES;
|
||||||
|
RGLSYMGLTEXIMAGE3DOESPROC __rglgen_glTexImage3DOES;
|
||||||
|
RGLSYMGLTEXSUBIMAGE3DOESPROC __rglgen_glTexSubImage3DOES;
|
||||||
|
RGLSYMGLCOPYTEXSUBIMAGE3DOESPROC __rglgen_glCopyTexSubImage3DOES;
|
||||||
|
RGLSYMGLCOMPRESSEDTEXIMAGE3DOESPROC __rglgen_glCompressedTexImage3DOES;
|
||||||
|
RGLSYMGLCOMPRESSEDTEXSUBIMAGE3DOESPROC __rglgen_glCompressedTexSubImage3DOES;
|
||||||
|
RGLSYMGLFRAMEBUFFERTEXTURE3DOESPROC __rglgen_glFramebufferTexture3DOES;
|
||||||
|
RGLSYMGLBINDVERTEXARRAYOESPROC __rglgen_glBindVertexArrayOES;
|
||||||
|
RGLSYMGLDELETEVERTEXARRAYSOESPROC __rglgen_glDeleteVertexArraysOES;
|
||||||
|
RGLSYMGLGENVERTEXARRAYSOESPROC __rglgen_glGenVertexArraysOES;
|
||||||
|
RGLSYMGLISVERTEXARRAYOESPROC __rglgen_glIsVertexArrayOES;
|
||||||
|
RGLSYMGLDEBUGMESSAGECONTROLPROC __rglgen_glDebugMessageControl;
|
||||||
|
RGLSYMGLDEBUGMESSAGEINSERTPROC __rglgen_glDebugMessageInsert;
|
||||||
|
RGLSYMGLDEBUGMESSAGECALLBACKPROC __rglgen_glDebugMessageCallback;
|
||||||
|
RGLSYMGLGETDEBUGMESSAGELOGPROC __rglgen_glGetDebugMessageLog;
|
||||||
|
RGLSYMGLPUSHDEBUGGROUPPROC __rglgen_glPushDebugGroup;
|
||||||
|
RGLSYMGLPOPDEBUGGROUPPROC __rglgen_glPopDebugGroup;
|
||||||
|
RGLSYMGLOBJECTLABELPROC __rglgen_glObjectLabel;
|
||||||
|
RGLSYMGLGETOBJECTLABELPROC __rglgen_glGetObjectLabel;
|
||||||
|
RGLSYMGLOBJECTPTRLABELPROC __rglgen_glObjectPtrLabel;
|
||||||
|
RGLSYMGLGETOBJECTPTRLABELPROC __rglgen_glGetObjectPtrLabel;
|
||||||
|
RGLSYMGLGETPOINTERVPROC __rglgen_glGetPointerv;
|
||||||
|
|
92
libretro-test-gl/glsym_es2.h
Normal file
92
libretro-test-gl/glsym_es2.h
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#ifndef RGLGEN_DECL_H__
|
||||||
|
#define RGLGEN_DECL_H__
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
|
||||||
|
typedef void* (GL_APIENTRYP RGLSYMGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
|
||||||
|
typedef GLboolean (GL_APIENTRYP RGLSYMGLUNMAPBUFFEROESPROC) (GLenum target);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid** params);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLFRAMEBUFFERTEXTURE3DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLBINDVERTEXARRAYOESPROC) (GLuint array);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays);
|
||||||
|
typedef GLboolean (GL_APIENTRYP RGLSYMGLISVERTEXARRAYOESPROC) (GLuint array);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam);
|
||||||
|
typedef GLuint (GL_APIENTRYP RGLSYMGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLPOPDEBUGGROUPPROC) (void);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
|
||||||
|
typedef void (GL_APIENTRYP RGLSYMGLGETPOINTERVPROC) (GLenum pname, void **params);
|
||||||
|
|
||||||
|
#define glEGLImageTargetTexture2DOES __rglgen_glEGLImageTargetTexture2DOES
|
||||||
|
#define glEGLImageTargetRenderbufferStorageOES __rglgen_glEGLImageTargetRenderbufferStorageOES
|
||||||
|
#define glGetProgramBinaryOES __rglgen_glGetProgramBinaryOES
|
||||||
|
#define glProgramBinaryOES __rglgen_glProgramBinaryOES
|
||||||
|
#define glMapBufferOES __rglgen_glMapBufferOES
|
||||||
|
#define glUnmapBufferOES __rglgen_glUnmapBufferOES
|
||||||
|
#define glGetBufferPointervOES __rglgen_glGetBufferPointervOES
|
||||||
|
#define glTexImage3DOES __rglgen_glTexImage3DOES
|
||||||
|
#define glTexSubImage3DOES __rglgen_glTexSubImage3DOES
|
||||||
|
#define glCopyTexSubImage3DOES __rglgen_glCopyTexSubImage3DOES
|
||||||
|
#define glCompressedTexImage3DOES __rglgen_glCompressedTexImage3DOES
|
||||||
|
#define glCompressedTexSubImage3DOES __rglgen_glCompressedTexSubImage3DOES
|
||||||
|
#define glFramebufferTexture3DOES __rglgen_glFramebufferTexture3DOES
|
||||||
|
#define glBindVertexArrayOES __rglgen_glBindVertexArrayOES
|
||||||
|
#define glDeleteVertexArraysOES __rglgen_glDeleteVertexArraysOES
|
||||||
|
#define glGenVertexArraysOES __rglgen_glGenVertexArraysOES
|
||||||
|
#define glIsVertexArrayOES __rglgen_glIsVertexArrayOES
|
||||||
|
#define glDebugMessageControl __rglgen_glDebugMessageControl
|
||||||
|
#define glDebugMessageInsert __rglgen_glDebugMessageInsert
|
||||||
|
#define glDebugMessageCallback __rglgen_glDebugMessageCallback
|
||||||
|
#define glGetDebugMessageLog __rglgen_glGetDebugMessageLog
|
||||||
|
#define glPushDebugGroup __rglgen_glPushDebugGroup
|
||||||
|
#define glPopDebugGroup __rglgen_glPopDebugGroup
|
||||||
|
#define glObjectLabel __rglgen_glObjectLabel
|
||||||
|
#define glGetObjectLabel __rglgen_glGetObjectLabel
|
||||||
|
#define glObjectPtrLabel __rglgen_glObjectPtrLabel
|
||||||
|
#define glGetObjectPtrLabel __rglgen_glGetObjectPtrLabel
|
||||||
|
#define glGetPointerv __rglgen_glGetPointerv
|
||||||
|
|
||||||
|
extern RGLSYMGLEGLIMAGETARGETTEXTURE2DOESPROC __rglgen_glEGLImageTargetTexture2DOES;
|
||||||
|
extern RGLSYMGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC __rglgen_glEGLImageTargetRenderbufferStorageOES;
|
||||||
|
extern RGLSYMGLGETPROGRAMBINARYOESPROC __rglgen_glGetProgramBinaryOES;
|
||||||
|
extern RGLSYMGLPROGRAMBINARYOESPROC __rglgen_glProgramBinaryOES;
|
||||||
|
extern RGLSYMGLMAPBUFFEROESPROC __rglgen_glMapBufferOES;
|
||||||
|
extern RGLSYMGLUNMAPBUFFEROESPROC __rglgen_glUnmapBufferOES;
|
||||||
|
extern RGLSYMGLGETBUFFERPOINTERVOESPROC __rglgen_glGetBufferPointervOES;
|
||||||
|
extern RGLSYMGLTEXIMAGE3DOESPROC __rglgen_glTexImage3DOES;
|
||||||
|
extern RGLSYMGLTEXSUBIMAGE3DOESPROC __rglgen_glTexSubImage3DOES;
|
||||||
|
extern RGLSYMGLCOPYTEXSUBIMAGE3DOESPROC __rglgen_glCopyTexSubImage3DOES;
|
||||||
|
extern RGLSYMGLCOMPRESSEDTEXIMAGE3DOESPROC __rglgen_glCompressedTexImage3DOES;
|
||||||
|
extern RGLSYMGLCOMPRESSEDTEXSUBIMAGE3DOESPROC __rglgen_glCompressedTexSubImage3DOES;
|
||||||
|
extern RGLSYMGLFRAMEBUFFERTEXTURE3DOESPROC __rglgen_glFramebufferTexture3DOES;
|
||||||
|
extern RGLSYMGLBINDVERTEXARRAYOESPROC __rglgen_glBindVertexArrayOES;
|
||||||
|
extern RGLSYMGLDELETEVERTEXARRAYSOESPROC __rglgen_glDeleteVertexArraysOES;
|
||||||
|
extern RGLSYMGLGENVERTEXARRAYSOESPROC __rglgen_glGenVertexArraysOES;
|
||||||
|
extern RGLSYMGLISVERTEXARRAYOESPROC __rglgen_glIsVertexArrayOES;
|
||||||
|
extern RGLSYMGLDEBUGMESSAGECONTROLPROC __rglgen_glDebugMessageControl;
|
||||||
|
extern RGLSYMGLDEBUGMESSAGEINSERTPROC __rglgen_glDebugMessageInsert;
|
||||||
|
extern RGLSYMGLDEBUGMESSAGECALLBACKPROC __rglgen_glDebugMessageCallback;
|
||||||
|
extern RGLSYMGLGETDEBUGMESSAGELOGPROC __rglgen_glGetDebugMessageLog;
|
||||||
|
extern RGLSYMGLPUSHDEBUGGROUPPROC __rglgen_glPushDebugGroup;
|
||||||
|
extern RGLSYMGLPOPDEBUGGROUPPROC __rglgen_glPopDebugGroup;
|
||||||
|
extern RGLSYMGLOBJECTLABELPROC __rglgen_glObjectLabel;
|
||||||
|
extern RGLSYMGLGETOBJECTLABELPROC __rglgen_glGetObjectLabel;
|
||||||
|
extern RGLSYMGLOBJECTPTRLABELPROC __rglgen_glObjectPtrLabel;
|
||||||
|
extern RGLSYMGLGETOBJECTPTRLABELPROC __rglgen_glGetObjectPtrLabel;
|
||||||
|
extern RGLSYMGLGETPOINTERVPROC __rglgen_glGetPointerv;
|
||||||
|
|
||||||
|
struct rglgen_sym_map { const char *sym; void *ptr; };
|
||||||
|
extern const struct rglgen_sym_map rglgen_symbol_map[];
|
||||||
|
#endif
|
1735
libretro-test-gl/glsym_gl.c
Normal file
1735
libretro-test-gl/glsym_gl.c
Normal file
File diff suppressed because it is too large
Load Diff
2593
libretro-test-gl/glsym_gl.h
Normal file
2593
libretro-test-gl/glsym_gl.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -8,20 +8,7 @@
|
|||||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||||
static struct retro_hw_render_callback hw_render;
|
static struct retro_hw_render_callback hw_render;
|
||||||
|
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#include "glsym.h"
|
||||||
#if defined(GLES)
|
|
||||||
#ifdef IOS
|
|
||||||
#include <OpenGLES/ES2/gl.h>
|
|
||||||
#else
|
|
||||||
#include <GLES2/gl2.h>
|
|
||||||
#endif
|
|
||||||
#elif defined(__APPLE__)
|
|
||||||
#include <OpenGL/gl.h>
|
|
||||||
#include <OpenGL/glext.h>
|
|
||||||
#else
|
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <GL/glext.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define BASE_WIDTH 320
|
#define BASE_WIDTH 320
|
||||||
#define BASE_HEIGHT 240
|
#define BASE_HEIGHT 240
|
||||||
@ -36,91 +23,6 @@ static struct retro_hw_render_callback hw_render;
|
|||||||
static unsigned width = BASE_WIDTH;
|
static unsigned width = BASE_WIDTH;
|
||||||
static unsigned height = BASE_HEIGHT;
|
static unsigned height = BASE_HEIGHT;
|
||||||
|
|
||||||
#if defined(GLES) || defined(__APPLE__)
|
|
||||||
#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 glDisableVertexAttribArray
|
|
||||||
#define pglGenBuffers glGenBuffers
|
|
||||||
#define pglBufferData glBufferData
|
|
||||||
#define pglBindBuffer glBindBuffer
|
|
||||||
#define init_gl_proc()
|
|
||||||
#else
|
|
||||||
static PFNGLCREATEPROGRAMPROC pglCreateProgram;
|
|
||||||
static PFNGLCREATESHADERPROC pglCreateShader;
|
|
||||||
static PFNGLCREATESHADERPROC pglCompileShader;
|
|
||||||
static PFNGLCREATESHADERPROC pglUseProgram;
|
|
||||||
static PFNGLSHADERSOURCEPROC pglShaderSource;
|
|
||||||
static PFNGLATTACHSHADERPROC pglAttachShader;
|
|
||||||
static PFNGLLINKPROGRAMPROC pglLinkProgram;
|
|
||||||
static PFNGLBINDFRAMEBUFFERPROC pglBindFramebuffer;
|
|
||||||
static PFNGLGETUNIFORMLOCATIONPROC pglGetUniformLocation;
|
|
||||||
static PFNGLUNIFORMMATRIX4FVPROC pglUniformMatrix4fv;
|
|
||||||
static PFNGLGETATTRIBLOCATIONPROC pglGetAttribLocation;
|
|
||||||
static PFNGLVERTEXATTRIBPOINTERPROC pglVertexAttribPointer;
|
|
||||||
static PFNGLENABLEVERTEXATTRIBARRAYPROC pglEnableVertexAttribArray;
|
|
||||||
static PFNGLDISABLEVERTEXATTRIBARRAYPROC pglDisableVertexAttribArray;
|
|
||||||
static PFNGLGENBUFFERSPROC pglGenBuffers;
|
|
||||||
static PFNGLBUFFERDATAPROC pglBufferData;
|
|
||||||
static PFNGLBINDBUFFERPROC pglBindBuffer;
|
|
||||||
#ifdef CORE
|
|
||||||
static PFNGLGENVERTEXARRAYSPROC pglGenVertexArrays;
|
|
||||||
static PFNGLBINDVERTEXARRAYPROC pglBindVertexArray;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct gl_proc_map
|
|
||||||
{
|
|
||||||
void *proc;
|
|
||||||
const char *sym;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define PROC_BIND(name) { &(pgl##name), "gl" #name }
|
|
||||||
static const struct gl_proc_map proc_map[] = {
|
|
||||||
PROC_BIND(CreateProgram),
|
|
||||||
PROC_BIND(CreateShader),
|
|
||||||
PROC_BIND(CompileShader),
|
|
||||||
PROC_BIND(UseProgram),
|
|
||||||
PROC_BIND(ShaderSource),
|
|
||||||
PROC_BIND(AttachShader),
|
|
||||||
PROC_BIND(LinkProgram),
|
|
||||||
PROC_BIND(BindFramebuffer),
|
|
||||||
PROC_BIND(GetUniformLocation),
|
|
||||||
PROC_BIND(GetAttribLocation),
|
|
||||||
PROC_BIND(UniformMatrix4fv),
|
|
||||||
PROC_BIND(VertexAttribPointer),
|
|
||||||
PROC_BIND(EnableVertexAttribArray),
|
|
||||||
PROC_BIND(DisableVertexAttribArray),
|
|
||||||
PROC_BIND(GenBuffers),
|
|
||||||
PROC_BIND(BufferData),
|
|
||||||
PROC_BIND(BindBuffer),
|
|
||||||
#ifdef CORE
|
|
||||||
PROC_BIND(GenVertexArrays),
|
|
||||||
PROC_BIND(BindVertexArray),
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
static void init_gl_proc(void)
|
|
||||||
{
|
|
||||||
for (unsigned i = 0; i < ARRAY_SIZE(proc_map); i++)
|
|
||||||
{
|
|
||||||
retro_proc_address_t proc = hw_render.get_proc_address(proc_map[i].sym);
|
|
||||||
if (!proc)
|
|
||||||
fprintf(stderr, "Symbol %s not found!\n", proc_map[i].sym);
|
|
||||||
memcpy(proc_map[i].proc, &proc, sizeof(proc));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static GLuint prog;
|
static GLuint prog;
|
||||||
static GLuint vbo;
|
static GLuint vbo;
|
||||||
|
|
||||||
@ -185,33 +87,33 @@ static const char *fragment_shader[] = {
|
|||||||
|
|
||||||
static void compile_program(void)
|
static void compile_program(void)
|
||||||
{
|
{
|
||||||
prog = pglCreateProgram();
|
prog = glCreateProgram();
|
||||||
GLuint vert = pglCreateShader(GL_VERTEX_SHADER);
|
GLuint vert = glCreateShader(GL_VERTEX_SHADER);
|
||||||
GLuint frag = pglCreateShader(GL_FRAGMENT_SHADER);
|
GLuint frag = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
|
|
||||||
pglShaderSource(vert, ARRAY_SIZE(vertex_shader), vertex_shader, 0);
|
glShaderSource(vert, ARRAY_SIZE(vertex_shader), vertex_shader, 0);
|
||||||
pglShaderSource(frag, ARRAY_SIZE(fragment_shader), fragment_shader, 0);
|
glShaderSource(frag, ARRAY_SIZE(fragment_shader), fragment_shader, 0);
|
||||||
pglCompileShader(vert);
|
glCompileShader(vert);
|
||||||
pglCompileShader(frag);
|
glCompileShader(frag);
|
||||||
|
|
||||||
pglAttachShader(prog, vert);
|
glAttachShader(prog, vert);
|
||||||
pglAttachShader(prog, frag);
|
glAttachShader(prog, frag);
|
||||||
pglLinkProgram(prog);
|
glLinkProgram(prog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_vao(void)
|
static void setup_vao(void)
|
||||||
{
|
{
|
||||||
#ifdef CORE
|
#ifdef CORE
|
||||||
pglGenVertexArrays(1, &vao);
|
glGenVertexArrays(1, &vao);
|
||||||
#endif
|
#endif
|
||||||
pglUseProgram(prog);
|
glUseProgram(prog);
|
||||||
|
|
||||||
pglGenBuffers(1, &vbo);
|
glGenBuffers(1, &vbo);
|
||||||
pglBindBuffer(GL_ARRAY_BUFFER, vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||||
pglBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
|
||||||
|
|
||||||
pglBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
pglUseProgram(0);
|
glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void retro_init(void)
|
void retro_init(void)
|
||||||
@ -342,28 +244,28 @@ void retro_run(void)
|
|||||||
input_poll_cb();
|
input_poll_cb();
|
||||||
|
|
||||||
#ifdef CORE
|
#ifdef CORE
|
||||||
pglBindVertexArray(vao);
|
glBindVertexArray(vao);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pglBindFramebuffer(GL_FRAMEBUFFER, hw_render.get_current_framebuffer());
|
glBindFramebuffer(GL_FRAMEBUFFER, hw_render.get_current_framebuffer());
|
||||||
glClearColor(0.3, 0.4, 0.5, 1.0);
|
glClearColor(0.3, 0.4, 0.5, 1.0);
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||||
|
|
||||||
pglUseProgram(prog);
|
glUseProgram(prog);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
pglBindBuffer(GL_ARRAY_BUFFER, vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||||
int vloc = pglGetAttribLocation(prog, "aVertex");
|
int vloc = glGetAttribLocation(prog, "aVertex");
|
||||||
pglVertexAttribPointer(vloc, 2, GL_FLOAT, GL_FALSE, 0, (void*)0);
|
glVertexAttribPointer(vloc, 2, GL_FLOAT, GL_FALSE, 0, (void*)0);
|
||||||
pglEnableVertexAttribArray(vloc);
|
glEnableVertexAttribArray(vloc);
|
||||||
int cloc = pglGetAttribLocation(prog, "aColor");
|
int cloc = glGetAttribLocation(prog, "aColor");
|
||||||
pglVertexAttribPointer(cloc, 4, GL_FLOAT, GL_FALSE, 0, (void*)(8 * sizeof(GLfloat)));
|
glVertexAttribPointer(cloc, 4, GL_FLOAT, GL_FALSE, 0, (void*)(8 * sizeof(GLfloat)));
|
||||||
pglEnableVertexAttribArray(cloc);
|
glEnableVertexAttribArray(cloc);
|
||||||
pglBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
int loc = pglGetUniformLocation(prog, "uMVP");
|
int loc = glGetUniformLocation(prog, "uMVP");
|
||||||
|
|
||||||
static unsigned frame_count;
|
static unsigned frame_count;
|
||||||
frame_count++;
|
frame_count++;
|
||||||
@ -377,7 +279,7 @@ void retro_run(void)
|
|||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
0, 0, 0, 1,
|
0, 0, 0, 1,
|
||||||
};
|
};
|
||||||
pglUniformMatrix4fv(loc, 1, GL_FALSE, mvp);
|
glUniformMatrix4fv(loc, 1, GL_FALSE, mvp);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
|
||||||
cos_angle *= 0.5;
|
cos_angle *= 0.5;
|
||||||
@ -389,23 +291,23 @@ void retro_run(void)
|
|||||||
0.4, 0.4, 0.2, 1,
|
0.4, 0.4, 0.2, 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
pglUniformMatrix4fv(loc, 1, GL_FALSE, mvp2);
|
glUniformMatrix4fv(loc, 1, GL_FALSE, mvp2);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
pglDisableVertexAttribArray(vloc);
|
glDisableVertexAttribArray(vloc);
|
||||||
pglDisableVertexAttribArray(cloc);
|
glDisableVertexAttribArray(cloc);
|
||||||
|
|
||||||
pglUseProgram(0);
|
glUseProgram(0);
|
||||||
|
|
||||||
video_cb(RETRO_HW_FRAME_BUFFER_VALID, width, height, 0);
|
video_cb(RETRO_HW_FRAME_BUFFER_VALID, width, height, 0);
|
||||||
#ifdef CORE
|
#ifdef CORE
|
||||||
pglBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void context_reset(void)
|
static void context_reset(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Context reset!\n");
|
fprintf(stderr, "Context reset!\n");
|
||||||
init_gl_proc();
|
rglgen_resolve_symbols(hw_render.get_proc_address);
|
||||||
compile_program();
|
compile_program();
|
||||||
setup_vao();
|
setup_vao();
|
||||||
}
|
}
|
||||||
|
19
libretro-test-gl/rglgen.c
Normal file
19
libretro-test-gl/rglgen.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "rglgen.h"
|
||||||
|
#include "glsym.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void rglgen_resolve_symbols_custom(rglgen_proc_address_t proc,
|
||||||
|
const struct rglgen_sym_map *map)
|
||||||
|
{
|
||||||
|
for (; map->sym; map++)
|
||||||
|
{
|
||||||
|
rglgen_func_t func = proc(map->sym);
|
||||||
|
memcpy(map->ptr, &func, sizeof(func));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void rglgen_resolve_symbols(rglgen_proc_address_t proc)
|
||||||
|
{
|
||||||
|
rglgen_resolve_symbols_custom(proc, rglgen_symbol_map);
|
||||||
|
}
|
||||||
|
|
47
libretro-test-gl/rglgen.h
Normal file
47
libretro-test-gl/rglgen.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#ifndef RGLGEN_H__
|
||||||
|
#define RGLGEN_H__
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_EGL
|
||||||
|
#include <EGL/egl.h>
|
||||||
|
#include <EGL/eglext.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(IOS)
|
||||||
|
#include <OpenGLES/ES2/gl.h>
|
||||||
|
#include <OpenGLES/ES2/glext.h>
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
#include <OpenGL/gl.h>
|
||||||
|
#include <OpenGL/glext.h>
|
||||||
|
#elif defined(HAVE_PSGL)
|
||||||
|
#include <PSGL/psgl.h>
|
||||||
|
#include <PSGL/psglu.h>
|
||||||
|
#include <GLES/glext.h>
|
||||||
|
#elif defined(HAVE_OPENGL_MODERN)
|
||||||
|
#include <GL3/gl3.h>
|
||||||
|
#include <GL3/gl3ext.h>
|
||||||
|
#elif defined(HAVE_OPENGLES2)
|
||||||
|
#include <GLES2/gl2.h>
|
||||||
|
#include <GLES2/gl2ext.h>
|
||||||
|
#elif defined(HAVE_OPENGLES1)
|
||||||
|
#include <GLES/gl.h>
|
||||||
|
#include <GLES/glext.h>
|
||||||
|
#else
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glext.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct rglgen_sym_map;
|
||||||
|
|
||||||
|
typedef void (*rglgen_func_t)(void);
|
||||||
|
typedef rglgen_func_t (*rglgen_proc_address_t)(const char*);
|
||||||
|
void rglgen_resolve_symbols(rglgen_proc_address_t proc);
|
||||||
|
void rglgen_resolve_symbols_custom(rglgen_proc_address_t proc,
|
||||||
|
const struct rglgen_sym_map *map);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user