cinder / Cinder

Cinder is a community-developed, free and open source library for professional-quality creative coding in C++.
http://libcinder.org
Other
5.28k stars 939 forks source link

Update OpenGL loader to one generated by glad 0.1.36 #2332

Open totalgee opened 1 week ago

totalgee commented 1 week ago
totalgee commented 1 week ago

I was actually intending to get rid of this build warning, that has annoyed me for ages with MSVC:

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition
1>(compiling source file '../../src/cinder/gl/wrapper.cpp')
1>C:\Users\holag\Documents\Work\Immersence\immr-root\cinder\include\glad\glad.h(518,1):
1>see previous definition of 'APIENTRY'

Unfortunately after going down the rabbit hole here of updating to the latest glad wrapper -- the last update was 071e776 in early 2020 -- I realized (too late) that what was needed was actually glad2 ...the latest version of glad (v1) doesn't fix the APIENTRY warning, so this PR isn't strictly necessary to accept (it doesn't hurt, but also doesn't add much new, except for a few more extensions ;-).

I spent some time trying to integrate the glad2-generated loader, but it has as slightly different API and I got a bit sidetracked trying to find a cross-platform Cinder-y way to get the "address loader" function, which needs to be passed to its initialization functions. Usually it's wglGetProcAddress() on Windows, or can be glfwGetProcAddress() on any platform where we know we're using GLFW. I wasn't sure what would be the most Cinder-friendly way to do it, especially in places like src/cinder/gl/EnvironmentCore.cpp, for example, where we don't know about the Windows DC, or whether we're using GLFW, WGL, GLX, etc. Any suggestions from other maintainers on a good way to do this would be appreciated, and then maybe I can finish the update to glad2 at some point!

Thanks.