I am trying to port a project from Visual Studio 2003 to Visual Studio 2005. It consists of a number of classes containing OpenGL and CG code. Here is an extract of the original (VS2003) code:
shScene.h:
__nogc class shScene
{
public:
int GPU_InitializeCG();
void GPU_cgErrorCallback();
}
shScene.cpp:
int shScene::GPU_InitializeCG()
{
cgSetErrorCallback( GPU_cgErrorCallback );
}
VS2005 follows the C++ standards more strictly than did VS2003, so I had to modify the function pointers as follows:
int shScene::GPU_InitializeCG()
{
void (shScene::*fnPtr)(void) = &shScene::GPU_cgErrorCallback;
cgSetErrorCallback( fnPtr );
}
Although the function pointer itself works fine, I get an error trying to pass it into cgSetErrorCallback:
“error C2664: ‘cgSetErrorCallback’ : cannot convert parameter 1 from ‘void (__thiscall shScene::* )(void)’ to ‘CGerrorCallbackFunc’”
I can’t figure out how to correct this error. Does anybody have any suggestions?
Thanks!