r/programminghelp • u/banana1093 • Mar 27 '24
C++ 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
1
Upvotes
2
u/Furry_69 Mar 27 '24
I don't think you ever actually create a window, so no OpenGL context is ever created.
1
u/banana1093 Feb 26 '26
The solution was to switch to building glfw statically instead of dynamically