void CppLayoutPreviewer::RefreshFromLayoutSecondPart() { cout << "Scene canvas reloading... (step 2/2)" << endl; CodeCompiler::Get()->DisableTaskRelatedTo(editor.GetLayout()); //Switch the working directory as we are making calls to the runtime scene if ( wxDirExists(wxFileName::FileName(editor.GetProject().GetProjectFile()).GetPath())) wxSetWorkingDirectory(wxFileName::FileName(editor.GetProject().GetProjectFile()).GetPath()); //Load the scene ( compilation is done ) std::cout << "Initializing RuntimeScene from layout..." << std::endl; previewScene.LoadFromScene( editor.GetLayout() ); std::cout << "Loading compiled code..." << std::endl; if ( !previewScene.GetCodeExecutionEngine()->LoadFromDynamicLibrary(editor.GetLayout().GetCompiledEventsFile(), "GDSceneEvents"+gd::SceneNameMangler::GetMangledSceneName(editor.GetLayout().GetName())) ) { gd::LogError(_("Compilation of events failed, and scene cannot be previewed. Please report this problem to GDevelop's developer, joining this file:\n") +CodeCompiler::Get()->GetOutputDirectory()+"LatestCompilationOutput.txt"); editor.GoToEditingState(); return; } editor.GetLayout().SetRefreshNotNeeded(); //We were preventing images unloading so as to be sure not to waste time unloading and reloading just after scenes images. if ( editor.GetProject().GetImageManager() ) editor.GetProject().GetImageManager()->EnableImagesUnloading(); isReloading = false; PlayPreview(); }
void CppLayoutPreviewer::OnPreviewPlayWindowBtClick( wxCommandEvent & event ) { PlayPreview(); mainFrameWrapper.GetRibbonSceneEditorButtonBar()->EnableButton(idRibbonPlay, true); mainFrameWrapper.GetRibbonSceneEditorButtonBar()->EnableButton(idRibbonPause, true); mainFrameWrapper.GetRibbonSceneEditorButtonBar()->EnableButton(idRibbonPlayWin, false); //Create now the window if necessary (not done in the constructor because, on linux, the window was not hidden). if (!externalPreviewWindow) externalPreviewWindow = std::shared_ptr<RenderDialog>(new RenderDialog(editor.GetParentControl(), this) ); externalPreviewWindow->Show(true); externalPreviewWindow->SetSizeOfRenderingZone(editor.GetProject().GetMainWindowDefaultWidth(), editor.GetProject().GetMainWindowDefaultHeight()); previewScene.ChangeRenderWindow(externalPreviewWindow->renderCanvas); }
void test_pcm_source(int op) { if (op == 0) { if (g_test_source == nullptr) { auto mydsp = std::make_shared<MyTestAudioDSP>(); g_test_source = std::make_shared<MRP_PCMSource>(mydsp); g_prev_reg.src = g_test_source.get(); g_prev_reg.volume = 1.0; g_prev_reg.loop = true; #ifdef WIN32 InitializeCriticalSection(&g_prev_reg.cs); #else // I wonder if pthread copies this stuff internally... pthread_mutexattr_t mta; pthread_mutexattr_init(&mta); pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&g_prev_reg.mutex, &mta); #endif } if (g_is_playing == false) { g_test_source->get_dsp()->prepare_audio(2, 44100.0, 512); PlayPreview(&g_prev_reg); g_is_playing = true; } else { StopPreview(&g_prev_reg); g_test_source->get_dsp()->release_audio(); g_is_playing = false; } } else if (op == 1) // Clean up on Reaper shutdown { if (g_is_playing == true) StopPreview(&g_prev_reg); g_test_source.reset(); #ifdef WIN32 DeleteCriticalSection(&g_prev_reg.cs); #else pthread_mutex_destroy(&g_prev_reg.mutex); #endif } }
void CppLayoutPreviewer::ExternalWindowClosed() { if (playing) PlayPreview(); //Go back to the internal preview }
void CppLayoutPreviewer::OnPreviewPlayBtClick( wxCommandEvent & event ) { PlayPreview(); }