I want to add the command-line option --software-rendering
to my application which switches to the MESA opengl32.dll found in a subfolder (e.g. mesa\opengl32.dll
). How can I switch to this dll programmatically?
So far I know that when I move the opengl32.dll to my main folder, the rendering uses this one, but I want it to be loaded depending on the command-line option
The only clean solution is loading the
opengl32.dll
usingLoadLibrary
instead of linking it hard to your program. Then before callingLoadLibrary
you can define the search path, where to look for the DLL, or even pass an absolute path. The downside is, that if usingLoadLibrary
every of the DLLs exported symbols must be retrieved manually usingGetProcAddress
. The good news is, that the GL loader generated by glLoadGen does exactly that; it usesGetModuleHandle
to reference whateveropengl32.dll
has been loaded into the process and usesGetProcAddress
on the regular OpenGL functions. Furthermore it will also do all the extension loading as well.