Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

Merge origin/feat/warm-ui-runner 67caecba: warm UI tests (one window and GL context for many scripts)

islandmed1affea8119a3
diff --cc CMakeLists.txt
index 59219bbf,a5a06268..7c988f8d
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@@ -348,10 -311,18 +348,11 @@@ if(SCULPTFORGE_BUILD_APP
src/app/AsyncStroke.cpp
src/app/Demo.cpp
src/app/UiTest.cpp
+ src/app/UiServe.cpp
- src/app/Actions.cpp
- src/app/BlenderKeymap.cpp
src/app/Ui.cpp
- src/app/UiLayout.cpp
src/app/Shell.cpp
- src/app/ShellGeometry.cpp
src/app/Palettes.cpp
src/app/Theme.cpp
- src/app/LookSchemes.cpp
- src/app/I18n.cpp
- src/app/I18nSpanish.cpp
src/app/CommandPalette.cpp
src/app/Console.cpp
src/app/Config.cpp
diff --cc src/app/App.cpp
index 7d3c22f6,38d2455f..a55dcd13
--- a/src/app/App.cpp
+++ b/src/app/App.cpp
@@@ -107,8 -123,8 +123,9 @@@ bool App::init(const AppOptions& option
// Full screen on one monitor stays up when the pointer clicks on another (Windows multi-monitor, Discord).
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
if (!headless && options.demo.empty()) applyCachedThreadCount(); // the hardware profile's threads, before any brush work
- if (!SDL_Init(SDL_INIT_VIDEO)) {
+ if (sharedWindow_) syncSdlEnvironment(); // (what SDL_Init would have read)
+ else if (!SDL_Init(SDL_INIT_VIDEO)) {
+ startError_ = std::string("The window system did not start: ") + SDL_GetError();
SDL_Log("SDL_Init failed: %s", SDL_GetError());
return false;
}
@@@ -136,9 -143,13 +144,14 @@@
rememberWindow_ = !sized && !headless && options.demo.empty() && !options.fullscreen;
const WindowState saved = rememberWindow_ ? loadWindowState() : WindowState{};
const int winW = sized ? options.width : saved.w, winH = sized ? options.height : saved.h;
- window_ = SDL_CreateWindow("SculptForge", winW, winH, flags);
+ if (sharedWindow_) { // --ui-serve: the server's window, at this script's size
+ window_ = sharedWindow_;
+ SDL_SetWindowSize(window_, winW, winH);
+ SDL_SyncWindow(window_);
+ } else
+ window_ = SDL_CreateWindow("SculptForge", winW, winH, flags);
if (!window_) {
+ startError_ = std::string("The OpenGL 3.3 window could not be made: ") + SDL_GetError();
SDL_Log("SDL_CreateWindow failed: %s", SDL_GetError());
return false;
}
@@@ -164,17 -175,17 +177,19 @@@
}
}
}
- glContext_ = SDL_GL_CreateContext(window_);
+ glContext_ = sharedContext_ ? sharedContext_ : SDL_GL_CreateContext(window_);
if (!glContext_) {
+ startError_ = std::string("OpenGL 3.3 is not available: ") + SDL_GetError();
SDL_Log("OpenGL 3.3 context creation failed: %s", SDL_GetError());
return false;
}
SDL_GL_MakeCurrent(window_, glContext_);
SDL_GL_SetSwapInterval(1);
+ timer.step("window, GL context");
- if (const char* missing = gl::load([](const char* n) { return reinterpret_cast<gl::GenericProc>(SDL_GL_GetProcAddress(n)); })) {
+ if (const char* missing = sharedContext_ ? nullptr // (loaded by the server)
+ : gl::load([](const char* n) { return reinterpret_cast<gl::GenericProc>(SDL_GL_GetProcAddress(n)); })) {
+ startError_ = std::string("The graphics driver lacks the OpenGL function ") + missing + ".";
SDL_Log("Missing OpenGL function: %s", missing);
return false;
}
diff --cc src/app/main.cpp
index b87fd084,2c586496..d3756605
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@@ -249,21 -254,9 +254,21 @@@ static int runMain(int argc, char** arg
}
sf::crashlog::start(logDir); // after isolateSettings: a UI test logs into its own folder
if (!crashTest.empty()) crashOnPurpose(crashTest);
- sf::App app;
- if (!app.init(options)) {
+ auto app = std::make_unique<sf::App>();
+ if (!app->init(options)) {
+ // A double-clicked app that can't start says why (#109: on a laptop it just vanished, not even in the
+ // Task Manager). Tests, renders and benchmarks keep failing quietly with their log.
+ const bool interactive = options.renderPath.empty() && options.recordPath.empty() && options.uiTest.empty() &&
+ options.timelapsePath.empty() && !options.benchmark && options.demo.empty() &&
+ !automatedRun();
+ if (interactive) {
+ std::string text = "SculptForge could not start.\n\n" +
- (app.startError().empty() ? std::string("See the log for details.") : app.startError()) +
++ (app->startError().empty() ? std::string("See the log for details.") : app->startError()) +
+ "\n\nUpdating the graphics driver (from the PC or GPU maker) usually fixes this.";
+ if (!sf::crashlog::path().empty()) text += "\n\nLog: " + sf::crashlog::path();
+ SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SculptForge", text.c_str(), nullptr);
+ }
- app.shutdown();
+ app->shutdown();
sf::crashlog::stop();
return 1;
}