Initial support for -Dgl-debug
This commit is contained in:
@@ -1859,6 +1859,10 @@ class NativeGLRenderContext {
|
|||||||
object = __extensionObjectConstructors.get (name) ();
|
object = __extensionObjectConstructors.get (name) ();
|
||||||
__extensionObjects.set (name, object);
|
__extensionObjects.set (name, object);
|
||||||
|
|
||||||
|
#if (lime_cffi && lime_opengl && !macro)
|
||||||
|
NativeCFFI.lime_gl_get_extension (name);
|
||||||
|
#end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
|
|||||||
@@ -18,6 +18,10 @@
|
|||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef APIENTRY
|
||||||
|
#define APIENTRY GLAPIENTRY
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef LIME_SDL
|
#ifdef LIME_SDL
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -36,6 +40,8 @@ namespace lime {
|
|||||||
void* OpenGLBindings::eglHandle = 0;
|
void* OpenGLBindings::eglHandle = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef void (APIENTRY * GL_DebugMessageCallback_Func)(GLDEBUGPROC, const void *);
|
||||||
|
GL_DebugMessageCallback_Func glDebugMessageCallback_ptr = 0;
|
||||||
|
|
||||||
std::map<GLObjectType, std::map <GLuint, value> > glObjects;
|
std::map<GLObjectType, std::map <GLuint, value> > glObjects;
|
||||||
std::map<value, GLuint> glObjectIDs;
|
std::map<value, GLuint> 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);
|
puts (message);
|
||||||
|
|
||||||
@@ -1150,38 +1156,46 @@ namespace lime {
|
|||||||
|
|
||||||
value lime_gl_get_extension (HxString name) {
|
value lime_gl_get_extension (HxString name) {
|
||||||
|
|
||||||
void *result = 0;
|
if (!glDebugMessageCallback_ptr && strcmp (name.__s, "KHR_debug") == 0) {
|
||||||
|
|
||||||
#ifdef LIME_SDL
|
|
||||||
result = SDL_GL_GetProcAddress (name.__s);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
|
|
||||||
static bool init = false;
|
glDebugMessageCallback_ptr = (GL_DebugMessageCallback_Func)SDL_GL_GetProcAddress ("glDebugMessageCallback");
|
||||||
static vkind functionKind;
|
|
||||||
|
|
||||||
if (!init) {
|
if (!glDebugMessageCallback_ptr) {
|
||||||
|
|
||||||
if (strcmp (name.__s, "KHR_debug") == 0) {
|
glDebugMessageCallback_ptr = (GL_DebugMessageCallback_Func)SDL_GL_GetProcAddress ("glDebugMessageCallbackKHR");
|
||||||
|
|
||||||
#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");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 ();
|
return alloc_null ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user