Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Austrian Coder

Maybe simple function pointer problem

This topic is 5475 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I am working on a extensionmanager for opengl. I want this feature: gExtensionManager->RegisterSetupFunction("GL_ARB_MegaCoolEffect", SetupARB_MegaCoolEffect); And then gExtensionManager->IsExtensionSupported("GL_ARB_MegaCoolEffect"); The last call checks if the extension is supported, when yes it looks if there is a function to call when extension is found - the Setupfunction for the extension. An example for a setupfunction:
	// ==================================

	// example setup function

	void CExtensionManager::SetupMultitexturing()
		// multitexture extension

		glMultiTexCoord1dARB	= (PFNGLMULTITEXCOORD1DARBPROC)		GetProcAdress("glMultiTexCoord1dARB");
		glMultiTexCoord1dvARB	= (PFNGLMULTITEXCOORD1DVARBPROC)	GetProcAdress("glMultiTexCoord1dvARB");	
		glMultiTexCoord1fARB	= (PFNGLMULTITEXCOORD1FARBPROC)		GetProcAdress("glMultiTexCoord1fARB");
		glMultiTexCoord1fvARB	= (PFNGLMULTITEXCOORD1FVARBPROC)	GetProcAdress("glMultiTexCoord1fvARB");
		glMultiTexCoord1iARB	= (PFNGLMULTITEXCOORD1IARBPROC)		GetProcAdress("glMultiTexCoord1iARB");
		glMultiTexCoord1ivARB	= (PFNGLMULTITEXCOORD1IVARBPROC)	GetProcAdress("glMultiTexCoord1ivARB");
		glMultiTexCoord1sARB	= (PFNGLMULTITEXCOORD1SARBPROC)		GetProcAdress("glMultiTexCoord1sARB");
		glMultiTexCoord1svARB	= (PFNGLMULTITEXCOORD1SVARBPROC)	GetProcAdress("glMultiTexCoord1svARB");
		glMultiTexCoord2dARB	= (PFNGLMULTITEXCOORD2DARBPROC)		GetProcAdress("glMultiTexCoord2dARB");
		glMultiTexCoord2dvARB	= (PFNGLMULTITEXCOORD2DVARBPROC)	GetProcAdress("glMultiTexCoord2dvARB");	
		glMultiTexCoord2fARB	= (PFNGLMULTITEXCOORD2FARBPROC)		GetProcAdress("glMultiTexCoord2fARB");
		glMultiTexCoord2fvARB	= (PFNGLMULTITEXCOORD2FVARBPROC)	GetProcAdress("glMultiTexCoord2fvARB");
		glMultiTexCoord2iARB	= (PFNGLMULTITEXCOORD2IARBPROC)		GetProcAdress("glMultiTexCoord2iARB");
		glMultiTexCoord2ivARB	= (PFNGLMULTITEXCOORD2IVARBPROC)	GetProcAdress("glMultiTexCoord2ivARB");
		glMultiTexCoord2sARB	= (PFNGLMULTITEXCOORD2SARBPROC)		GetProcAdress("glMultiTexCoord2sARB");
		glMultiTexCoord2svARB	= (PFNGLMULTITEXCOORD2SVARBPROC)	GetProcAdress("glMultiTexCoord2svARB");
		glMultiTexCoord3dARB	= (PFNGLMULTITEXCOORD3DARBPROC)		GetProcAdress("glMultiTexCoord3dARB");
		glMultiTexCoord3dvARB	= (PFNGLMULTITEXCOORD3DVARBPROC)	GetProcAdress("glMultiTexCoord3dvARB");
		glMultiTexCoord3fARB	= (PFNGLMULTITEXCOORD3FARBPROC)		GetProcAdress("glMultiTexCoord3fARB");
		glMultiTexCoord3fvARB	= (PFNGLMULTITEXCOORD3FVARBPROC)	GetProcAdress("glMultiTexCoord3fvARB");
		glMultiTexCoord3iARB	= (PFNGLMULTITEXCOORD3IARBPROC)		GetProcAdress("glMultiTexCoord3iARB");
		glMultiTexCoord3ivARB	= (PFNGLMULTITEXCOORD3IVARBPROC)	GetProcAdress("glMultiTexCoord3ivARB");
		glMultiTexCoord3sARB	= (PFNGLMULTITEXCOORD3SARBPROC)		GetProcAdress("glMultiTexCoord3sARB");
		glMultiTexCoord3svARB	= (PFNGLMULTITEXCOORD3SVARBPROC)	GetProcAdress("glMultiTexCoord3svARB");
		glMultiTexCoord4dARB	= (PFNGLMULTITEXCOORD4DARBPROC)		GetProcAdress("glMultiTexCoord4dARB");
		glMultiTexCoord4dvARB	= (PFNGLMULTITEXCOORD4DVARBPROC)	GetProcAdress("glMultiTexCoord4dvARB");	
		glMultiTexCoord4fARB	= (PFNGLMULTITEXCOORD4FARBPROC)		GetProcAdress("glMultiTexCoord4fARB");
		glMultiTexCoord4fvARB	= (PFNGLMULTITEXCOORD4FVARBPROC)	GetProcAdress("glMultiTexCoord4fvARB");
		glMultiTexCoord4iARB	= (PFNGLMULTITEXCOORD4IARBPROC)		GetProcAdress("glMultiTexCoord4iARB");
		glMultiTexCoord4ivARB	= (PFNGLMULTITEXCOORD4IVARBPROC)	GetProcAdress("glMultiTexCoord4ivARB");
		glMultiTexCoord4saARB	= (PFNGLMULTITEXCOORD4SARBPROC)		GetProcAdress("glMultiTexCoord4saARB");
		glMultiTexCoord4svARB	= (PFNGLMULTITEXCOORD4SVARBPROC)	GetProcAdress("glMultiTexCoord4svARB");
		glActiveTextureARB		= (PFNGLACTIVETEXTUREARBPROC)		GetProcAdress("glActiveTextureARB");
		glClientActiveTextureARB= (PFNGLCLIENTACTIVETEXTUREARBPROC)	GetProcAdress("glClientActiveTextureARB");
The only problem: // resgister test setup function RegisterSetupFunction("GL_ARB_multitexture", SetupMultitexturing); --> error C2664: ''RegisterSetupFunction'' :cannot convert parameter 2 from void (void)'' to ''void (__cdecl *)(void)'' Here are other code snipps
typedef void(*VoidFuncPointer)();
typedef std::multimap<const char*, VoidFuncPointer> SetupMap;
void RegisterSetupFunction(String Extension, VoidFuncPointer Func);
So can anybody help me? Thanks, Christian

Share this post

Link to post
Share on other sites
It''s because it''s a member function. you need a global function, or you need to define a function pointer to a class member function. take a look at this thread:


void (__cdecl *)(void) means that you want a function of type __cdecl. member functions in classes are always of the type thiscall

My Site

Share this post

Link to post
Share on other sites
Pointers to member functions and pointers to non-member functions are incompatible. There a no possibility of conversion whatsoever.

Workaround : store and use function objects instead of function pointers. See boost::function (link in signature) for an example.

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!