Jump to content
  • Advertisement
Sign in to follow this  
of_ownage

DXUT function pointer

This topic is 3567 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
×

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!