Original Post
Yo,
I''ve been following the ''Striving for Graphics API Independence'' series of articles, and I''ve decided to implement a wrapper of my own, following the factory design. However, I''ve run into problems with calling GetProcAddress on GCC Dlls.
I import a custom made .def file, containing two function names, CreateRenderInterface and DestroyRenderInterface into the project. The dll and lib compile well, but the test project doesn''t.
Here''s the relavent code:
Relevant source:
extern "C"
{
ZRESULT CreateRenderInterface(RenderInterface **pInterface)
{
if (!*pInterface)
{
*pInterface=new OGLRenderer();
return Z_OK;
}
return Z_FAIL;
}
void DestroyRenderInterface(RenderInterface **pInterface)
{
if (!*pInterface)
{
return;
}
delete *pInterface;
*pInterface=NULL;
}
}
The definiton''s of the functions in a header file
extern "C"
{
ZRESULT CreateRenderInterface(RenderInterface** pInterface);
typedef ZRESULT (*CREATERENDERINTERFACE)(RenderInterface** pInterface);
void DestroyRenderInterface(RenderInterface** pInterface);
typedef void (*DESTROYRENDERINTERFACE)(RenderInterface** pInterface);
}
and the code to load the DLL
ZRESULT RenderFactory::InitInterface(API a)
{
if (a==ZIN_API_OGL)
{
//Load GL libary here
mModule=LoadLibraryEx("GL/GLRenderer.dll",NULL,0);
if (mModule==NULL)
{
MessageBox(NULL,"GL Dll could not be loaded","!",MB_OK | MB_ICONSTOP);
return Z_FAIL;
}
}
if (a==ZIN_API_D3D)
{
mModule=LoadLibraryEx("D3D/D3DRenderer.dll",NULL,0);
if (mModule==NULL)
{
MessageBox(NULL,"D3D dll could not be loaded","!",MB_OK | MB_ICONSTOP);
return Z_FAIL;
}
}
CREATERENDERINTERFACE CreateInterface=NULL;
CreateInterface=(CREATERENDERINTERFACE)GetProcAddress(mModule,"CreateRenderInterface");
if (CreateInterface==NULL)
{
MessageBox(NULL,"Function address could not be retrieved","!",MB_OK | MB_ICONSTOP);
return Z_FAIL;
}
ZRESULT zr=CreateInterface(&mInterface);
if (zr!=Z_OK)
{
MessageBox(NULL,"Render interface could not be created","!",MB_OK | MB_ICONSTOP);
return Z_FAIL;
}
return Z_OK;
}
void RenderFactory::DestroyInterface()
{
DESTROYRENDERINTERFACE DestroyInterface;
DestroyInterface=(DESTROYRENDERINTERFACE)GetProcAddress(mModule,"DestroyRenderInterface");
DestroyInterface(&mInterface);
}
Any ideas on why GetProcAddress fails?
CloudNine