[Android] Support grabbing OpenGL extensions and a function for checking for support.

This commit is contained in:
Ryan Houdek 2013-12-28 01:04:52 -06:00
parent e04edd89cc
commit d8b7f4d73f
3 changed files with 27 additions and 1 deletions

View File

@ -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 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 glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat* value);
GL_APICALL void GL_APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); 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 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 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); GL_APICALL void GL_APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params);

View File

@ -5,7 +5,9 @@
#include "DriverDetails.h" #include "DriverDetails.h"
#include "GLFunctions.h" #include "GLFunctions.h"
#include "Log.h" #include "Log.h"
#include <dlfcn.h> #include <dlfcn.h>
#include <unordered_map>
#ifdef USE_GLES3 #ifdef USE_GLES3
PFNGLMAPBUFFERRANGEPROC glMapBufferRange; PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
@ -13,6 +15,7 @@ PFNGLUNMAPBUFFERPROC glUnmapBuffer;
PFNGLBINDBUFFERRANGEPROC glBindBufferRange; PFNGLBINDBUFFERRANGEPROC glBindBufferRange;
PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
PFNGLGETSTRINGIPROC glGetStringi;
PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
@ -49,6 +52,8 @@ PFNGLGENQUERIESPROC glGenQueries;
namespace GLFunc namespace GLFunc
{ {
void *self; void *self;
std::unordered_map<std::string, bool> _extensions;
void LoadFunction(const char *name, void **func) void LoadFunction(const char *name, void **func)
{ {
#ifdef USE_GLES3 #ifdef USE_GLES3
@ -67,10 +72,27 @@ namespace GLFunc
#endif #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() void Init()
{ {
self = dlopen(NULL, RTLD_LAZY); self = dlopen(NULL, RTLD_LAZY);
LoadFunction("glGetStringi", (void**)&glGetStringi);
InitExtensions();
LoadFunction("glUnmapBuffer", (void**)&glUnmapBuffer); LoadFunction("glUnmapBuffer", (void**)&glUnmapBuffer);
LoadFunction("glBeginQuery", (void**)&glBeginQuery); LoadFunction("glBeginQuery", (void**)&glBeginQuery);
LoadFunction("glEndQuery", (void**)&glEndQuery); LoadFunction("glEndQuery", (void**)&glEndQuery);

View File

@ -10,8 +10,10 @@ typedef GLvoid* (*PFNGLMAPBUFFERPROC) (GLenum target, GLenum access);
typedef GLvoid* (*PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield 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 void (*PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
typedef GLboolean (*PFNGLUNMAPBUFFERPROC) (GLenum target); 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); typedef void (*PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
// VAOS // VAOS
typedef void (*PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays); typedef void (*PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays);
typedef void (*PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint* arrays); typedef void (*PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint* arrays);
@ -63,6 +65,7 @@ extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange; extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange;
extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
extern PFNGLGETSTRINGIPROC glGetStringi;
extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
@ -95,5 +98,6 @@ extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding;
namespace GLFunc namespace GLFunc
{ {
void Init(); void Init();
bool SupportsExt(std::string ext);
} }
#endif #endif