diff options
-rw-r--r-- | include/mbgl/platform/gl.hpp | 27 | ||||
-rw-r--r-- | src/platform/gl.cpp | 8 |
2 files changed, 22 insertions, 13 deletions
diff --git a/include/mbgl/platform/gl.hpp b/include/mbgl/platform/gl.hpp index 02fd64b9a1..73d04b7a9e 100644 --- a/include/mbgl/platform/gl.hpp +++ b/include/mbgl/platform/gl.hpp @@ -21,6 +21,7 @@ #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> #else + #define GL_GLEXT_PROTOTYPES #include <GL/gl.h> #include <GL/glext.h> #endif @@ -72,18 +73,18 @@ namespace gl { #define GL_TEXTURE 0x1702 #define GL_RENDERBUFFER 0x8D41 #define GL_FRAMEBUFFER 0x8D40 -typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -typedef void (APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, void **params); -typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); -typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); -typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); -typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); -typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); -typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (* GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam); +typedef void (* PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (* PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (* PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (* PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (* PFNGLGETPOINTERVPROC) (GLenum pname, void **params); +typedef void (* PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (* PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (* PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (* PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (* PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (* PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); extern PFNGLDEBUGMESSAGECONTROLPROC DebugMessageControl; extern PFNGLDEBUGMESSAGEINSERTPROC DebugMessageInsert; extern PFNGLDEBUGMESSAGECALLBACKPROC DebugMessageCallback; @@ -95,7 +96,9 @@ extern PFNGLOBJECTLABELPROC ObjectLabel; extern PFNGLGETOBJECTLABELPROC GetObjectLabel; extern PFNGLOBJECTPTRLABELPROC ObjectPtrLabel; extern PFNGLGETOBJECTPTRLABELPROC GetObjectPtrLabel; +void debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam); +#define GL_VERTEX_ARRAY_BINDING 0x85B5 typedef void (* PFNGLBINDVERTEXARRAYPROC) (GLuint array); typedef void (* PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint* arrays); typedef void (* PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays); diff --git a/src/platform/gl.cpp b/src/platform/gl.cpp index c9f76bf1d6..bec1136bb0 100644 --- a/src/platform/gl.cpp +++ b/src/platform/gl.cpp @@ -1,4 +1,5 @@ #include <mbgl/platform/gl.hpp> +#include <mbgl/platform/log.hpp> #include <iostream> @@ -18,6 +19,10 @@ PFNGLGETOBJECTLABELPROC GetObjectLabel; PFNGLOBJECTPTRLABELPROC ObjectPtrLabel; PFNGLGETOBJECTPTRLABELPROC GetObjectPtrLabel; +void debug_callback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam) { + //mbgl::Error(mbgl::Event::OpenGL) +} + PFNGLBINDVERTEXARRAYPROC BindVertexArray = nullptr; PFNGLDELETEVERTEXARRAYSPROC DeleteVertexArrays = nullptr; PFNGLGENVERTEXARRAYSPROC GenVertexArrays = nullptr; @@ -39,9 +44,10 @@ void _CHECK_GL_ERROR(const char *cmd, const char *file, int line) { case GL_INVALID_VALUE: error = "INVALID_VALUE"; break; case GL_OUT_OF_MEMORY: error = "OUT_OF_MEMORY"; break; case GL_INVALID_FRAMEBUFFER_OPERATION: error = "INVALID_FRAMEBUFFER_OPERATION"; break; + default: error = "(unknown)"; break; } - std::cerr << "GL_" << error.c_str() << " - " << file << ":" << line << std::endl; + mbgl::Log::Error(mbgl::Event::OpenGL, "GL_%s(0x%04X) - %s:%i", error.c_str(), file, line, err); exit(1); } } |