Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add macro guards for OpenGL <=1.3 function prototypes #10617

Merged
merged 1 commit into from
Oct 12, 2024

Conversation

Semphriss
Copy link
Contributor

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 types

They 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

- `#define SDL_OPENGL_1_NO_PROTOTYPES` to hide function prototypes
- `#define SDL_OPENGL_1_FUNCTION_TYPEDEFS` to add PFNGL*PROC function types
@icculus icculus merged commit 05c53b5 into libsdl-org:main Oct 12, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Macro option to hide OpenGL <=1.3 function definitions in SDL_opengl.h?
2 participants