| 246 | ForgeModule& ForgeManager::plugin() { return *mPlugin; } |
| 247 | |
| 248 | fg_window ForgeManager::getMainWindow() { |
| 249 | static std::once_flag flag; |
| 250 | |
| 251 | // Define AF_DISABLE_GRAPHICS with any value to disable initialization |
| 252 | std::string noGraphicsENV = getEnvVar("AF_DISABLE_GRAPHICS"); |
| 253 | |
| 254 | af_err error = AF_SUCCESS; |
| 255 | fg_err forgeError = FG_ERR_NONE; |
| 256 | if (noGraphicsENV.empty()) { // If AF_DISABLE_GRAPHICS is not defined |
| 257 | std::call_once(flag, [this, &error, &forgeError] { |
| 258 | if (!this->mPlugin->isLoaded()) { |
| 259 | error = AF_ERR_LOAD_LIB; |
| 260 | return; |
| 261 | } |
| 262 | fg_window w = nullptr; |
| 263 | forgeError = this->mPlugin->fg_create_window( |
| 264 | &w, WIDTH, HEIGHT, "ArrayFire", NULL, true); |
| 265 | if (forgeError != FG_ERR_NONE) { return; } |
| 266 | this->setWindowChartGrid(w, 1, 1); |
| 267 | this->mPlugin->fg_make_window_current(w); |
| 268 | this->mMainWindow.reset(new Window({w})); |
| 269 | if (!gladLoadGL()) { error = AF_ERR_LOAD_LIB; } |
| 270 | }); |
| 271 | if (error == AF_ERR_LOAD_LIB) { |
| 272 | string error_message = |
| 273 | "Error loading Forge: " + this->mPlugin->getErrorMessage() + |
| 274 | "\nForge or one of it's dependencies failed to " |
| 275 | "load. Try installing Forge or check if Forge is in the " |
| 276 | "search path."; |
| 277 | AF_ERROR(error_message.c_str(), AF_ERR_LOAD_LIB); |
| 278 | } |
| 279 | if (forgeError != FG_ERR_NONE) { |
| 280 | AF_ERROR(this->mPlugin->fg_err_to_string(forgeError), |
| 281 | AF_ERR_RUNTIME); |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | return mMainWindow->handle; |
| 286 | } |
| 287 | |
| 288 | fg_window ForgeManager::getWindow(const int w, const int h, |
| 289 | const char* const title, |
no test coverage detected