|
|

楼主 |
发表于 2005-12-21 15:12:00
|
显示全部楼层
Re:求助:关于OPENGL程序,CPU占用率的问题
问题解决了,自己动手,丰衣足食,哈哈
if (!m_pMainWnd)
AfxPostQuitMessage(0);
MSG msg;
CMainFrame* pFrame = STATIC_DOWNCAST ( CMainFrame, m_pMainWnd );
if ( QueryPerformanceFrequency ( ( LARGE_INTEGER *) &m_lPerfCounter ) ) {
// yes, set m_dwTimeCount and timer choice flag
m_bPerFlag = TRUE;
m_dwTimeCount = unsigned long(m_lPerfCounter / m_lFramesPerSecond);
QueryPerformanceCounter ( ( LARGE_INTEGER * ) &m_lNextTime );
m_dTimeScale = 1.0 / m_lPerfCounter;
} else {
// no performance counter, read in using timeGetTime
m_lNextTime = timeGetTime ();
m_dTimeScale = 0.001;
}
// save time of last frame
m_lLastTime = m_lNextTime;
while ( TRUE ) {
//see if there is a message waiting
if ( : eekMessage ( &msg, NULL, 0, 0, PM_NOREMOVE ) ) {
do //if there is pump all waiting
{
if ( !PumpMessage () )
return ExitInstance ();
} while ( ::PeekMessage ( &msg, NULL, 0, 0, PM_NOREMOVE ) );
} else
{
// use the appropriate method to get time
// and calculate elapsed time since last frame
if ( m_bPerFlag )
{
QueryPerformanceCounter ( ( LARGE_INTEGER * ) &m_lCurTime );
}
else
{
m_lCurTime=timeGetTime ();
}
// is it time to render the frame?
if ( m_lCurTime > m_lNextTime )
{
// calculate elapsed time
m_dTimeElapsed = ( m_lCurTime - m_lLastTime ) * m_dTimeScale;
// save frame time
m_lLastTime = m_lCurTime;
// yes, render the frame
if ( !pFrame->m_bAppIsActive )
WaitMessage();
else
pFrame->RenderGLScene ();
// set time for next frame
m_lNextTime = m_lCurTime + m_dwTimeCount;
} // end if
} // end if else
} // end while
return msg.wParam; |
|