• Advertisement
Sign in to follow this  

DXUT function pointer

This topic is 3297 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 have a problem with DXUT. I need to define the callback functions like this. DXUTSetCallbackD3D9FrameRender( OnD3D9FrameRender); this works perfect, but what if i want to use the function from one of my classes? like this: MainClass* myRPlaner = MainClass::getInstance(); DXUTSetCallbackD3D9FrameRender( myRPlaner::OnD3D9FrameRender); does not work, DXUTSetCallbackD3D9FrameRender( &MainClass::OnD3D9FrameRender); does not work, ... what do i have to do? Is that even possible? it always says it cant convert the function. thank yo

Share this post


Link to post
Share on other sites
Advertisement
One way to handle it is to register a function that uses the pUserContext as your class pointer and then calls the member function on the pointer. Ex:

VOID FrameRenderThunk(
IDirect3DDevice9 * pd3dDevice,
DOUBLE fTime,
FLOAT fElapsedTime,
void* pUserContext
) {
MainClass * ptr = static_cast<MainClass *>(pUserContext);
ptr->OnD3D9FrameRender(pd3dDevice, fTime, fElapsedTime);
}

// later
DXUTSetCallbackD3D9FrameRender(&FrameRenderThunk, myRPlaner);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement