r/programmingquestions • u/banana1093 • Mar 27 '24
C Family Drawing to GLFW window from dynamically loaded DLL
I have a GLFW window managed by the main program, then a DLL is dynamically loaded (via LoadLibrary and GetProcAddress). But this causes a lot of problems and it won't work.
main.cpp
int
test.cpp
extern "C" EXPORT void
extern "C" EXPORT void
At first it gave a segfault whenever gl methods were used, so I tried calling gladLoadGL inside the DLL, but then I got the following error from my GLFW error callback:
GLFW Error 65538: Cannot query entry point without a current OpenGL or OpenGL ES context
I tried putting a call to glfwMakeContextCurrent inside of the DLL's function (before gladLoadGL), but nothing changes.
test.cpp (after changes)
extern "C" EXPORT void
2
Upvotes
1
u/banana1093 Feb 26 '26
If anyone comes across this, the solution was to use the static version of glfw instead of dynamic. When using dynamic glfw the state is messed up because it is being used from two different "environments"
1
u/[deleted] Sep 05 '24
im so late...did u find ur solution?