Пример #1
0
//-----------------------------------------------------------------------------------------------
void RunFrame() {
	RunMessagePump();
	Update();
	Render();
	WaitUntilNextFrameTime();
	SwapBuffers( g_displayDeviceContext );
}
Пример #2
0
//-----------------------------------------------------------------------------------------------
void RunFrame()
{
	RunMessagePump();
	Update();
	Render();
	WaitUntilNextFrameTime();
}
Пример #3
0
//-----------------------------------------------------------------------------------------------
void RunFrame()
{
	TheApp::instance->AdvanceFrameNumber();
	RunMessagePump();
	Update();
	Render();
}
Пример #4
0
//-----------------------------------------------------------------------------------------------
void RunFrame()
{
	static double timeSpentLastFrameSeconds = 0.0;
	RunMessagePump();
	Update( LOCKED_FRAME_RATE_SECONDS );
	Render();
	timeSpentLastFrameSeconds = WaitUntilNextFrameThenGiveFrameTime();
}
Пример #5
0
void InformApp::WaitForProcessEnd(HANDLE process)
{
  DWORD result = STILL_ACTIVE;
  while (result == STILL_ACTIVE)
  {
    ::MsgWaitForMultipleObjects(0,NULL,FALSE,INFINITE,QS_ALLINPUT);
    RunMessagePump();
    ::GetExitCodeProcess(process,&result);
  }
  ::CloseHandle(process);
}
Пример #6
0
int InformApp::RunCommand(const char* dir, CString& command, OutputSink& output)
{
  CWaitCursor wc;

  // Create a pipe to read the command's output
  SECURITY_ATTRIBUTES security;
  ::ZeroMemory(&security,sizeof security);
  security.nLength = sizeof security;
  security.bInheritHandle = TRUE;
  HANDLE pipeRead, pipeWrite;
  ::CreatePipe(&pipeRead,&pipeWrite,&security,0);

  // Use the pipe for standard I/O and, for Windows 9X, make sure that the
  // console window is hidden
  STARTUPINFO start;
  ::ZeroMemory(&start,sizeof start);
  start.cb = sizeof start;
  start.hStdOutput = pipeWrite;
  start.hStdError = pipeWrite;
  start.wShowWindow = SW_HIDE;
  start.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;

  // Create the process with debugging enabled
  PROCESS_INFORMATION process;
  char* cmdLine = command.GetBuffer();
  BOOL created = ::CreateProcess(NULL,cmdLine,NULL,NULL,TRUE,DEBUG_PROCESS|CREATE_NO_WINDOW,
    NULL,dir,&start,&process);
  command.ReleaseBuffer();

  DWORD result = 512;
  if (created)
  {
    // Wait for the process to complete
    result = STILL_ACTIVE;
    while (result == STILL_ACTIVE)
    {
      // Catch errors from the process
      DEBUG_EVENT debug;
      while (::WaitForDebugEvent(&debug,2))
      {
        DWORD status = DBG_CONTINUE;
        if (debug.dwDebugEventCode == EXCEPTION_DEBUG_EVENT)
        {
          switch (debug.u.Exception.ExceptionRecord.ExceptionCode)
          {
          case EXCEPTION_ACCESS_VIOLATION:
            if (debug.u.Exception.dwFirstChance)
              status = DBG_EXCEPTION_NOT_HANDLED;
            else
              ::TerminateProcess(process.hProcess,10);
            break;
          case EXCEPTION_STACK_OVERFLOW:
            ::TerminateProcess(process.hProcess,11);
            break;
          }
        }
        ::ContinueDebugEvent(debug.dwProcessId,debug.dwThreadId,status);
      }

      // Wait for a window message or 100ms to elapse
      ::MsgWaitForMultipleObjects(0,NULL,FALSE,100,QS_ALLINPUT);
      RunMessagePump();

      // Is there any more output?
      DWORD available = 0;
      ::PeekNamedPipe(pipeRead,NULL,0,NULL,&available,NULL);
      if (available > 0)
      {
        // Read the output from the pipe
        CString msg;
        char* buffer = msg.GetBuffer(available);
        DWORD read = 0;
        ::ReadFile(pipeRead,buffer,available,&read,NULL);
        msg.ReleaseBuffer(read);
        output.Output(msg);
      }

      // Get the exit code
      ::GetExitCodeProcess(process.hProcess,&result);
    }
    ::CloseHandle(process.hProcess);
    ::CloseHandle(process.hThread);
  }

  ::CloseHandle(pipeRead);
  ::CloseHandle(pipeWrite);
  return result;
}