diff --git a/lime/_backend/native/NativeGLRenderContext.hx b/lime/_backend/native/NativeGLRenderContext.hx index c9b672eb7..a52d41ad3 100644 --- a/lime/_backend/native/NativeGLRenderContext.hx +++ b/lime/_backend/native/NativeGLRenderContext.hx @@ -1859,6 +1859,10 @@ class NativeGLRenderContext { object = __extensionObjectConstructors.get (name) (); __extensionObjects.set (name, object); + #if (lime_cffi && lime_opengl && !macro) + NativeCFFI.lime_gl_get_extension (name); + #end + } return object; diff --git a/project/src/graphics/opengl/OpenGLBindings.cpp b/project/src/graphics/opengl/OpenGLBindings.cpp index e47e80457..8e5b2bbdd 100644 --- a/project/src/graphics/opengl/OpenGLBindings.cpp +++ b/project/src/graphics/opengl/OpenGLBindings.cpp @@ -18,6 +18,10 @@ #include #endif +#ifndef APIENTRY +#define APIENTRY GLAPIENTRY +#endif + #ifdef LIME_SDL #include #endif @@ -36,6 +40,8 @@ namespace lime { void* OpenGLBindings::eglHandle = 0; #endif + typedef void (APIENTRY * GL_DebugMessageCallback_Func)(GLDEBUGPROC, const void *); + GL_DebugMessageCallback_Func glDebugMessageCallback_ptr = 0; std::map > glObjects; std::map glObjectIDs; @@ -183,7 +189,7 @@ namespace lime { } - void GLAPIENTRY gl_debug_callback (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam) { + void APIENTRY gl_debug_callback (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, GLvoid *userParam) { puts (message); @@ -1150,38 +1156,46 @@ namespace lime { value lime_gl_get_extension (HxString name) { - void *result = 0; - - #ifdef LIME_SDL - result = SDL_GL_GetProcAddress (name.__s); - #endif - - if (result) { + if (!glDebugMessageCallback_ptr && strcmp (name.__s, "KHR_debug") == 0) { - static bool init = false; - static vkind functionKind; + glDebugMessageCallback_ptr = (GL_DebugMessageCallback_Func)SDL_GL_GetProcAddress ("glDebugMessageCallback"); - if (!init) { + if (!glDebugMessageCallback_ptr) { - if (strcmp (name.__s, "KHR_debug") == 0) { - - #ifdef LIME_GLES - glDebugMessageCallbackKHR ((GLDEBUGPROCARB)gl_debug_callback, NULL); - #elif !defined(HX_MACOS) - glDebugMessageCallback ((GLDEBUGPROCARB)gl_debug_callback, NULL); - #endif - - } - - init = true; - kind_share (&functionKind, "function"); + glDebugMessageCallback_ptr = (GL_DebugMessageCallback_Func)SDL_GL_GetProcAddress ("glDebugMessageCallbackKHR"); } - return alloc_abstract (functionKind, result); + if (glDebugMessageCallback_ptr) { + + glDebugMessageCallback_ptr ((GLDEBUGPROCARB)gl_debug_callback, NULL); + + } } + // void *result = 0; + + // #ifdef LIME_SDL + // result = SDL_GL_GetProcAddress (name.__s); + // #endif + + // if (result) { + + // static bool init = false; + // static vkind functionKind; + + // if (!init) { + + // init = true; + // kind_share (&functionKind, "function"); + + // } + + // return alloc_abstract (functionKind, result); + + // } + return alloc_null (); }