0
点赞
收藏
分享

微信扫一扫

DirectX9.0 3D---EnterMsgLoop参数中指向函数的指针


该函数接受一个名为 ptr_display 的指向函数的指针,该函数指针的参数为 float 类型,返回类型为 bool。函数返回一个 int 类型的值。

int EnterMsgLoop( 
		bool (*ptr_display)(float timeDelta));

int d3d::EnterMsgLoop( bool (*ptr_display)(float timeDelta) )
{
	MSG msg;
	::ZeroMemory(&msg, sizeof(MSG));

	static float lastTime = (float)timeGetTime(); 

	while(msg.message != WM_QUIT)
	{
		if(::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
		{
			::TranslateMessage(&msg);
			::DispatchMessage(&msg);
		}
		else
        {	
			float currTime  = (float)timeGetTime();
			float timeDelta = (currTime - lastTime)*0.001f;

			ptr_display(timeDelta);

			lastTime = currTime;
        }
    }
    return msg.wParam;
}


举报

相关推荐

指向函数的指针

0 条评论