Add macro guards for OpenGL <=1.3 function prototypes #10617
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I've added two macros in SDL_opengl.h to help with dynamically loading OpenGL:
#define SDL_OPENGL_1_NO_PROTOTYPES
to hide function prototypes#define SDL_OPENGL_1_FUNCTION_TYPEDEFS
to add PFNGL*PROC function typesThey help avoid clashing names for OpenGL functions up to 1.3 when developers use a different or a custom OpenGL loader.
I've also added the typedefs (PFNGL...PROC) for those functions. Since they seem not to be standard, I made another macro to hide them by default. I created them with gedit 41.0 find-and-replace, with find =
GLAPI ([a-zA-Z0-9 \*]+) GLAPIENTRY (gl[a-zA-Z0-9]+) *\(([^)]+)\);
and replace =typedef \1 (APIENTRYP PFN\U\2\EPROC) (\3);
. This is probably compatible with other regex engines; the least common-looking feature I used is\U
for uppercase and\E
for un-uppercase.I've kept the two macros separate because someone might want to have both the prototypes and the typedefs.
As usual, I'm open to changing the macro names and their structure.
Existing Issue(s)
Closes #10606