[Solved] Function Pointers stored in global variables get set to 0 when entering function, and get back to previous state when exiting function


if you write in header file

static PFNGLGETERRORPROC                           glGetError;

every c/cpp have own private copy of glGetError and it not conflict with other because it static – so different cpp files use different versions of glGetError – in one cpp unit you init one version and it !=0, when you enter to another cpp unit – you worked with uninit version , ant it 0. when you return to original unit – again != 0;
so problem with bad declaration.

you need declare it as

extern PFNGLGETERRORPROC glGetError;

in .h file and as

PFNGLGETERRORPROC glGetError;

in any single cpp. file.

or declare it as

__declspec(selectany) PFNGLGETERRORPROC glGetError;

2

solved Function Pointers stored in global variables get set to 0 when entering function, and get back to previous state when exiting function