BOOL DoInit() { HINSTANCE hInstance = g_Instance; int nReturnCode = -1; CWinThread* pThread = AfxGetThread(); CWinApp* pApp = AfxGetApp(); // AFX internal initialization if (!AfxWinInit(hInstance, NULL, TEXT(""), SW_SHOW)) return DoExit(); // App global initializations (rare) if (pApp != NULL && !pApp->InitApplication()) return DoExit(); // Perform specific initializations if (!pThread->InitInstance()) { if (pThread->m_pMainWnd != NULL) { TRACE(traceAppMsg, 0, "Warning: Destroying non-NULL m_pMainWnd\n"); pThread->m_pMainWnd->DestroyWindow(); } nReturnCode = pThread->ExitInstance(); return DoExit(); } return TRUE; }
DWORD WINAPI _WinThreadProc( LPVOID lpParameter ) /***********************************************/ { CWinThread *pThread = (CWinThread *)lpParameter; ASSERT( pThread != NULL ); AFX_MODULE_THREAD_STATE *pState = AfxGetModuleThreadState(); ASSERT( pState != NULL ); ASSERT( pState->m_pCurrentWinThread == NULL ); pState->m_pCurrentWinThread = pThread; AfxInitThread(); int nExitCode; if( pThread->m_pfnThreadProc != NULL ) { nExitCode = pThread->m_pfnThreadProc( pThread->m_pThreadParams ); } else { if( pThread->InitInstance() ) { nExitCode = pThread->Run(); } else { nExitCode = -1; } } if( pThread->m_bAutoDelete ) { delete pThread; } AfxTermThread( NULL ); return( nExitCode ); }
int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { ASSERT(hPrevInstance == NULL); int nReturnCode = -1; __try { CWinThread* pThread = AfxGetThread(); CWinApp* pApp = AfxGetApp(); // AFX internal initialization if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow)) goto InitFailure; // App global initializations (rare) if (pApp != NULL && !pApp->InitApplication()) goto InitFailure; // Perform specific initializations if (!pThread->InitInstance()) { if (pThread->m_pMainWnd != NULL) { TRACE(traceAppMsg, 0, "Warning: Destroying non-NULL m_pMainWnd\n"); pThread->m_pMainWnd->DestroyWindow(); } nReturnCode = pThread->ExitInstance(); goto InitFailure; } nReturnCode = pThread->Run(); InitFailure: #ifdef _DEBUG // Check for missing AfxLockTempMap calls if (AfxGetModuleThreadState()->m_nTempMapLock != 0) { TRACE(traceAppMsg, 0, "Warning: Temp map lock count non-zero (%ld).\n", AfxGetModuleThreadState()->m_nTempMapLock); } AfxLockTempMaps(); AfxUnlockTempMaps(-1); #else ; #endif } __except(RecordExceptionInfo(GetExceptionInformation())) { } // must call AfxWinTerm after handling exception or we'll crash // again trying to destroy the tooltip window AfxWinTerm(); return nReturnCode; }
int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { ASSERT(hPrevInstance == NULL); int nReturnCode = -1; CWinThread* pThread = AfxGetThread(); CWinApp* pApp = AfxGetApp(); // AFX internal initialization bool InitSuccess = AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow); // App global initializations (rare) if (pApp != NULL) InitSuccess = InitSuccess && pApp->InitApplication(); // Perform specific initializations InitSuccess = InitSuccess && pThread->InitInstance(); // Run the BCI2000 core module. if( InitSuccess ) { CoreModuleMFC coreModule; nReturnCode = ( coreModule.Run( __argc, __argv ) ? 0 : -1 ); } else { if (pThread->m_pMainWnd != NULL) { TRACE0("Warning: Destroying non-NULL m_pMainWnd\n"); pThread->m_pMainWnd->DestroyWindow(); } } pThread->ExitInstance(); #ifdef _DEBUG // Check for missing AfxLockTempMap calls if (AfxGetModuleThreadState()->m_nTempMapLock != 0) { TRACE1("Warning: Temp map lock count non-zero (%ld).\n", AfxGetModuleThreadState()->m_nTempMapLock); } AfxLockTempMaps(); AfxUnlockTempMaps(-1); #endif AfxWinTerm(); return nReturnCode; }
/* ================= RadiantInit This is also called when you 'quit' in doom ================= */ void RadiantInit( void ) { // make sure the renderer is initialized if ( !renderSystem->IsOpenGLRunning() ) { common->Printf( "no OpenGL running\n" ); return; } g_editorAlive = true; // allocate a renderWorld and a soundWorld if ( g_qeglobals.rw == NULL ) { g_qeglobals.rw = renderSystem->AllocRenderWorld(); g_qeglobals.rw->InitFromMap( NULL ); } if ( g_qeglobals.sw == NULL ) { g_qeglobals.sw = soundSystem->AllocSoundWorld( g_qeglobals.rw ); } if ( g_DoomInstance ) { if ( ::IsWindowVisible( win32.hWnd ) ) { ::ShowWindow( win32.hWnd, SW_HIDE ); g_pParentWnd->ShowWindow( SW_SHOW ); g_pParentWnd->SetFocus(); } } else { Sys_GrabMouseCursor( false ); g_DoomInstance = win32.hInstance; CWinApp* pApp = AfxGetApp(); CWinThread *pThread = AfxGetThread(); InitAfx(); // App global initializations (rare) pApp->InitApplication(); // Perform specific initializations pThread->InitInstance(); qglFinish(); //qwglMakeCurrent(0, 0); qwglMakeCurrent(win32.hDC, win32.hGLRC); // hide the doom window by default ::ShowWindow( win32.hWnd, SW_HIDE ); } }
/* ================= RadiantInit This is also called when you 'quit' in doom ================= */ void RadiantInit( void ) { // make sure the renderer is initialized if ( !renderSystem->IsOpenGLRunning() ) { common->Printf( "no OpenGL running\n" ); return; } g_editorAlive = true; // allocate a renderWorld and a soundWorld if ( g_qeglobals.rw == NULL ) { // jmarshall // g_qeglobals.defaultEditorMaterial = declManager->FindMaterial( "_editordefault" ); RadiantInitTestWindow(); // jmarshall end g_qeglobals.rw = renderSystem->AllocRenderWorld(); g_qeglobals.rw->InitFromMap( NULL ); } if ( g_qeglobals.sw == NULL ) { g_qeglobals.sw = soundSystem->AllocSoundWorld( g_qeglobals.rw ); } if ( g_DoomInstance ) { if ( ::IsWindowVisible( win32.hWnd ) ) { ::ShowWindow( win32.hWnd, SW_HIDE ); g_pParentWnd->ShowWindow( SW_SHOW ); g_pParentWnd->SetFocus(); } } else { sys->GrabMouseCursor( false ); g_DoomInstance = win32.hInstance; CWinApp* pApp = AfxGetApp(); CWinThread *pThread = AfxGetThread(); InitAfx(); // App global initializations (rare) pApp->InitApplication(); // Perform specific initializations pThread->InitInstance(); qglFinish(); //qwglMakeCurrent(0, 0); renderDevice->BindDeviceToWindow(win32.hDC); // hide the doom window by default ::ShowWindow( win32.hWnd, SW_HIDE ); // jmarshall toolInterfaceLocal.ShowDebugConsole(); // jmarshall end } }