Ok, I know I shouldn’t post this message here, but here it goes…
I’m programming in VS6 and I have created a project here I’ve included all my .cpp and .h. If I would use OpenGL in one of the .cpp or .h I would include “gl/gl.h”. Of course the project was linked with the opengl32.lib. But this way I can’t link to whatever dll I want… So…
I’ve created two files: “OpenGL.cpp” and “OpenGL.h”:
=>In “OpenGL.h” I have included:
typedef unsigned int GLenum;
typedef unsigned char GLboolean;
…
#define GL_VERSION_1_1 1
#define GL_ACCUM 0x0100
…
=>created the prototypes:
typedef void (WINAPI* pfnglAccum) (GLenum op, GLfloat value);
typedef void (WINAPI* pfnglAlphaFunc) (GLenum func, GLclampf ref);
…
=>and the functions pointers:
#ifdef __cplusplus
extern “C” {
#endif
extern pfnglAccum glAccum;
extern pfnglAlphaFunc glAlphaFunc;
…
#ifdef __cplusplus
}
#endif
=>and two functions to load and unload everything:
bool OpenGL_Load(char *pszDllName);
bool OpenGL_Unload(void);
and replaced the “#include gl/gl.h” in every file I use with “OpenGL.h”, and took of “opengl32.lib”. My “OpenGL.cpp” file looks like this:
#include <windows.h>
#include “OpenGL.h”
static HMODULE OpenGL_DLL=NULL;
pfnglAccum glAccum;
pfnglAlphaFunc glAlphaFunc;
…
#define GETADDR(type, var, name) var = (type)GetProcAddress(OpenGL_DLL, name)
static void SetProcs(void)
{
GETADDR(pfnglAccum,glAccum,“glAccum”);
GETADDR(pfnglAlphaFunc,glAlphaFunc,“glAlphaFunc”);
…
}
bool OpenGL_Load(char *pszDllName)
{
if (OpenGL_DLL!=NULL) return false;
OpenGL_DLL=LoadLibrary(pszDllName);
if (OpenGL_DLL==NULL) return false;
SetProcs();
return true;
}
bool OpenGL_Unload(void)
{
if (OpenGL_DLL==NULL) return false;
FreeLibrary(OpenGL_DLL);
OpenGL_DLL=NULL;
return true;
}
Now everything compiles and links correctly…but when I run the .exe:
“The instruction at “0x00000000” referenced memory at “0x00000000”. …”
when I debug it it even doesn’t enter WinMain…
You see my dilema… What am I doing wrong?
And should I replace the default OpenGL32.dll by one that suports 1.2?
Thanks for any help…