//-------------------------------- void PositionCommand(std::string in) { std::string arg1, arg2; GetFirstArg(in, &arg1, &arg2); if(arg1 == "fen") { std::string fenstring; int beg = arg2.find_first_not_of(" \t"); fenstring = arg2.substr(beg, arg2.size()); if(!FenStringToEngine((char *)fenstring.c_str())) { std::cout << "Illegal position" << std::endl; return; } } else InitEngine(); int moves = arg2.find("moves"); if(moves == -1) return; std::string mov_seq = arg2.substr(moves + 5, in.size()); int beg = mov_seq.find_first_not_of(" \t"); mov_seq = mov_seq.substr(beg, mov_seq.size()); ProcessMoveSequence(mov_seq); }
//-------------------------------- void SetvalueCommand(std::string in) { #ifdef TUNE_PARAMETERS std::string arg1, arg2; GetFirstArg(in, &arg1, &arg2); if(arg1 == "k_saf") { param.at(0) = atof(arg2.c_str()); } /* else if(arg1 == "k_saf1") { param.at(1) = atof(arg2.c_str()); } */ else { std::cout << "error: wrong parameter name" << std ::endl << "resign" << std::endl; param.clear(); } InitEngine(); #else UNUSED(in); #endif }
bool VAppBase::AppInit() { VASSERT_MSG(m_pAppImpl != NULL, "VAppImpl invalid!"); // Trigger the user application for possible screen setting changes m_pAppImpl->SetupAppConfig(m_appConfig); // Set default texture filter mode // Note: platform specific code may override this Vision::Renderer.SetDefaultTextureFilterMode(FILTER_MIN_MAG_MIP_LINEAR); // Setup platform specific stuff PlatformInitSettings(); SetupPlatformRootFileSystem(); // Setup base data directory and load vision engine plugin which is always required SetupBaseDataDirectories(); VISION_PLUGIN_ENSURE_LOADED(VisionEnginePlugin); m_pAppImpl->PreloadPlugins(); // Initialize engine if (!InitEngine()) { AppInitFailed(); return false; } AppInitThreadManager(); AppAfterEngineInit(); PlatformMapInput(); m_pAppImpl->Init(); return true; }
HGEGame::HGEGame(HGE* hge) { mHGE = hge; mHGE->System_SetState(HGE_FRAMEFUNC, FrameFunction); // Функция во время кадра (Не знаю как перевести) mHGE->System_SetState(HGE_RENDERFUNC, RenderFunction); // Функция рисования сцены InitEngine(); }
void xrSASH::TryInitEngine( bool bNoRun) { if (m_bReinitEngine) { InitEngine(); // It was destroyed on previous exit Console->Initialize(); } xr_strcpy (Console->ConfigFile,"user.ltx"); if (strstr(Core.Params,"-ltx ")) { string64 c_name; sscanf (strstr(Core.Params,"-ltx ")+5,"%[^ ] ",c_name); xr_strcpy (Console->ConfigFile,c_name); } if(strstr(Core.Params,"-r2a")) Console->Execute ("renderer renderer_r2a"); else if(strstr(Core.Params,"-r2")) Console->Execute ("renderer renderer_r2"); else { CCC_LoadCFG_custom* pTmp = xr_new<CCC_LoadCFG_custom>("renderer "); pTmp->Execute (Console->ConfigFile); if (m_bOpenAutomate) pTmp->Execute ("SASH.ltx"); else pTmp->Execute (Console->ConfigFile); xr_delete (pTmp); } InitInput(); Engine.External.Initialize( ); if (bNoRun) InitSound1(); Console->Execute ("unbindall"); Console->ExecuteScript (Console->ConfigFile); if (m_bOpenAutomate) { // Overwrite setting using SASH.ltx if has any. xr_strcpy(Console->ConfigFile,"SASH.ltx"); Console->ExecuteScript (Console->ConfigFile); } if (bNoRun) { InitSound2(); Device.Create(); } }
//-------------------------------- int main(int argc, char* argv[]) { UNUSED(argc); UNUSED(argv); #ifdef TUNE_PARAMETERS for(int i = 0; i < NPARAMS; ++i) param.push_back(1); #endif InitEngine(); tt.clear(); max_search_depth = max_ply; time_remains = 300000000; time_base = 300000000; time_inc = 0; moves_per_session = 0; max_nodes_to_search = 0; time_command_sent = false; char in[0x4000]; while(!quit) { if(!std::cin.getline(in, sizeof(in), '\n')) std::cin.clear(); if(CmdProcess((std::string)in)) { // NiCheGoNeDeLaYem! } else if(!busy && LooksLikeMove((std::string)in)) { if(!MakeMoveFinaly(in)) std::cout << "Illegal move" << std::endl; else if(!force) { #ifdef USE_THREAD_FOR_INPUT if(t.joinable()) t.join(); t = std::thread(MainSearch); #else MainSearch(); #endif // USE_THREAD_FOR_INPUT } } else std::cout << "Unknown command: " << in << std::endl; } if(busy) StopEngine(); }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); // TODO: Place code here. MSG msg; ZeroMemory(&msg, sizeof(MSG)); HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, g_szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_AIRCRAFTGAME, g_szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); InitEngine(); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_AIRCRAFTGAME)); //сно╥я╜╩╥ while (msg.message != WM_QUIT) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (!g_pGameControl->UpdateScence()) break; } g_pGameControl->Exit(); UninitEngine(); return (int) msg.wParam; }
void CSpecPearlInfEngine::EnterEvidence( const CEvidence* evidence, int maximize, int sumOnMixtureNode ) { PNL_CHECK_IS_NULL_POINTER(evidence); m_bMaximize = maximize ? 1 : 0; // clear all the previous data ClearMessagesStorage(); // init new data InitEngine(evidence); // initialize messages InitMessages(evidence); // start inference ParallelProtocol(); }
//-------------------------------- void NewCommand(std::string in) { UNUSED(in); if(busy) StopEngine(); force = false; pondering_in_process = false; if(!xboard && !uci) { if(total_time_spent == 0) total_time_spent = 1e-5; std::cout << "( Total node count: " << total_nodes << ", total time spent: " << total_time_spent / 1000000.0 << " )" << std::endl << std::setprecision(4) << std::fixed << "( MNPS = " << total_nodes / total_time_spent << " )" << std::endl; } InitEngine(); tt.clear(); }
//---------------------------------- //機能:エンジン生成・ウェーブバンクandサウンドバンクの読み込みをまとめた関数 //引数:waveBankFileName ウェーブバンクの名前 //引数:soundBankFileName サウンドバンクの名前 //戻値:成功or失敗 //---------------------------------- HRESULT Audio::Load(char* waveBankFileName, char* soundBankFileName) { //XACTエンジンの作成 if (FAILED(InitEngine())) { return E_FAIL; } //WaveBank読み込み if (FAILED(LoadWaveBank(waveBankFileName))) { return E_FAIL; } //SoundBank読み込み if (FAILED(LoadSoundBank(soundBankFileName))) { return E_FAIL; } return S_OK; }
bool GameApplication::Init() { if (!Application::Init()) { return false; } if (!InitApp()) { return false; } if (!InitEngine()) { return false; } m_Timer.Start(); m_TickTimer.start(); return true; }
bool rApplication::Init(){ int sdlInit = SDL_Init(SDL_INIT_VIDEO); if (sdlInit < 0){ rLog::Error("Error Initializing SDL: %i", sdlInit); return false; } if (SDL_SetVideoMode(m_displaySize.x, m_displaySize.y, 0, SDL_OPENGL) == 0){ rLog::Error("Error Setting SDL OpenGL Video Mode"); return false; } m_graphicsDevice = new rSDLGraphicsDevice(); m_contentManager = new rOpenGLContentManager(m_graphicsDevice); m_inputManager = new rSDLInputManager(); InitEngine(m_graphicsDevice, m_contentManager, m_inputManager); InitModule(); return true; }
int main(int argc, char **argv) { Game game; uint64_t perftVal; int depth; SetUnbufferedOutput(); if(argc == 2 && strcmp(argv[1], "--version") == 0) { printf("Weak %s.\n", version); return EXIT_SUCCESS; } if(argc < 3) { fprintf(stderr, "Usage: %s [fen] [depth]\n", argv[0]); return EXIT_FAILURE; } if((depth = atoi(argv[2])) < 1) { fprintf(stderr, "Invalid depth '%s'.\n", argv[2]); return EXIT_FAILURE; } // Initialise prng. randk_seed(); randk_warmup(KISS_WARMUP_ROUNDS); InitEngine(); game = ParseFen(argv[1]); perftVal = QuickPerft(&game, depth); printf("%lu\n", perftVal); return EXIT_SUCCESS; }
BOOL CSceneEditorApp::InitInstance() { // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(FALSE); // AfxInitRichEdit2() is required to use RichEdit control // AfxInitRichEdit2(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization SetRegistryKey(_T("AJN\\Disaster Simulator\\SceneEditor Application")); LoadStdProfileSettings(4); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CSceneEditorDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CSceneEditorView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Enable DDE Execute open EnableShellOpen(); RegisterShellFileTypes(TRUE); // Dispatch commands specified on the command line. Will return FALSE if // app was launched with /RegServer, /Register, /Unregserver or /Unregister. if (!ProcessShellCommand(cmdInfo)) return FALSE; // The one and only window has been initialized, so show and update it m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); // call DragAcceptFiles only if there's a suffix // In an SDI app, this should occur after ProcessShellCommand // Enable drag/drop open m_pMainWnd->DragAcceptFiles(); InitEngine(); return TRUE; }
BOOL CLinkedControllersApp::InitInstance() { // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); EnableTaskbarInteraction(FALSE); // AfxInitRichEdit2() is required to use RichEdit control // AfxInitRichEdit2(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization SetRegistryKey(_T("Packt Publishing\\Ogre3D Cookbook\\LinkedControllers Application")); LoadStdProfileSettings(4); // Load standard INI file options (including MRU) InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CLinkedControllersDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CLinkedControllersView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line. Will return FALSE if // app was launched with /RegServer, /Register, /Unregserver or /Unregister. if (!ProcessShellCommand(cmdInfo)) return FALSE; // The one and only window has been initialized, so show and update it m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED); m_pMainWnd->UpdateWindow(); // call DragAcceptFiles only if there's a suffix // In an SDI app, this should occur after ProcessShellCommand InitEngine(); return TRUE; }
void CScriptEnvTest::SetUp() { InitEngine(); LoadExtension(); }
int _tmain(int argc, _TCHAR* argv[]) { if (InitEngine() < 0) { cout << "init failed" << endl; return -1; } string image_path = "..\\image\\download_image\\test"; vector<string> image_list; get_image_list(image_path, image_list); int lv_cnt[5] = {0}, fail_cnt = 0; int lv_correct_cnt[5] = {0}; double totalTime = 0; for (vector<string>::iterator it = image_list.begin(); it != image_list.end(); ++it) { string img_file = image_path + "\\" + *it; Mat img = imread(img_file, 4); if (img.data == NULL) { DeleteFile(img_file.c_str()); continue; } double t = (double)getTickCount(); char code[4] = {0}; float conf[4] = {0}; int ret = RecognizeCode((char*)(img_file.c_str()), code, conf); t = (double)getTickCount() - t; totalTime += t; if (ret >= 0) { cout << "[" << ret << "]" << "\t" << *it << endl; cout << "\t" << code[0] << code[1] << code[2] << code[3]; cout << "\t" << "[" << conf[0] << " " << conf[1] << " " << conf[2] << " " << conf[3] << "]" << endl; char str[5]; str[0] = code[0];str[1] = code[1];str[2] = code[2];str[3] = code[3];str[4]='\0'; if (it->substr(6, 4) == string(str)) lv_correct_cnt[ret]++; else { //imshow("code", img); //waitKey(0); //destroyAllWindows(); } lv_cnt[ret]++; } else { cout << *it << " "; cout << "[" << ret << "]" << "\t" << "pass." << endl; //MoveFile(img_file.c_str(), (image_path + "\\@\\" + *it).c_str()); fail_cnt++; } imshow("code", img); waitKey(0); destroyAllWindows(); } cout << "FAIL: " << fail_cnt << endl; int total_cnt = 0, correct_cnt = 0; for (int i = 0; i < 5; i++) { total_cnt += lv_cnt[i]; correct_cnt += lv_correct_cnt[i]; cout << "Lv[" << i << "]: " << lv_correct_cnt[i] << "/" << lv_cnt[i] << " = " << lv_correct_cnt[i]/(float)lv_cnt[i] << endl; } total_cnt += fail_cnt; cout << "TOTAL: " << correct_cnt << "/" << total_cnt << " = " << correct_cnt/(float)total_cnt << endl; cout << "Time : " << totalTime/(double)getTickFrequency()*1000. << "/" << total_cnt << " " << totalTime/(double)getTickFrequency()*1000./total_cnt << endl; if (ReleaseEngine() < 0) cout << "release failed" << endl; return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEXA wc = {0}; MSG Msg = {0}; // Create a window with these properties wc.cbSize = sizeof(WNDCLASSEX); wc.lpfnWndProc = WndProc; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW); wc.lpszClassName = "WindowClass"; wc.hIcon = LoadIcon(hInstance,"A"); // laad projecticoon wc.hIconSm = LoadIcon(hInstance,"A"); // Say hi to Windows if(!RegisterClassEx(&wc)) { MessageBox(NULL, "Window Registration Failed!","Error!",MB_ICONEXCLAMATION|MB_OK); return 0; } // Set up a window with 1024x768 usable pixels RECT result = {0,0,1024,768}; AdjustWindowRect(&result,WS_VISIBLE|WS_OVERLAPPEDWINDOW,false); // Create a window with a border and 'client rect' of 1024x768 hwnd = CreateWindow("WindowClass","DotsEnBoxes",WS_VISIBLE|WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, // x CW_USEDEFAULT, // y result.right - result.left, // width result.bottom - result.top, // height NULL,NULL,hInstance,NULL); if(hwnd == NULL) { MessageBox(NULL,"Window Creation Failed!","Error!",MB_ICONEXCLAMATION|MB_OK); return 0; } // Init render loop InitEngine(); InitGame(); // Handle user input. If done, render a frame. Goto 1 while(Msg.message != WM_QUIT) { while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&Msg); DispatchMessage(&Msg); } if(!renderer->paused) { renderer->Begin(false); renderer->DrawScene(scene); renderer->End(); } else { Sleep(100); } } DeleteGame(); // Render loop stopped due to Alt+F4 etc? Delete everything DeleteEngine(); return Msg.wParam; }
int main(void) { communicationStatus = OpenCommunicationChannel(DEFAULT_CHANNEL, INPUT_BUFFER_SIZE); InitOutputPins(); InitLcd(); FireTextEvent("System", SYSTEM_NAME, DEFAULT_CHANNEL); FireTextEvent("Memory", PersistentMemoryType(), DEFAULT_CHANNEL); PutLcdLine(0, SYSTEM_NAME); UpdateLcd(); InitPersistentDataManager(); RegisterTableTypes(); RegisterEngineType(); memoryStatus = CheckPersistentMemory(&checkPersistentMemoryNotifyCallback); ShowStatus("Check memory", memoryStatus); if (memoryStatus == OK) { Status status = InitEngine(); ShowStatus("Initialize engine", status); if (status == OK) { InitAnalogInput(); ignitionStatus = InitIgnition(); ShowStatus("Initialize ignition", ignitionStatus); injectionStatus = InitInjection(); ShowStatus("Initialize injection", injectionStatus); } } if (FindMeasurement(RPM, &rpmMeasurement) != OK) { rpmMeasurement = NULL; } if (FindMeasurement(LOAD, &loadMeasurement) != OK) { loadMeasurement = NULL; } for (;;) { ShowIfError(communicationStatus); communicationStatus = ReadString(input); if ((communicationStatus == OK) && (strlen(input) > 0)) { communicationStatus = HandleMessage(input, &motorManagementApi, DEFAULT_CHANNEL); } if (memoryStatus == OK) { Status status = UpdateIgnition(); ShowIfError(status); if (status != ignitionStatus) { FireTextEvent(IGNITION, status, DEFAULT_CHANNEL); ignitionStatus = status; } status = UpdateInjection(); ShowIfError(status); if (status != injectionStatus) { FireTextEvent(INJECTION, status, DEFAULT_CHANNEL); injectionStatus = status; } if ((ignitionStatus == OK) && (injectionStatus == OK)) { UpdateDisplay(); } } } }
HGEGame::HGEGame() { SetupHGE(); InitEngine(); }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevinstance, LPSTR lpszCmdParam, int nCmdShow) { if(FindWindow(szWindowClass, szTitle) != NULL) { //ÀÌ¹Ì ½ÇÇàÁßÀ̸é MessageBox(NULL, _TEXT("ÀÌ¹Ì OpenWorld°¡ ½ÇÇàÁßÀÔ´Ï´Ù."), szTitle, MB_OK); return 0; } ApplicationLogger.write("OpenWorld started."); ApplicationLogger.write("Application version: %s\n", VERSION); //ÅؽºÆ® ¿¡µ÷ ÄÁÆ®·Ñ proc º¯°æ GetClassInfo(NULL, "edit", &EditWndClass); EditOrigWndProc = (WNDPROC)EditWndClass.lpfnWndProc; EditWndClass.lpfnWndProc = EditWndProc; EditWndClass.hInstance = hInst; EditWndClass.lpszClassName = "Edit"; //À©µµ¿ì Ŭ·¡½º µî·Ï WndClassRegister(hInstance); RegisterClass((LPWNDCLASS)&EditWndClass); ApplicationLogger.write("Configure display option..."); Option.OptionFile(".\\configure.ini"); if(Option.getOptionByInt("OpenWorld", "window_mode") == -1) { //ini ÆÄÀÏÀÌ ´©¶ôµÇ¾ú°Å³ª ÇÊµå ¶Ç´Â ¿É¼Ç ¼³Á¤¿¡ ¿À·ù°¡ Àִ°æ¿ì isWindowMode = 0; ApplicationLogger.write("Coudn't loaded window mode ini value - default set: 0"); } else { isWindowMode = Option.getOptionByInt("OpenWorld", "window_mode"); if(isWindowMode < 0 || isWindowMode > 1) { //0 ¶Ç´Â 1 ÀÌ¿ÜÀÇ °ªÀ¸·Î ¼³Á¤µÇÀÖ´Â °æ¿ì isWindowMode = 0; ApplicationLogger.write("window mode ini value has wrong value. default set: 0"); } } ScreenWidth = Option.getOptionByInt("OpenWorld", "width"); ScreenHeight = Option.getOptionByInt("OpenWorld", "height"); if(ScreenWidth < 1 || ScreenHeight < 1) { ApplicationLogger.write("Display setting has wrong value. - default set: width=1024, height=768"); MessageBox(NULL, "configure.ini ³» width ¶Ç´Â height °ªÀÌ À߸ø ¼³Á¤µÇ¾î ÀÖ½À´Ï´Ù.\n±âº»°ªÀÎ width=1024, height=768 ·Î Àç¼³Á¤ µÇ¾î ½ÇÇàµË´Ï´Ù.", "OpenWorld", MB_OK); Option.setOptionByInt("OpenWorld", "width", 1024); Option.setOptionByInt("OpenWorld", "height", 768); ScreenWidth = 1024; ScreenHeight = 768; } if(!InitWindowsForm(hInstance, nCmdShow, isWindowMode)) { //false ¸¦ ¸®ÅϹÞÀº °æ¿ì MessageBox(NULL, "OpenWorld âÀÇ ÃʱâÈ¿¡ ½ÇÆÐÇÏ¿´½À´Ï´Ù.", szTitle, MB_OK); return 0; } int Start_Time = 0, End_Time = 0, Frame_Time = 0; InitEngine(); //ÀÎÆ®·Î while(Quit != 1) { MessageProcess(); if(LogoIntro()) //·Î°í Ãâ·ÂÀÌ ³¡³ª¸é break; } //¸ÞÀΰÔÀÓ while(Quit != 1) { MessageProcess(); //¸ÞÀÎÇÚµéÀ϶§´Â ¹«Á¶°Ç IME¸¦ ¿µ¾î·Î ¼³Á¤(¾È±×·¯¸é ÇѱÛÅ° ´·ÁÀÖ¾î¼ z °°Àº ½ºÅ³Å° ¾È³ª°¨) if(GetFocus() == hWndMain) ImmSetConversionStatus(ImmGetContext(hWndMain), IME_CMODE_ALPHANUMERIC, (DWORD)0); if(Frame_Time == 0) Frame_Time = 1; UpdateEngineStatus(Frame_Time); End_Time = clock(); Frame_Time = End_Time - Start_Time; Start_Time = End_Time; } CloseEngine(); #ifdef DEBUG ShowWindow(hWndMain, SW_HIDE); system("pause"); #endif return 0; }
/** * Launch the app */ void System::Run() { try { Log("=============================================================="); Log("=========================Launching !========================="); Log("=============================================================="); //Initialize everything, at each step we check running to be sure the previous step go init correctly if(InitEngine()) { Log("Window opened, Width: "+ToString(_width)+"px, Height: "+ToString(_height)+"px"); if (!_renderer.Init(_width, _height,this)) { _error = true; Log("Renderer Init Error"); } LoadUis(); _renderer.SetMenu(_menu); _currentInput.SetWindowSize(vec2(_width, _height)); _currentUiDescriptor = _uis[_startupUiName]; _currentUi = _currentUiDescriptor->GetUi(); _currentUi->SetUiFunction(this); _renderer.SetupUi(_currentUi); //Reset the clock for delta time calculation Clock::GetRef().GetElapsedTime(); try { while(_running && !_error) { _running = !_currentInput.Update(); if (_uiChangeRequested) ChangeUi(); UiElement::ResetMouseInterception(); float delta = Clock::GetRef().GetElapsedTime(); if(_currentUiDescriptor->DisplayMenu()) _menu->Update(delta,&_currentInput, &_lastInput); _currentUi->Update(delta,&_currentInput,&_lastInput); _renderer.DrawFrame(delta,_displayMenu && _currentUiDescriptor->DisplayMenu()); SDL_GL_SwapWindow(_mainwindowPtr); _lastInput = _currentInput; } } catch(Exception e) { ReportError(e.what()); } _renderer.Unload(); StopEngine(); } } catch(Exception e) { ReportError(e.what()); StopEngine(); } }
int CALLBACK WinMain( _In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow) { int flags = 0; dfDeltaTime = 43.f; ScreenResolution.x = 800.f; ScreenResolution.y = 600.f; GameResolution.x = 640.f; GameResolution.y = 480.f; if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { printf( "Video initialization failed: %s\n", SDL_GetError( ) ); GameExit( 1 ); } if( SDL_Init( SDL_INIT_JOYSTICK ) < 0 ) { printf( "Input initialization failed: %s\n", SDL_GetError( ) ); GameExit( 1 ); } if( SDL_Init( SDL_INIT_GAMECONTROLLER ) < 0 ) { printf( "Input initialization failed: %s\n", SDL_GetError( ) ); GameExit( 1 ); } if( SDL_Init( SDL_INIT_AUDIO ) < 0 ) { printf( "Audio initialization failed: %s\n", SDL_GetError( ) ); GameExit( 1 ); } //Initialize SDL_mixer if( Mix_OpenAudio( 44100, MIX_DEFAULT_FORMAT, 2, 2048 ) < 0 ) { printf( "SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError() ); GameExit( 1 ); } SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 ); SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); //flags = SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL; flags = SDL_WINDOW_OPENGL; RenderSystem::window = SDL_CreateWindow("Dufresne", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, ScreenResolution.x, ScreenResolution.y, flags); flags = IMG_INIT_JPG | IMG_INIT_PNG; int initted = IMG_Init(flags); if(initted & flags != flags) { printf("Failed to Init SDL Image\n"); printf("IMG_Init: %s\n", IMG_GetError()); GameExit( 1 ); // handle error } // init gl SDL_GLContext glcontext; glcontext = SDL_GL_CreateContext(RenderSystem::window); GLint GlewInitResult = glewInit(); if (GlewInitResult != GLEW_OK) { printf("ERROR: %s\n",glewGetErrorString(GlewInitResult)); GameExit( 1 ); } glEnable(GL_TEXTURE_2D); tinyjson_init(); InitEngine(); assMan = AssetManager(); std::wstring path = L"fart\\"; assMan.CalculateLoosePackageSize(path); assMan.LoadLoosePackage(path); assMan.DebugTestWritePoolToFile(); sfxMan = SoundSystem(); sfxMan.Init(); sceneMan.Init(); input = Input(); input.Init(); dfScene* scene1 = sceneMan.CreateScene("scene-left"); dfScene* scene2 = sceneMan.CreateScene("scene-right"); scene1->setupFunc = &SetupScene1; scene2->setupFunc = &SetupScene2; sceneMan.LoadScene(scene1); Uint32 previousMiliseconds = 0; while(true) { Uint32 currentMiliseconds = SDL_GetTicks(); dfRandomFloat = dfRand(); dfTotalTime = currentMiliseconds / 1000.f; dfDeltaTime = (currentMiliseconds / 1000.f) - (previousMiliseconds / 1000.f); if(testDude->tf.rectangle.left > GameResolution.x) { sceneMan.LoadScene(scene2); } if(testDude->tf.rectangle.right < 0) { sceneMan.LoadScene(scene1); } if(input.keyboard.n1.tapped) { sceneMan.renderer.UpdateResolution(640, 480); } if(input.keyboard.n2.tapped) { sceneMan.renderer.UpdateResolution(300, 300); } if(input.keyboard.n3.tapped) { sceneMan.renderer.UpdateResolution(450, 300); } input.Update(); sceneMan.Update(); SDL_GL_SwapWindow(RenderSystem::window); } return 0; }
nsresult MediaEngineWebRTCMicrophoneSource::UpdateSingleSource( const AllocationHandle* aHandle, const NormalizedConstraints& aNetConstraints, const MediaEnginePrefs& aPrefs, const nsString& aDeviceId, const char** aOutBadConstraint) { FlattenedConstraints c(aNetConstraints); MediaEnginePrefs prefs = aPrefs; prefs.mAecOn = c.mEchoCancellation.Get(prefs.mAecOn); prefs.mAgcOn = c.mAutoGainControl.Get(prefs.mAgcOn); prefs.mNoiseOn = c.mNoiseSuppression.Get(prefs.mNoiseOn); LOG(("Audio config: aec: %d, agc: %d, noise: %d, delay: %d", prefs.mAecOn ? prefs.mAec : -1, prefs.mAgcOn ? prefs.mAgc : -1, prefs.mNoiseOn ? prefs.mNoise : -1, prefs.mPlayoutDelay)); mPlayoutDelay = prefs.mPlayoutDelay; switch (mState) { case kReleased: MOZ_ASSERT(aHandle); if (sChannelsOpen == 0) { if (!InitEngine()) { LOG(("Audio engine is not initalized")); return NS_ERROR_FAILURE; } } else { // Until we fix (or wallpaper) support for multiple mic input // (Bug 1238038) fail allocation for a second device return NS_ERROR_FAILURE; } if (!AllocChannel()) { LOG(("Audio device is not initalized")); return NS_ERROR_FAILURE; } if (mAudioInput->SetRecordingDevice(mCapIndex)) { FreeChannel(); return NS_ERROR_FAILURE; } LOG(("Audio device %d allocated", mCapIndex)); break; case kStarted: if (prefs == mLastPrefs) { return NS_OK; } if (MOZ_LOG_TEST(GetMediaManagerLog(), LogLevel::Debug)) { MonitorAutoLock lock(mMonitor); if (mSources.IsEmpty()) { LOG(("Audio device %d reallocated", mCapIndex)); } else { LOG(("Audio device %d allocated shared", mCapIndex)); } } break; default: LOG(("Audio device %d in ignored state %d", mCapIndex, mState)); break; } if (sChannelsOpen > 0) { int error; error = mVoEProcessing->SetEcStatus(prefs.mAecOn, (webrtc::EcModes)prefs.mAec); if (error) { LOG(("%s Error setting Echo Status: %d ",__FUNCTION__, error)); // Overhead of capturing all the time is very low (<0.1% of an audio only call) if (prefs.mAecOn) { error = mVoEProcessing->SetEcMetricsStatus(true); if (error) { LOG(("%s Error setting Echo Metrics: %d ",__FUNCTION__, error)); } } } error = mVoEProcessing->SetAgcStatus(prefs.mAgcOn, (webrtc::AgcModes)prefs.mAgc); if (error) { LOG(("%s Error setting AGC Status: %d ",__FUNCTION__, error)); } error = mVoEProcessing->SetNsStatus(prefs.mNoiseOn, (webrtc::NsModes)prefs.mNoise); if (error) { LOG(("%s Error setting NoiseSuppression Status: %d ",__FUNCTION__, error)); } } mSkipProcessing = !(prefs.mAecOn || prefs.mAgcOn || prefs.mNoiseOn); if (mSkipProcessing) { mSampleFrequency = MediaEngine::USE_GRAPH_RATE; } SetLastPrefs(prefs); return NS_OK; }
nsresult MediaEngineWebRTCMicrophoneSource::UpdateSingleSource( const AllocationHandle* aHandle, const NormalizedConstraints& aNetConstraints, const MediaEnginePrefs& aPrefs, const nsString& aDeviceId, const char** aOutBadConstraint) { FlattenedConstraints c(aNetConstraints); MediaEnginePrefs prefs = aPrefs; prefs.mAecOn = c.mEchoCancellation.Get(prefs.mAecOn); prefs.mAgcOn = c.mAutoGainControl.Get(prefs.mAgcOn); prefs.mNoiseOn = c.mNoiseSuppression.Get(prefs.mNoiseOn); uint32_t maxChannels = 1; if (mAudioInput->GetMaxAvailableChannels(maxChannels) != 0) { return NS_ERROR_FAILURE; } // Check channelCount violation if (static_cast<int32_t>(maxChannels) < c.mChannelCount.mMin || static_cast<int32_t>(maxChannels) > c.mChannelCount.mMax) { *aOutBadConstraint = "channelCount"; return NS_ERROR_FAILURE; } // Clamp channelCount to a valid value if (prefs.mChannels <= 0) { prefs.mChannels = static_cast<int32_t>(maxChannels); } prefs.mChannels = c.mChannelCount.Get(std::min(prefs.mChannels, static_cast<int32_t>(maxChannels))); // Clamp channelCount to a valid value prefs.mChannels = std::max(1, std::min(prefs.mChannels, static_cast<int32_t>(maxChannels))); LOG(("Audio config: aec: %d, agc: %d, noise: %d, delay: %d, channels: %d", prefs.mAecOn ? prefs.mAec : -1, prefs.mAgcOn ? prefs.mAgc : -1, prefs.mNoiseOn ? prefs.mNoise : -1, prefs.mPlayoutDelay, prefs.mChannels)); mPlayoutDelay = prefs.mPlayoutDelay; switch (mState) { case kReleased: MOZ_ASSERT(aHandle); if (sChannelsOpen == 0) { if (!InitEngine()) { LOG(("Audio engine is not initalized")); return NS_ERROR_FAILURE; } } else { // Until we fix (or wallpaper) support for multiple mic input // (Bug 1238038) fail allocation for a second device return NS_ERROR_FAILURE; } if (mAudioInput->SetRecordingDevice(mCapIndex)) { return NS_ERROR_FAILURE; } mAudioInput->SetUserChannelCount(prefs.mChannels); if (!AllocChannel()) { FreeChannel(); LOG(("Audio device is not initalized")); return NS_ERROR_FAILURE; } LOG(("Audio device %d allocated", mCapIndex)); { // Update with the actual applied channelCount in order // to store it in settings. uint32_t channelCount = 0; mAudioInput->GetChannelCount(channelCount); MOZ_ASSERT(channelCount > 0); prefs.mChannels = channelCount; } break; case kStarted: if (prefs == mLastPrefs) { return NS_OK; } if (prefs.mChannels != mLastPrefs.mChannels) { MOZ_ASSERT(mSources.Length() > 0); auto& source = mSources.LastElement(); mAudioInput->SetUserChannelCount(prefs.mChannels); // Get validated number of channel uint32_t channelCount = 0; mAudioInput->GetChannelCount(channelCount); MOZ_ASSERT(channelCount > 0 && mLastPrefs.mChannels > 0); // Check if new validated channels is the same as previous if (static_cast<uint32_t>(mLastPrefs.mChannels) != channelCount && !source->OpenNewAudioCallbackDriver(mListener)) { return NS_ERROR_FAILURE; } // Update settings prefs.mChannels = channelCount; } if (MOZ_LOG_TEST(GetMediaManagerLog(), LogLevel::Debug)) { MonitorAutoLock lock(mMonitor); if (mSources.IsEmpty()) { LOG(("Audio device %d reallocated", mCapIndex)); } else { LOG(("Audio device %d allocated shared", mCapIndex)); } } break; default: LOG(("Audio device %d in ignored state %d", mCapIndex, mState)); break; } if (sChannelsOpen > 0) { int error; error = mVoEProcessing->SetEcStatus(prefs.mAecOn, (webrtc::EcModes)prefs.mAec); if (error) { LOG(("%s Error setting Echo Status: %d ",__FUNCTION__, error)); // Overhead of capturing all the time is very low (<0.1% of an audio only call) if (prefs.mAecOn) { error = mVoEProcessing->SetEcMetricsStatus(true); if (error) { LOG(("%s Error setting Echo Metrics: %d ",__FUNCTION__, error)); } } } error = mVoEProcessing->SetAgcStatus(prefs.mAgcOn, (webrtc::AgcModes)prefs.mAgc); if (error) { LOG(("%s Error setting AGC Status: %d ",__FUNCTION__, error)); } error = mVoEProcessing->SetNsStatus(prefs.mNoiseOn, (webrtc::NsModes)prefs.mNoise); if (error) { LOG(("%s Error setting NoiseSuppression Status: %d ",__FUNCTION__, error)); } } mSkipProcessing = !(prefs.mAecOn || prefs.mAgcOn || prefs.mNoiseOn); if (mSkipProcessing) { mSampleFrequency = MediaEngine::USE_GRAPH_RATE; mAudioOutputObserver = nullptr; } else { // make sure we route a copy of the mixed audio output of this MSG to the // AEC mAudioOutputObserver = new AudioOutputObserver(); } SetLastPrefs(prefs); return NS_OK; }
EngineCore::EngineCore(char *title, int width, int height, Game *game) { this->game = game; InitEngine(title, width, height); }
BOOL CSpeechApp::InitInstance() { // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(FALSE); // AfxInitRichEdit2() is required to use RichEdit control // AfxInitRichEdit2(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization SetRegistryKey(_T("Packt Publishing\\Ogre3D Cookbook\\Speech Ogre Application")); LoadStdProfileSettings(4); // Load standard INI file options (including MRU) InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CSpeechDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CSpeechView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // Connect the COleTemplateServer to the document template // The COleTemplateServer creates new documents on behalf // of requesting OLE containers by using information // specified in the document template m_server.ConnectTemplate(clsid, pDocTemplate, TRUE); // Note: SDI applications register server objects only if /Embedding // or /Automation is present on the command line // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Enable DDE Execute open EnableShellOpen(); RegisterShellFileTypes(TRUE); // App was launched with /Embedding or /Automation switch. // Run app as automation server. if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated) { // Register all OLE server factories as running. This enables the // OLE libraries to create objects from other applications COleTemplateServer::RegisterAll(); // Don't show the main window return TRUE; } // App was launched with /Unregserver or /Unregister switch. Unregister // typelibrary. Other unregistration occurs in ProcessShellCommand(). else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister) { UnregisterShellFileTypes(); m_server.UpdateRegistry(OAT_DISPATCH_OBJECT, NULL, NULL, FALSE); AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor); } // App was launched standalone or with other switches (e.g. /Register // or /Regserver). Update registry entries, including typelibrary. else { m_server.UpdateRegistry(OAT_DISPATCH_OBJECT); COleObjectFactory::UpdateRegistryAll(); AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid); } // Dispatch commands specified on the command line. Will return FALSE if // app was launched with /RegServer, /Register, /Unregserver or /Unregister. if (!ProcessShellCommand(cmdInfo)) return FALSE; // The one and only window has been initialized, so show and update it m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED); m_pMainWnd->UpdateWindow(); // call DragAcceptFiles only if there's a suffix // In an SDI app, this should occur after ProcessShellCommand // Enable drag/drop open m_pMainWnd->DragAcceptFiles(); m_cpVoice.CoCreateInstance(CLSID_SpVoice); InitEngine(); return TRUE; }