int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR lpCmdLine,int nCmdShow ) { MSG msg; #ifdef _DEBUG _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); #endif if( !initApplication(hInstance) ) return FALSE; HANDLE hMutex = CreateMutex(NULL,NULL,className); if(ERROR_ALREADY_EXISTS == GetLastError()){ if( lpCmdLine[0]!='\0'){ HWND hWin=FindWindow( className, NULL ); if( hWin ){ SendMessage( hWin, WM_COMMAND, ID_END, 0 ); } }else{ return FALSE; } } HANDLE hAccel = LoadAccelerators( hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR) ); CoInitialize(NULL); readProfile(); if( !OpenPackFile() ) return FALSE; if( !InitInstance(hInstance,nCmdShow) ) return FALSE; SystemInit(lpCmdLine); WINNLSEnableIME(sysInf.hWnd,FALSE); TIMECAPS tc; timeGetDevCaps(&tc,sizeof(tc)); timeBeginPeriod(tc.wPeriodMin); while(FALSE==sysInf.bGameEnd){ BOOL bGotMsg; if(sysInf.bIsActive || lpMovie || !sysInf.bBackStop){ bGotMsg = PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE); }else{ bGotMsg = GetMessage( &msg, NULL, 0U, 0U ); } if(bGotMsg){ if(TranslateAccelerator( sysInf.hWnd, (HACCEL)hAccel, &msg ))continue; TranslateMessage(&msg); DispatchMessage(&msg); } if(sysInf.bIsActive || lpMovie || !sysInf.bBackStop){ mainLoop(); } } WINNLSEnableIME(sysInf.hWnd,TRUE); timeEndPeriod(tc.wPeriodMin); writeProfile(); cleanup(); CoUninitialize(); CloseHandle(hMutex); return msg.wParam; } // WinMain
int fakeIt() { if ( !initApplication(hInstance)) { // Handle that shit NSLog(L"RegisterClassEx FAILED: %d", GetLastError()); } HWND hWnd = CreateWindow( L"MainWClass", // lpClassName NULL, // lpWindowName WS_OVERLAPPEDWINDOW, // dwStyle 100, // x 100, // y 500, // width 500, // height NULL, // hWndParent NULL, // hMenu hInstance, // hInstance NULL ); // lpParam if (!hWnd) { NSLog(L"CreateWindow FAILED: %d", GetLastError()); } ShowWindow(hWnd, SW_SHOW); UpdateWindow(hWnd); HWND hWnd2 = CreateWindow( L"MainWClass", // lpClassName NULL, // lpWindowName WS_CHILD, // dwStyle 10, // x 10, // y 50, // width 50, // height hWnd, // hWndParent NULL, // hMenu hInstance, // hInstance NULL ); // lpParam if (!hWnd2) { NSLog(L"CreateWindow FAILED: %d", GetLastError()); } ShowWindow(hWnd2, SW_SHOW); UpdateWindow(hWnd2); MSG msg; while (GetMessage(&msg, NULL, 0, 0) > 0) { TranslateMessage(&msg); DispatchMessage(&msg); } return 0; }
int PASCAL WinMain( HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show ) { char buffer[PATH_MAX]; #if !defined( __WATCOMC__ ) && defined( __NT__ ) _argc = __argc; _argv = __argv; #endif EXEName = _cmdname( buffer ); InstanceHandle = inst; showHow = show; prev = prev; cmdline = cmdline; InitMem(); #ifndef __NT__ if( prev != NULL && !HasShare() ) { MessageBox( NULLHANDLE, "SHARE.EXE must be loaded before starting Windows in order to run multiple instances of the editor", EditorName, MB_OK ); MyGetInstanceData( (unsigned short) prev, (void near *) &Root, sizeof( Root ) ); SetFocus( Root ); return( 0 ); } #endif Comspec = getenv( "COMSPEC" ); #ifdef __NT__ VarAddGlobalStr( "OS", "winnt" ); #else VarAddGlobalStr( "OS", "win" ); #endif SetConfigFileName( CFG_NAME ); ReadProfile(); ShowStartupDialog(); initApplication(); if( !initInstance() ) { return( 0 ); } InitializeEditor(); SetSaveConfig(); if( !BAD_ID( CurrentWindow ) ) { SetFocus( Root ); } SetWindowCursorForReal(); ResizeRoot(); EditMain(); FiniMem(); return( 0 ); } /* WinMain */
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR lpCmdLine,int nCmdShow ) { MSG msg; if( !initApplication(hInstance) ) return FALSE; HANDLE hMutex = CreateMutex(NULL,NULL,className); if(ERROR_ALREADY_EXISTS == GetLastError())return FALSE; HANDLE hAccel = LoadAccelerators( hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR) ); CoInitialize(NULL); readProfile(); if( !OpenPackFile() ) return FALSE; if( !InitInstance(hInstance,nCmdShow) ) return FALSE; SystemInit(); WINNLSEnableIME(sysInf.hWnd,FALSE); TIMECAPS tc; timeGetDevCaps(&tc,sizeof(tc)); timeBeginPeriod(tc.wPeriodMin); while(FALSE==sysInf.bGameEnd){ BOOL bGotMsg; if(sysInf.bIsActive || lpMovie || lpStaffRoll){ bGotMsg = PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE); }else{ bGotMsg = GetMessage( &msg, NULL, 0U, 0U ); } if(bGotMsg){ if(TranslateAccelerator( sysInf.hWnd, (HACCEL)hAccel, &msg ))continue; TranslateMessage(&msg); DispatchMessage(&msg); } if(sysInf.bIsActive || sysInf.execMode==movie_mode || lpStaffRoll){ mainLoop(); } } WINNLSEnableIME(sysInf.hWnd,TRUE); timeEndPeriod(tc.wPeriodMin); writeProfile(); cleanup(); CoUninitialize(); CloseHandle(hMutex); if(CheckWinExec()){ WinExec2( str_winpath, str_winexec ); } return msg.wParam; } // WinMain
/*!************************************************************************************** @Function main @Return void @Description Main function invoked after Application launch. ******************************************************************************************/ int main(void) { int n=-1; pthread_t thread1; pthread_t thread2; /* Ensure the contents are erased and file is created if doesn't exist*/ FILE *fd_instance = fopen( INSTANCEID_FIFO_NAME, "w"); fprintf(fd_instance,"%d",-1); fclose(fd_instance); printf("Initializing egl..\n\n"); if( 0 == initApplication()) { printf("EGL init failed"); return 0; } initView(); /* Launch user and pipe control threads */ n = pthread_create(&thread1, NULL, pipe_ctrl_thread, NULL); n = pthread_create(&thread2, NULL, user_ctrl_thread, NULL); while(1) { if(id != -1) setup_channel(); /* If any of the bc_cat devices are alive render */ if( (dev_fd0 != -1) || (dev_fd1 != -1) || (dev_fd2 != -1) || (dev_fd3 != -1) ) { render_thread(dev_fd0,0); render_thread(dev_fd1,1); render_thread(dev_fd2,2); render_thread(dev_fd3,3); /* eglswapbuffers must be called only after all active devices have finished rendering inorder to avoid any artifacts due to incomplete/partial frame updates*/ eglSwapBuffers(dpy, surface); } else { sleep(2); } } return 0; }
int main(int argc, char* argv []) { GLFWwindow* window = initContext(); if (window) { initApplication(window); gl::Program<GLuint> prog; eventLoop(window); } delete appData->program; delete appData->fshader; delete appData->vshader; delete appData; glfwTerminate(); }
// Qt application's entry point. eInt main(eInt argc, eChar **argv) { eMemTrackerStart(); if (!eVerifyInstructionSets()) { return -1; } QApplication app(argc, argv); initApplication(); eMainWnd mainWnd; app.setActiveWindow(&mainWnd); mainWnd.show(); return app.exec(); }
/* * WinMain */ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { if( !initApplication(hInstance, nCmdShow) ) return FALSE; { /* * Since printfs go into the bit bucket on Win32, * put up a message in the window. */ HDC hDC = GetDC(hWndMain); char *message = "Press any Key to continue!"; RECT rect; GetClientRect(hWndMain, &rect); SetTextColor(hDC, RGB(0, 255, 255)); SetBkColor(hDC, RGB(0, 0, 0)); SetTextAlign(hDC, TA_CENTER); ExtTextOut(hDC, rect.right/2, rect.bottom/2, ETO_OPAQUE, &rect, message, strlen(message), NULL); ReleaseDC(hWndMain, hDC); GdiFlush(); } { int argc; char **argv; extern int main(int argc, char **argv); argv = commandLineToArgv(lpCmdLine, &argc); main(argc, argv); } p3dc_close(); printf("Exiting winMain()\n"); fflush(stdout); DestroyWindow(hWndMain); return 0; } /* WinMain */
int main(int argc, char** argv) { initApplication( argc, argv ); //initGL( argc, argv ); initGLUT( argc, argv ); GLenum err = glewInit(); if (err || !glewIsSupported("GL_VERSION_2_0 GL_ARB_pixel_buffer_object")) { fprintf(stderr, "Required OpenGL extensions missing."); exit(-1); } else { initCUDA( argc, argv ); initObservationSpace(); // init the pbo dispResp->createPBO(); // Create pixel buffer object // init result device memory //createResMem(); atexit(cleanUpAtExit); // printHelpMenu(); // start glut main loop glutMainLoop(); } return 0; }
NavApp::NavApp(int& argc, char **argv, int flags) : atools::gui::Application(argc, argv, flags) { initApplication(); }
/// @brief Entry point for the application void ServerGraphics::go (void) { GameCore::uPublicSeed = time(NULL); srand(GameCore::uPublicSeed + 1); // Initialise the application. if (!initApplication()) return; // Enter the render loop. unsigned long usCurrentFrame = 0, usPreviousFrame = 0, numberOfFrames = 0; float sTimeSinceLastFrame = 0; mAverageFrameRate = 0; #if SERVER_FPS > 0 signed long usRemainingTime = 0; unsigned long usNextStateStep = 0; const unsigned long usStateStepSize = 1000000 / SERVER_FPS; #endif #if GRAPHICS_FPS > 0 unsigned long usNextGraphicsStep = 0; const unsigned long usGraphicsStepSize = 1000000 / GRAPHICS_FPS; #endif mRoot->getRenderSystem()->_initRenderTargets(); // Run the server at the server FPS, making the assumption that the graphics are both // non-critical and update at a sufficiently lower rate than the state update rate, // extrapolating the graphical updates on top of the state updates. #if SERVER_FPS > 0 usNextStateStep = mRoot->getTimer()->getMicroseconds() + usStateStepSize; #endif #if GRAPHICS_FPS > 0 usNextGraphicsStep = mRoot->getTimer()->getMicroseconds() + usGraphicsStepSize; #endif while (1) { // Calculate the time since the last frame was processed. usCurrentFrame = mRoot->getTimer()->getMicroseconds(); sTimeSinceLastFrame = (float) (usCurrentFrame - usPreviousFrame) / 1000000.0f; if (numberOfFrames < 5000) mAverageFrameRate += ((1.0f / sTimeSinceLastFrame) - mAverageFrameRate) / ((float) ++numberOfFrames); else mAverageFrameRate += ((1.0f / sTimeSinceLastFrame) - mAverageFrameRate) / 5000; // Calculate the scheduled finish time of this step by adding the step size to // the previous scheduled finish. This accounts for both oversleep and undersleep // from the sleep at the end of the loop. If the previous scheduled finish is // already so far behind that we won't reach it this step, don't increment the // scheduled finish and instead use the previous one. This prevents 'losing time' // when the server can't run at its MAX_FPS, and stabilises the frame durations // on systems with high workload // Calculate when to have the next state step (the driving step). #if SERVER_FPS > 0 if (usNextStateStep < usCurrentFrame + usStateStepSize) usNextStateStep += usStateStepSize; #endif // Update the gamestate updateState(sTimeSinceLastFrame); // Update the graphics, if this state step coincides with a graphics step. #if GRAPHICS_FPS > 0 if (usCurrentFrame > usNextGraphicsStep) { #endif // Render the frame - pumping window messages to keep the system responsive and // drawing the GUI, exitting the loop if necessary. Ogre::WindowEventUtilities::messagePump(); if (!mRoot->renderOneFrame()) break; #if GRAPHICS_FPS > 0 usNextGraphicsStep += usGraphicsStepSize; } #endif // Try to sleep for the remaining time. // We may wake up early or late, however the NextStep mechanic will force it to tend to // the target rate. When the SERVER_FPS is greater than it can reach, usRemainingTime // will always be < 0 (as we are effectively losing time) and no sleeping will occur. #if SERVER_FPS > 0 usRemainingTime = usNextStateStep - mRoot->getTimer()->getMicroseconds(); if (usRemainingTime > 0) usleep(usRemainingTime); #endif usPreviousFrame = usCurrentFrame; } // Exit the render loop and clean up. GameCore::destroy(); }
EngineState::EngineState() : #if defined(_PROFILE) | defined(_DEBUG) m_displayShadowMaps(false), m_displayShadowFrustum(false), m_displayShadowBuffer(false), #endif m_BackBufferDesc({ 1280, 720, DXGI_FORMAT_R16G16B16A16_FLOAT, { 1, 0 } }), m_Viewport({ 0.0f, 0.0f, static_cast<float>(m_BackBufferDesc.Width), static_cast<float>(m_BackBufferDesc.Height), 0.0f, 1.0f}), m_Light(-0.5f, -0.5f, 0.5f, 0.5f, 0.0f, 1.0f), m_LightDirection(XMVector3Normalize(XMVectorSet(1.f, 0.5f, 0.3f, 0.f))), m_fovy(XM_PI / 3.f), m_aspect(m_Viewport.Width / m_Viewport.Height), m_znear(0.1f), m_zfar(200.f), m_LightShafts(true), m_DepthOfField(true), m_Bloom(true), m_AmbientOcclusion(true), m_Fxaa(true), m_ShadowMapSize(2048), m_ShadowMapCount(3), m_ShadowMapQuality(1), m_ShadowMapType(2), m_fullScreen(false), m_vsync(true), m_refreshRate({60,1}) { NvGsaApplication app; NvGsaStatus status; const NvGsaNamedOption *options = NULL; size_t numOptions = 0; const NvGsaResolution *resolutions = NULL; size_t numResolutions = 0; NvGsaVersion runtimeVersion = GFSDK_GSA_GetVersion(); // Print the GSA compile time version wprintf(L"Compiled against GSA version: "); printGsaVersion(&NvGsaCurrentVersion); wprintf(L"\n"); // Print the GSA run time version wprintf(L"Running against GSA version: "); printGsaVersion(&runtimeVersion); wprintf(L"\n"); // Initialize the application LPWSTR *szArglist; int nArgs = 0; szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); if (nArgs < 1 || !initApplication(&app, szArglist[0])) { wprintf(L"Failed to initialize the application, exiting!"); return; } GlobalFree(szArglist); // Initialize the GSA SDK status = GFSDK_GSA_InitializeSDK(&app, &NvGsaCurrentVersion); releaseApplication(&app); if (status != NV_GSA_STATUS_OK) { wprintf(L"Failed to initialize the GSA SDK, exiting!"); return; } if (initOptions(&options, &numOptions) && initResolutions(&resolutions, &numResolutions)) { //status = GFSDK_GSA_SaveConfigFile(NV_GSA_SAVE_ALL); NvGsaResolution currentResolution; size_t i; // Register the options for (i = 0; i < numOptions; ++i) { GFSDK_GSA_RegisterOption(&options[i]); } // Register the resolutions GFSDK_GSA_RegisterResolutions(resolutions, (int)numResolutions); // Load the config file status = GFSDK_GSA_LoadConfigFile(); if (status == NV_GSA_STATUS_FILENOTFOUND) { GFSDK_GSA_SetResolution(&resolutions[0]); } // Print and cycle the options for (i = 0; i < numOptions; ++i) { NvGsaVariant value; value.type = options[i].value.type; status = GFSDK_GSA_GetOptionValue(&value, options[i].name); if (status == NV_GSA_STATUS_OK) { switch (str2int(options[i].name)) { case str2int(L"Field_Of_View"): m_fovy = value.asFloat; break; case str2int(L"Near_Plane"): m_znear = value.asFloat; break; case str2int(L"Far_Plane"): m_zfar = value.asFloat; break; case str2int(L"LightShafts"): m_LightShafts = value.asBool; break; case str2int(L"DepthOfField"): m_DepthOfField = value.asBool; break; case str2int(L"Bloom"): m_Bloom = value.asBool; break; case str2int(L"AmbientOcclusion"): m_AmbientOcclusion = value.asBool; break; case str2int(L"Fxaa"): m_Fxaa = value.asBool; break; case str2int(L"FullScreen"): m_fullScreen = value.asBool; break; case str2int(L"V-Sync"): m_vsync = value.asBool; break; case str2int(L"ShadowMapSize"): switch (str2int(value.asEnum)) { case str2int(L"512"): m_ShadowMapSize = 512; break; case str2int(L"1024"): m_ShadowMapSize = 1024; break; case str2int(L"2048"): m_ShadowMapSize = 2048; break; case str2int(L"4096"): m_ShadowMapSize = 4096; break; } break; case str2int(L"ShadowMapCount"): m_ShadowMapCount = value.asInt; break; case str2int(L"ShadowMapQuality"): switch (str2int(value.asEnum)) { case str2int(L"Low_Hard"): m_ShadowMapQuality = 0; m_ShadowMapType = 0; break; case str2int(L"Medium_Hard"): m_ShadowMapQuality = 1; m_ShadowMapType = 0; break; case str2int(L"High_Hard"): m_ShadowMapQuality = 2; m_ShadowMapType = 0; break; case str2int(L"Low_PCF"): m_ShadowMapQuality = 0; m_ShadowMapType = 1; break; case str2int(L"Medium_PCF"): m_ShadowMapQuality = 1; m_ShadowMapType = 1; break; case str2int(L"High_PCF"): m_ShadowMapQuality = 2; m_ShadowMapType = 1; break; case str2int(L"Low_PCSS"): m_ShadowMapQuality = 0; m_ShadowMapType = 2; break; case str2int(L"Medium_PCSS"): m_ShadowMapQuality = 1; m_ShadowMapType = 2; break; case str2int(L"High_PCSS"): m_ShadowMapQuality = 2; m_ShadowMapType = 2; break; } break; } GFSDK_GSA_ReleaseVariant(&value); } } // Print and increment the resolution status = GFSDK_GSA_GetResolution(¤tResolution); if (status == NV_GSA_STATUS_OK) { m_refreshRate.Numerator = (UINT)round(currentResolution.refreshRate); WindowSizeChanged(currentResolution.width, currentResolution.height); } } // Cleanup releaseOptions(options); releaseResolutions(resolutions); m_Camera.SetProjParams(m_fovy, m_aspect, m_znear, m_zfar); m_Camera.SetViewParams(XMVectorSet(0.f, 0.f, 0.f, 1.f), XMVectorSet(0.f, 0.f, 1.f, 1.f)); }