Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Android] Support grabbing OpenGL extensions and a function for check…
…ing for support.
  • Loading branch information
Sonicadvance1 committed Dec 28, 2013
1 parent e04edd8 commit d8b7f4d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Externals/GLES3/GLES3/gl3.h
Expand Up @@ -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);
Expand Down
22 changes: 22 additions & 0 deletions Source/Core/VideoBackends/OGL/Src/GLFunctions.cpp
Expand Up @@ -5,14 +5,17 @@
#include "DriverDetails.h"
#include "GLFunctions.h"
#include "Log.h"

#include <dlfcn.h>
#include <unordered_map>

#ifdef USE_GLES3
PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
PFNGLUNMAPBUFFERPROC glUnmapBuffer;
PFNGLBINDBUFFERRANGEPROC glBindBufferRange;

PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
PFNGLGETSTRINGIPROC glGetStringi;

PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
Expand Down Expand Up @@ -49,6 +52,8 @@ PFNGLGENQUERIESPROC glGenQueries;
namespace GLFunc
{
void *self;
std::unordered_map<std::string, bool> _extensions;

void LoadFunction(const char *name, void **func)
{
#ifdef USE_GLES3
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/VideoBackends/OGL/Src/GLFunctions.h
Expand Up @@ -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);
Expand Down Expand Up @@ -63,6 +65,7 @@ extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange;

extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
extern PFNGLGETSTRINGIPROC glGetStringi;

extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
Expand Down Expand Up @@ -95,5 +98,6 @@ extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding;
namespace GLFunc
{
void Init();
bool SupportsExt(std::string ext);
}
#endif

0 comments on commit d8b7f4d

Please sign in to comment.