PDA

View Full Version : OpenGL.dll and LoadLibrary



12-14-2000, 10:12 AM
When I call LoadLibrary with "opengl.dll" as parameter, it always returns error code 1114 => Initialization of the opengl.dll failed.

What can I do to load the dll with LoadLibrary correctly?

Sansus
12-14-2000, 02:01 PM
Firstly, the name of the DLL is not opengl.dll, but opengl32.dll.
Secondly, why do you use LoadLibrary? your program will load it automatically, if it uses an OpenGL function, uses the opengl32.lib and is located at:
c:\windows
c:\windows\system
or the directory of your executable.

softland_gh
12-14-2000, 02:11 PM
Which language do you use? C/C++ or Delphi?

12-14-2000, 08:42 PM
I use C++...

I wanna use LoadLibary to make a proxy dll.

softland_gh
12-15-2000, 01:13 AM
I don't know what do you mean by proxy dll, but since you use C++, I don't think you need to use LoadLibrary, because you can add include directives to automatically use the OpenGL library:

#include "gl/gl.h"
#include "gl/glu.h"
#include "gl/glaux.h"

However if you insist, you can write:

HINSTANCE Handle = LoadLibrary("opengl32.dll");

Then, to find the entry address of every function you must use the function GetProcAddress, and pass to it the handle you got and the name of the procedure. This way you'll get a CALLBACK function that you can use. I can't help you with CALLBACK functions because I am a Delphi programmer and we have Procedural types instead of CALLBACK functions which differ in declaration.

GA

12-16-2000, 11:58 AM
"Explicit" linking (using LoadLibrary()) has advantages over "implicit" linking (linking with the stub library):

1> It makes it so that the client of the library doesn't die with an ugly messagebox at launch in the case the library is unavailable.

2> It doesn't load libraries it does not need, wasting computer resources. For instance, an engine which supports both D3D and OpenGL benefits from explicit linking because it only needs toload one or the other library at run time. With implicit linking, both libraries get loaded, taking more time and memory.

There's a section in the MSVC docs about the advantages and disadvantages of each which delves into more detail.