void CWinSystemBase::DriveRenderLoop() { MessagePump(); { CSingleLock lock(m_renderLoopSection); for (auto i = m_renderLoopClients.begin(); i != m_renderLoopClients.end(); ++i) (*i)->FrameMove(); } }
int __stdcall _tWinMain( HINSTANCE hInstanceExe, HINSTANCE, // should not reference this parameter PTSTR lpstrCmdLine, int nCmdShow ) { // // To enable a console project to compile this code, set // Project->Properties->Linker->System->Subsystem: Windows. // int nArgC = 0; PWSTR* ppArgV = CommandLineToArgvW(lpstrCmdLine, &nArgC); g_pszAppName = ppArgV[0]; if (!InitWindowClass()) { // InitWindowClass displays any errors return -1; } // Main app window HWND hWnd = CreateWindowEx( WS_EX_CLIENTEDGE | WS_EX_APPWINDOW, WND_CLASS_NAME, g_pszAppName, WS_OVERLAPPEDWINDOW, // style CW_USEDEFAULT, 0, 640, 480, NULL, NULL, hInstanceExe, NULL); if (hWnd == NULL) { ErrorHandler(TEXT("CreateWindowEx: main appwindow hWnd")); return -1; } // Actually draw the window. ShowWindow(hWnd, SW_SHOWNORMAL); UpdateWindow(hWnd); // The message pump loops until the window is destroyed. MessagePump(hWnd); return 1; }
//----------------------------------------------------------------------------- // Purpose: Start a new frame //----------------------------------------------------------------------------- bool CGameEnginePS3::StartFrame() { // Pump PS3 system callbacks MessagePump(); // We may now be shutting down, check and don't start a frame then if ( BShuttingDown() ) return false; // Clear the screen for the new frame glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); return true; }
bool CFrameNetThread::Execute() { bool bHasData = false; //while(!GetTerminated()) //{ //消息泵 if(MessagePump() > 0) { bHasData = true; } //处理socket超时事件 HandleTimeOutEvent(); //} return bHasData; }
//----------------------------------------------------------------------------- // Purpose: Start a new frame //----------------------------------------------------------------------------- bool CGameEngineGL::StartFrame() { AdjustViewport(); // Pump system callbacks MessagePump(); // We may now be shutting down, check and don't start a frame then if ( BShuttingDown() ) return false; #if 0 // for debug static unsigned char counter; counter++; glClearColor( (float)counter/255.0f, (float)counter/255.0f, (float)counter/255.0f, (float)1.0f ); #endif // Clear the screen for the new frame glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT ); return true; }
// param: PWCHAR, new volume's disk letter will be stored there. static DWORD WINAPI DevNotifyThread(void *param) { HWND hWnd; DWORD diskIndex = 0; g_NewVolumeBitmask = 0; if (!InitWindowClass()) return 1; hWnd = CreateWindowEx( WS_EX_CLIENTEDGE | WS_EX_APPWINDOW, WND_CLASS_NAME, L"QDevNotify", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, 640, 480, NULL, NULL, GetModuleHandle(NULL), NULL); if (hWnd == NULL) { perror("CreateWindowEx: main appwindow hWnd"); return 2; } MessagePump(); if (g_NewVolumeBitmask == 0) // failed? return 3; // Translate bitmask into disk letter. BitScanForward(&diskIndex, g_NewVolumeBitmask); *(WCHAR *) param = L'A' + (WCHAR) diskIndex; return 0; }
void GameHostX11::Impl::Run(Game & game) { game.Initialize(); while (!exitRequest) { clock.Tick(); MessagePump(); constexpr int64_t gamepadDetectionInterval = 240; if (((clock.GetFrameNumber() % gamepadDetectionInterval) == 1) && (clock.GetFrameRate() >= 30.0f)) { gamepad->EnumerateDevices(); } gamepad->PollEvents(); game.Update(); RenderFrame(game); auto elapsedTime = clock.GetElapsedTime(); if (elapsedTime < presentationInterval) { auto sleepTime = (presentationInterval - elapsedTime); std::this_thread::sleep_for(sleepTime); } } }
//*********************************************************************************************** // METHOD: OnScan // PURPOSE: Request a packet from all servers out there // to populate serial number combo // void CMCTeleClientDlg::OnScan() { ASSERT(m_hWnd != NULL); m_bScanning = TRUE; // post a multiclamp 700B scan message if( !::PostMessage( HWND_BROADCAST, s_uMCTGBroadcastMessage, (WPARAM) m_hWnd, (LPARAM) 0 ) ) { TRACE("Failed to scan servers!"); return; } // disable scan button and hold down. m_cbxSerialNum.EnableWindow( FALSE ); m_btnScan.EnableWindow( FALSE ); m_btnScan.SetState( TRUE ); // make sure the serial number list is empty before populating m_vSerialNum.clear(); // scan c_uNumMultiClampScans times to make sure we get a response for( int i=1; i<=s_cuNumMultiClampScans; i++ ) { DWORD dwStartTime = GetTickCount(); do MessagePump(); while( s_cuScanMultiClampTimeOutMS > (GetTickCount() - dwStartTime) ); } // fill the serial number combo using the accumulated serial number list. m_cbxSerialNum.ResetContent(); SerialNumList::iterator iter; for( iter = m_vSerialNum.begin(); iter != m_vSerialNum.end(); iter++ ) { // get a pointer to each string in the list CString * pSN = iter; char szSerialNum[16] = {0}; strncpy( szSerialNum, (char *)pSN->GetBuffer(pSN->GetLength()), sizeof(szSerialNum) ); // skip duplicates int nIndex = m_cbxSerialNum.FindStringExact( 0, szSerialNum ); if( nIndex != CB_ERR ) continue; // add the string and numerical conversion (as data) to the combo nIndex = m_cbxSerialNum.AddString( szSerialNum ); if( nIndex != CB_ERRSPACE ) m_cbxSerialNum.SetItemData( nIndex, atoi(szSerialNum) ); else m_cbxSerialNum.ResetContent(); } // update serial number combo m_cbxSerialNum.EnableWindow( TRUE ); m_cbxSerialNum.SetCurSel( 0 ); m_btnScan.EnableWindow( TRUE ); m_btnScan.SetState( FALSE ); // tag combo with "No Device" and set data to magic number if no clients found if( m_cbxSerialNum.GetCount() == 0 ) { m_cbxSerialNum.AddString( s_cszNoDevice ); m_cbxSerialNum.SetItemData( m_cbxSerialNum.GetCurSel(), s_cdwNoDevice ); m_cbxSerialNum.EnableWindow( FALSE ); m_cbxSerialNum.SetCurSel( 0 ); // warn that no servers were found CString cstrMessage; cstrMessage = "No servers found.\n\n"; cstrMessage += "Start MultiClamp 700B Commander or MCTeleServer and rescan.\n"; int nRetVal = AfxMessageBox( cstrMessage, MB_OK | MB_ICONINFORMATION, (UINT) -1 ); } OnSelChangeSerialNum(); m_bScanning = FALSE; }