From d8b7f4d73f9b2b8ce4a5b74a014bf597296b2bfc Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sat, 28 Dec 2013 01:04:52 -0600 Subject: [PATCH] [Android] Support grabbing OpenGL extensions and a function for checking for support. --- Externals/GLES3/GLES3/gl3.h | 2 +- .../VideoBackends/OGL/Src/GLFunctions.cpp | 22 +++++++++++++++++++ .../Core/VideoBackends/OGL/Src/GLFunctions.h | 4 ++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Externals/GLES3/GLES3/gl3.h b/Externals/GLES3/GLES3/gl3.h index 01cbeaacf7..afee172f9c 100644 --- a/Externals/GLES3/GLES3/gl3.h +++ b/Externals/GLES3/GLES3/gl3.h @@ -996,7 +996,7 @@ GL_APICALL void GL_APIENTRY glClearBufferiv (GLenum buffer, GLint draw GL_APICALL void GL_APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint* value); GL_APICALL void GL_APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat* value); GL_APICALL void GL_APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -GL_APICALL const GLubyte* GL_APIENTRY glGetStringi (GLenum name, GLuint index); +//GL_APICALL const GLubyte* GL_APIENTRY glGetStringi (GLenum name, GLuint index); GL_APICALL void GL_APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); GL_APICALL void GL_APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices); GL_APICALL void GL_APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params); diff --git a/Source/Core/VideoBackends/OGL/Src/GLFunctions.cpp b/Source/Core/VideoBackends/OGL/Src/GLFunctions.cpp index c91908ea11..505326b1ea 100644 --- a/Source/Core/VideoBackends/OGL/Src/GLFunctions.cpp +++ b/Source/Core/VideoBackends/OGL/Src/GLFunctions.cpp @@ -5,7 +5,9 @@ #include "DriverDetails.h" #include "GLFunctions.h" #include "Log.h" + #include +#include #ifdef USE_GLES3 PFNGLMAPBUFFERRANGEPROC glMapBufferRange; @@ -13,6 +15,7 @@ PFNGLUNMAPBUFFERPROC glUnmapBuffer; PFNGLBINDBUFFERRANGEPROC glBindBufferRange; PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; +PFNGLGETSTRINGIPROC glGetStringi; PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; @@ -49,6 +52,8 @@ PFNGLGENQUERIESPROC glGenQueries; namespace GLFunc { void *self; + std::unordered_map _extensions; + void LoadFunction(const char *name, void **func) { #ifdef USE_GLES3 @@ -67,10 +72,27 @@ namespace GLFunc #endif } + bool SupportsExt(std::string ext) + { + return _extensions.find(ext) != _extensions.end(); + } + + void InitExtensions() + { + GLint NumExtension = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &NumExtension); + for (GLint i = 0; i < NumExtension; ++i) + _extensions[std::string((const char*)glGetStringi(GL_EXTENSIONS, i))] = true; + } + void Init() { self = dlopen(NULL, RTLD_LAZY); + LoadFunction("glGetStringi", (void**)&glGetStringi); + + InitExtensions(); + LoadFunction("glUnmapBuffer", (void**)&glUnmapBuffer); LoadFunction("glBeginQuery", (void**)&glBeginQuery); LoadFunction("glEndQuery", (void**)&glEndQuery); diff --git a/Source/Core/VideoBackends/OGL/Src/GLFunctions.h b/Source/Core/VideoBackends/OGL/Src/GLFunctions.h index cbfde1276c..7cdd5476ba 100644 --- a/Source/Core/VideoBackends/OGL/Src/GLFunctions.h +++ b/Source/Core/VideoBackends/OGL/Src/GLFunctions.h @@ -10,8 +10,10 @@ typedef GLvoid* (*PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); typedef GLvoid* (*PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); typedef void (*PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef GLboolean (*PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef GLubyte* (*PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); typedef void (*PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + // VAOS typedef void (*PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays); typedef void (*PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint* arrays); @@ -63,6 +65,7 @@ extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange; extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange; extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; +extern PFNGLGETSTRINGIPROC glGetStringi; extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; @@ -95,5 +98,6 @@ extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding; namespace GLFunc { void Init(); + bool SupportsExt(std::string ext); } #endif