#42 Improve GL_{AMD/ARB}_debug_output

1.10.1
pending
Nigel Stewart
None
7
2014-08-03
2011-01-25
alexbolz
No

Currently it is not possible to use GL_ARB_debug_output with a callback function
in a satisfactory (and portable) way. Consider a class wrapping the callback function
implemented in it's own compilation unit. This class would have a static member function

static APIENTRY callback(arguments...)

Now after including <glew.h> APIENTRY is not defined (on windows platforms only
if <windows.h> was not included before). Just using

ifndef APIENTRY

define APIENTRY

endif

to fix the problem is not enough on windows platforms.

But APIENTRY is defined in glew.h at the beginning and a lot of preprocessor directives
are used to ensure that this is properly defined on windows platforms and at the end care is
taken to undef APIENTRY

To get the extension work without any additional code modification I would suggest
replacing APIENTRY in the definitions of GLDEBUGPROCAMD and GLDEBUGPROCARB to
GLAPIENTRY (which should be consistent with the specs), defining GLAPIENTRY in <glew.h>
in the first place instead of APIENTRY and then using

ifndef APIENTRY

define GLEW_APIENTRY_DEFINED

define APIENTRY GLAPIENTRY

endif

to define APIENTRY. This way APIENTRY can safely be undefined at the end of glew.h:

ifdef GLEW_APIENTRY_DEFINED

undef GLEW_APIENTRY_DEFINED

undef APIENTRY

endif

and we can leave GLAPIENTRY as it is and define the callback function like

static GLAPIENTRY callback(arguments...)

with the correct calling convention. This should also be compatible with the fix for
BUG-ID 2544715 but I must admit that I have not tested this approach yet...

Discussion

  • alexbolz
    alexbolz
    2011-01-27

    I thought about that too, but there might be a small problem:

    These headers include windows.h at the beginning to get the definition for APIENTRY,
    so including windows.h after glext.h has no effect.
    Since glew does not include windows.h and windows.h unconditionally defines APIENTRY,
    this redefinition might be a problem with build systems which treat warnings as errors.

    I think it would be fine if glew.h includes windows.h to just get APIENTRY defined, since
    (almost) every windows program using glew will sooner or later include windows.h.

     
  • Nigel Stewart
    Nigel Stewart
    2011-04-07

    I'd be reluctant to #include windows.h. But I see some merit in leaving APIENTRY defined unless glew.h needed to define it.

     
  • Nigel Stewart
    Nigel Stewart
    2014-02-20

    I think this is resolved in bug #227.
    Use GLAPIENTRY instead of APIENTRY for debug procs on Windows.

     


Anonymous


Cancel   Add attachments