On Monday, 22 May 2017 at 16:37:51 UTC, Andrew Edwards wrote:

Specific context at the following links:


https://github.com/glfw/glfw/blob/66ff4aae89572419bb130c5613798e34d7521fc7/deps/glad/glad.h#L24-L48

APIENTRY is typically defined in Windows headers to set the stdcall calling convention (which is where we get extern(Windows) in D) in function declarations. You'll find it all over Win32 API headers. In this case, since OpenGL uses it on Windows, glad is checking if it's defined and, if not, defining it as empty for non-Windows platforms. That way it can be used in the function signatures glad generates on every platform.

Generally, any functions in the Windows-specific sections with APIENTRY in their declarations need to be declared in D as extern(Windows). APIENTRY itself can be left out of the D binding.


https://github.com/glfw/glfw/blob/66ff4aae89572419bb130c5613798e34d7521fc7/deps/glad/glad.h#L57-L81


Again, GLAPI is a Windows-specific thing. A lot of libraries that support compiling to a DLL define something similar on Windows. Function declarations need to be exported when compiling a DLL and imported when compiling programs that use the DLL, so the FOOAPI technique is used to apply the correct attribute to each declaration. On other platforms, FOOAPI is defined as empty.

You can safely ignore this one, unless you're planning to do a pure D port (not binding) of the library and intend to compile as a shared lib. It tells you which functions need to be exported from the shared lib to match the C API.

https://github.com/glfw/glfw/blob/66ff4aae89572419bb130c5613798e34d7521fc7/deps/glad/glad.h#L88-L124

This one is a guard that makes sure that everything in the #ifndef GLEXT_64_TYPES_DEFINED block is only imported once. It's explained in the comment:

/* This code block is duplicated in glxext.h, so must be protected */

By defining GLEXT_64_TYPES_DEFINED, if glxext.h after, then it presumably also has a #ifndef GLEXT_64_TYPES_DEFINED block and will not redefine those types.

This one can also be ignored on the D side.


Reply via email to