int wmain(int argc, gs2d::str_type::char_t* argv[]) #endif { Platform::FileManagerPtr fileManager(new Platform::StdFileManager()); Platform::FileIOHubPtr fileIOHub = Platform::CreateFileIOHub(fileManager, GS_L("data/")); VideoPtr video; if ((video = CreateVideo(1024, 768, GS_L("temp"), true, true, fileIOHub, Texture::PF_UNKNOWN, false))) { InputPtr input = CreateInput(0, false); AudioPtr audio = CreateAudio(0); Video::APP_STATUS status; while ((status = video->HandleEvents()) != Video::APP_QUIT) { if (status == Video::APP_SKIP) continue; input->Update(); video->BeginSpriteScene(); video->EndSpriteScene(); } } return 0; }
int main() { VideoPtr video; BaseApplicationPtr application = CreateBaseApplication(); if ((video = CreateVideo(480, 854, L"GS2D", true, true, L"assets/fonts/"))) { InputPtr input = CreateInput(0, true); AudioPtr audio = CreateAudio(0); application->Start(video, input, audio); Video::APP_STATUS status; while ((status = video->HandleEvents()) != Video::APP_QUIT) { if (status == Video::APP_SKIP) continue; input->Update(); application->Update(Min(static_cast<unsigned long>(1000), ComputeElapsedTime(video))); application->RenderFrame(); } } application->Destroy(); #ifdef _DEBUG #ifdef WIN32 _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif #endif return 0; }
JNIEXPORT jstring JNICALL Java_net_asantee_gs2d_GS2DJNI_mainLoop(JNIEnv* env, jobject thiz, jstring inputStr) { jboolean isCopy; g_inputStr = env->GetStringUTFChars(inputStr, &isCopy); video->HandleEvents(); input->Update(); // if the splash screen has already been shown, do the regular engine loop if (g_splashShown) { // if the engine hasn't been started yet (which means the previous frame was the splash screen frame), // start the engine machine before performing the regular loop if (!application) { StartApplication(); } application->Update(Min(static_cast<unsigned long>(1000), ComputeElapsedTime(video))); application->RenderFrame(); } else { // draw the splash screen and prepare the engine start DrawSplashScreen(); g_splashShown = true; } return env->NewStringUTF(AssembleCommands().c_str()); }
GS_PLAYER_INFO PlayCutscene(VideoPtr pVideo, const std::wstring& fileName, InputPtr pInput, const GS_KEY escapeKey) { if (!pVideo) { ShowMessage(L"Invalid video handler - gs2d::PlayCutscene", GSMT_ERROR); return GSPI_FAILED; } GS_PLAYER_INFO info = GSPI_FINISHED; //pVideo->TurnLoopManagerOff(); const bool rendering = pVideo->Rendering(); if (rendering) pVideo->EndSpriteScene(); PlayerPtr player = CreatePlayer(pVideo, fileName); if (!player) { ShowMessage(L"Failed while trying to load the video - gs2d::PlayCutscene", GSMT_ERROR); if (rendering) pVideo->BeginSpriteScene(); return GSPI_FAILED; } pVideo->EnableMediaPlaying(true); player->SetFullscreen(); player->Rewind(); player->Play(); while (!player->IsFinished()) { player->UpdateVideo(); const Video::APP_STATUS status = pVideo->HandleEvents(); if (status == Video::APP_QUIT) { info = GSPI_CLOSE_WINDOW; break; } else { if (status == Video::APP_SKIP) continue; } if (pInput) { pInput->Update(); if (pInput->GetKeyState(escapeKey) == GSKS_HIT) { info = GSPI_SKIPPED; break; } } } if (rendering) pVideo->BeginSpriteScene(); pVideo->EnableMediaPlaying(false); return info; }
int wmain(int argc, wchar_t* argv[]) { bool compileAndRun, testing, wait; ProcParams(argc, argv, compileAndRun, testing, wait); ETHScriptWrapper::SetArgc(argc); ETHScriptWrapper::SetArgv(argv); Platform::FileManagerPtr fileManager(new Platform::StdFileManager()); Platform::FileIOHubPtr fileIOHub(new Platform::WindowsFileIOHub(fileManager, ETHDirectories::GetBitmapFontDirectory())); const str_type::string resourceDirectory = fileIOHub->GetResourceDirectory(); const ETHAppEnmlFile app(resourceDirectory + ETH_APP_PROPERTIES_FILE, Platform::FileManagerPtr(new Platform::StdFileManager), GS_L("")); const str_type::string bitmapFontPath = resourceDirectory + ETHDirectories::GetBitmapFontDirectory(); bool aborted; { ETHEnginePtr application = ETHEnginePtr(new ETHEngine(testing, compileAndRun)); application->SetHighEndDevice(true); // the PC will always be considered as a high-end device VideoPtr video; if ((video = CreateVideo(app.GetWidth(), app.GetHeight(), app.GetTitle(), app.IsWindowed(), app.IsVsyncEnabled(), fileIOHub, Texture::PF_UNKNOWN, false))) { InputPtr input = CreateInput(0, false); AudioPtr audio = CreateAudio(0); application->Start(video, input, audio); if (compileAndRun) { Video::APP_STATUS status; while ((status = video->HandleEvents()) != Video::APP_QUIT) { if (status == Video::APP_SKIP) continue; input->Update(); if (application->Update(Min(static_cast<unsigned long>(1000), ComputeElapsedTime(video))) == Application::APP_QUIT) { break; } application->RenderFrame(); } } } application->Destroy(); aborted = application->Aborted(); } if (aborted) { ETH_STREAM_DECL(ss) << std::endl << GS_L("The program executed an ilegal operation and was aborted"); //logger->Log(ss.str(), Platform::Logger::ERROR); std::wcerr << ss.str() << std::endl; } if (!compileAndRun && !aborted) { ETH_STREAM_DECL(ss) << std::endl << GS_L("Compilation successful: 0 errors"); //logger->Log(ss.str(), Platform::Logger::INFO); std::wcerr << ss.str() << std::endl; } if (aborted && wait) { std::wcout << GS_L("Press any key to continue...") << std::endl; while(!_getch()); } #ifdef _DEBUG #ifdef WIN32 _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif #endif return 0; }
int main(int argc, char** argv) #endif { // convert args to multibyte char #ifdef WIN32 GS2D_UNUSED_ARGUMENT(hInstance); GS2D_UNUSED_ARGUMENT(nCmdShow); int argc = 0; LPWSTR* wargv = CommandLineToArgvW(lpCmdLine, &argc); LPSTR* argv = new LPSTR [argc]; for (int t = 0; t < argc; t++) { std::size_t convertCount = 0; const std::size_t bufferSize = 4096; argv[t] = new CHAR [bufferSize]; wcstombs_s(&convertCount, argv[t], bufferSize, wargv[t], wcslen(wargv[t]) + 1); } #endif // start engine runtime bool compileAndRun, testing, wait; ProcParams(argc, argv, compileAndRun, testing, wait); ETHScriptWrapper::SetArgc(argc); ETHScriptWrapper::SetArgv(argv); Platform::FileManagerPtr fileManager(new Platform::StdFileManager()); Platform::FileIOHubPtr fileIOHub = Platform::CreateFileIOHub(fileManager, ETHDirectories::GetBitmapFontDirectory()); { const str_type::string resourceDirectory = FindResourceDir(argc, argv); if (!resourceDirectory.empty()) fileIOHub->SetResourceDirectory(resourceDirectory); } const str_type::string resourceDirectory = fileIOHub->GetResourceDirectory(); const ETHAppEnmlFile app(resourceDirectory + ETH_APP_PROPERTIES_FILE, Platform::FileManagerPtr(new Platform::StdFileManager), Application::GetPlatformName()); const str_type::string bitmapFontPath = resourceDirectory + ETHDirectories::GetBitmapFontDirectory(); bool aborted; { ETHEnginePtr application = ETHEnginePtr(new ETHEngine(testing, compileAndRun)); application->SetHighEndDevice(true); VideoPtr video; if ((video = CreateVideo( app.GetWidth(), app.GetHeight(), app.GetTitle(), app.IsWindowed(), app.IsVsyncEnabled(), fileIOHub, Texture::PF_UNKNOWN, false))) { InputPtr input = CreateInput(0, false); AudioPtr audio = CreateAudio(0); application->Start(video, input, audio); if (compileAndRun) { Video::APP_STATUS status; while ((status = video->HandleEvents()) != Video::APP_QUIT) { if (status == Video::APP_SKIP) continue; input->Update(); if (application->Update(Min(1000.0f, ComputeElapsedTimeF(video))) == Application::APP_QUIT) { break; } application->RenderFrame(); } } } application->Destroy(); aborted = application->Aborted(); } if (aborted) { ETH_STREAM_DECL(ss) << std::endl << GS_L("The program executed an ilegal operation and was aborted"); GS2D_CERR << ss.str() << std::endl; } if (!compileAndRun && !aborted) { ETH_STREAM_DECL(ss) << std::endl << GS_L("Compilation successful: 0 errors"); GS2D_CERR << ss.str() << std::endl; } if (aborted && wait) { GS2D_COUT << GS_L("Press any key to continue...") << GS_L("\n"); std::cin.get(); } #if defined(_DEBUG) || defined(DEBUG) #ifdef WIN32 _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); LocalFree(wargv); for (int t = 0; t < argc; t++) { delete [] argv[t]; } delete [] argv; #endif #endif return 0; }
int ETH_MACHINE_MAIN_FUNC(int argc, gs2d::str_type::char_t** argv) #endif { bool compileAndRun, testing, wait; ProcParams(argc, argv, compileAndRun, testing, wait); ETHScriptWrapper::SetArgc(argc); ETHScriptWrapper::SetArgv(argv); Platform::FileManagerPtr fileManager(new Platform::StdFileManager()); Platform::FileIOHubPtr fileIOHub = Platform::CreateFileIOHub(fileManager, ETHDirectories::GetBitmapFontDirectory()); { const str_type::string resourceDirectory = FindResourceDir(argc, argv); if (!resourceDirectory.empty()) fileIOHub->SetResourceDirectory(resourceDirectory); } const str_type::string resourceDirectory = fileIOHub->GetResourceDirectory(); const ETHAppEnmlFile app(resourceDirectory + ETH_APP_PROPERTIES_FILE, Platform::FileManagerPtr(new Platform::StdFileManager), Application::GetPlatformName()); const str_type::string bitmapFontPath = resourceDirectory + ETHDirectories::GetBitmapFontDirectory(); bool aborted; { ETHEnginePtr application = ETHEnginePtr(new ETHEngine(testing, compileAndRun)); application->SetHighEndDevice(true); VideoPtr video; if ((video = CreateVideo( app.GetWidth(), app.GetHeight(), app.GetTitle(), app.IsWindowed(), app.IsVsyncEnabled(), fileIOHub, Texture::PF_UNKNOWN, false))) { InputPtr input = CreateInput(0, false); AudioPtr audio = CreateAudio(0); application->Start(video, input, audio); if (compileAndRun) { Video::APP_STATUS status; while ((status = video->HandleEvents()) != Video::APP_QUIT) { if (status == Video::APP_SKIP) continue; input->Update(); if (application->Update(Min(static_cast<unsigned long>(1000), ComputeElapsedTime(video))) == Application::APP_QUIT) { break; } application->RenderFrame(); } } } application->Destroy(); aborted = application->Aborted(); } if (aborted) { ETH_STREAM_DECL(ss) << std::endl << GS_L("The program executed an ilegal operation and was aborted"); GS2D_CERR << ss.str() << std::endl; } if (!compileAndRun && !aborted) { ETH_STREAM_DECL(ss) << std::endl << GS_L("Compilation successful: 0 errors"); GS2D_CERR << ss.str() << std::endl; } if (aborted && wait) { GS2D_COUT << GS_L("Press any key to continue...") << GS_L("\n"); std::cin.get(); } #if defined(_DEBUG) || defined(DEBUG) #ifdef WIN32 _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif #endif return 0; }