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.dllusingLoadLibraryinstead of linking it hard to your program. Then before callingLoadLibraryyou can define the search path, where to look for the DLL, or even pass an absolute path. The downside is, that if usingLoadLibraryevery 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 usesGetModuleHandleto reference whateveropengl32.dllhas been loaded into the process and usesGetProcAddresson the regular OpenGL functions. Furthermore it will also do all the extension loading as well.