Skip to content

Add optional debug mode for WebGL calls#1

Open
SanchesS wants to merge 1 commit intomainfrom
codex/add-debug-mode-to-bindgen.js-and-additions.c
Open

Add optional debug mode for WebGL calls#1
SanchesS wants to merge 1 commit intomainfrom
codex/add-debug-mode-to-bindgen.js-and-additions.c

Conversation

@SanchesS
Copy link
Copy Markdown
Owner

Summary

  • add helper macros in additions.c for debug logging
  • invoke the macros after GLUT and GL calls
  • extend bindgen.js so generated wrappers log failures when WEBGL_DEBUG is defined

Testing

  • make test (fails: No rule to make target 'quickjs/qjs.c')

Comment thread additions.c
char *argv[1] = {""};

glutInit(&argc, argv);
DEBUG_GL_CHECK_RAW("glutInit", "%d, %p", argc, argv);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DEBUG_GL_CHECK_RAW("glutInit", "%d, %p", argc, argv);

This call causes segfault, let's remove it. I think this is a little bit early place to call glGetError().

Comment thread additions.c

static void debug_check_error(JSContext *ctx, const char *func, int argc, JSValueConst *argv) {
GLenum err = glGetError();
if (err != GL_NO_ERROR) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (err != GL_NO_ERROR) {
if (err != GL_NO_ERROR || WEBGL_DEBUG > 1) {

Let's make an improvement: allow to specify -DWEBGL_DEBUG=2 for compiler options and get unconditional OpenGL calls log mode.

Comment thread additions.c
#define DEBUG_GL_CHECK_RAW(name, fmt, ...) \
do { \
GLenum err = glGetError(); \
if (err != GL_NO_ERROR) { \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (err != GL_NO_ERROR) { \
if (err != GL_NO_ERROR || WEBGL_DEBUG > 1) { \

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants