Skip to content

Conversation

@SanchesS
Copy link
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')

char *argv[1] = {""};

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

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().


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

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.

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

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.

3 participants