本文整理汇总了C++中Loader::LoadAll方法的典型用法代码示例。如果您正苦于以下问题:C++ Loader::LoadAll方法的具体用法?C++ Loader::LoadAll怎么用?C++ Loader::LoadAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loader
的用法示例。
在下文中一共展示了Loader::LoadAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitApp
bool App::InitApp (void)
{
#ifdef CONFDIR
strcpy (settings_path, (std::string (CONFDIR) + PATH_SEPARATOR + "test3d.ini").c_str());
#else
strcpy (settings_path, (std::string (SDL_GetBasePath ()) + "settings.ini").c_str());
#endif
int w, h;
// initialize SDL with screen sizes from settings file:
w = LoadSetting (settings_path, SCREENWIDTH_SETTING);
if (w < 640)
w = 640;
h = LoadSetting (settings_path, SCREENHEIGHT_SETTING);
if (h < 480)
h = 480;
fullscreen = LoadSetting (settings_path, FULLSCREEN_SETTING) > 0 ? true : false;
// Create a window:
if (!InitializeSDL(w, h))
return false;
// Create a rendering context in the window:
if (!InitializeGL())
return false;
pScene = new HubScene (this);
RandomSeed ();
Progress progress;
Loader loader;
// Collect jobs to be done:
pScene->AddAll (&loader);
// Progress bar is rendered in a different thread while the scene loads:
bool error = false;
SDL_Thread* progressThread = MakeSDLThread (
[&] () { return ProgressLoop (mainWindow, &progress, error); },
"progress"
);
if (!progressThread)
{
SetError ("failed to create progress thread: %s", SDL_GetError());
return false;
}
/*
Do all jobs while the progress bar is rendered.
Some of them depend on the current thread's rendering context.
*/
if (!loader.LoadAll (&progress))
{
error = true;
SDL_DetachThread (progressThread);
return false;
}
// progressThread will finish automatically, now that everything is loaded ..
// Check for other errors:
if (!CheckGLOK ("scene init"))
return false;
// Wait for progress display thread to finish:
int progressReturn;
SDL_WaitThread (progressThread, &progressReturn);
if (progressReturn != 0)
{
SetError ("progress thread returned exit code %d", progressReturn);
return false;
}
return true;
}