libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
10.14k stars 1.85k forks source link

SDL_opengl.h being no-op on iOS is unintuitive #11489

Open sfan5 opened 4 days ago

sfan5 commented 4 days ago

Problem

When you include SDL_opengl.h while targeting iOS, it will silently just not define anything at all: https://github.com/libsdl-org/SDL/blob/e027b85cc457556071cbb2f3f1bcf8803c1bc001/include/SDL3/SDL_opengl.h#L33-L35 The API user, who expected this file to define OpenGL stuff, will be (momentarily) confused on why their code does not compile.

Possible solutions

  1. Notwithstanding missing platform support - if the user wants the GL symbols, let him have them.

  2. Use #warning or even #error to tell the API user that including this file on iOS is not meant to be.

I personally favor option 1. If you want to write code that works on both OpenGL and OpenGL ES, it is not unreasonable to include the desktop GL headers and compensate for the differences manually. This doesn't work if the header is gated behind a platform check. (Admittedly this is a niche case, since for this to work you basically need to write your own GL loader.)

Semphriss commented 1 day ago

FWIW, I made #10617 a while ago; the macros might be helpful here, as they allow making systems that don't require linking to any OpenGL library.