Original Post
Hi, I'm having a problem with function pointers in C++. The directX 9 sample framework allows us to create callbacks for significant events, e.g. the create device event can be handled by a function with this declaration:
HRESULT CALLBACK onCreateDevice(IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc);
and we declare to the framework that this will be the callback with the command DXUTSetCallbackDeviceCreated(onCreateDevice). This function takes a function pointer as a parameter. The problem is that if the function passed in is not global, and instead is a member function of a class, the conversion of the parameter to the correct type does not work as before -I get a type cast error. The type that is expected is the function pointer HRESULT (CALLBACK *LPDXUTCALLBACKDEVICECREATED)( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc ); Can anyone with more experience on function pointers provide any insight on this situation? Furthermore, what happens if the function is virtual -can pointers to that function work in this case? Thanks for any replies.