Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions binding/egl_context_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,12 @@ void EGLContextWrapper::BindProcAddresses() {
glViewport =
reinterpret_cast<PFNGLVIEWPORTPROC>(eglGetProcAddress("glViewport"));

#if DEBUG
// Debug specific
glDebugMessageCallback = reinterpret_cast<PFNGLDEBUGMESSAGECALLBACKPROC>(
eglGetProcAddress("glDebugMessageCallback"));
#endif

// ANGLE specific
glRequestExtensionANGLE = reinterpret_cast<PFNGLREQUESTEXTENSIONANGLEPROC>(
eglGetProcAddress("glRequestExtensionANGLE"));
Expand Down
6 changes: 6 additions & 0 deletions binding/egl_context_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "angle/include/GLES2/gl2.h"
#include "angle/include/GLES2/gl2ext.h"
#include "angle/include/GLES3/gl3.h"
#include "angle/include/GLES3/gl32.h" // TODO - debug this?

#include <iostream>
#include <memory>
Expand Down Expand Up @@ -228,6 +229,11 @@ class EGLContextWrapper {
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
PFNGLVIEWPORTPROC glViewport;

#if DEBUG
// Debug specific
PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback;
#endif

// ANGLE specific
PFNGLREQUESTEXTENSIONANGLEPROC glRequestExtensionANGLE;

Expand Down
16 changes: 16 additions & 0 deletions binding/webgl_rendering_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,17 @@ static napi_status GetArrayLikeBuffer(napi_env env, napi_value array_like_value,
return napi_invalid_arg;
}

#if DEBUG
void DebugMessageCallback(GLenum source, GLenum type, GLuint id,
GLenum severity, GLsizei length,
const GLchar *message, const void *userParam) {
fprintf(stderr,
"GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n",
(type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""), type, severity,
message);
}
#endif

napi_ref WebGLRenderingContext::constructor_ref_;

WebGLRenderingContext::WebGLRenderingContext(napi_env env)
Expand All @@ -391,6 +402,11 @@ WebGLRenderingContext::WebGLRenderingContext(napi_env env)
return;
}
alloc_count_ = 0;

#if DEBUG
eglContextWrapper_->glEnable(GL_DEBUG_OUTPUT);
eglContextWrapper_->glDebugMessageCallback(DebugMessageCallback, 0);
#endif
}

WebGLRenderingContext::~WebGLRenderingContext() {
Expand Down