What is easiest way to implement animated startup/load screen?
I need it to hide some unaesthetic 3D scene stuff behind.
What is easiest way to implement animated startup/load screen?
-
- Bronze Sponsor
- Posts: 146
- Joined: Fri May 23, 2025 5:04 pm
- x 5
What is easiest way to implement animated startup/load screen?
-
- Orc Shaman
- Posts: 752
- Joined: Wed Mar 18, 2009 3:03 am
- x 421
Re: What is easiest way to implement animated startup/load screen?
If you are using background loading of your resources at startup, I think you can just render normally (with an FPS limit of course, otherwise you may fry some graphic cards!) until the background resources have been completely loaded.
If you are not using background loading, you can use the resource group listener to listen to when a resource has been loaded, and then just trigger a render (with an FPS limit as well).
Here is a short class to handle that:
Code: Select all
class CResourceGroupListener : public Ogre::ResourceGroupListener
{
public:
CResourceGroupListener();
~CResourceGroupListener();
// ResourceGroupListener
void resourceGroupScriptingStarted(const Ogre::String& groupName, size_t scriptCount);
void scriptParseStarted(const Ogre::String& scriptName, bool& skipThisScript);
void scriptParseEnded(const Ogre::String& scriptName, bool skipped);
void resourceGroupScriptingEnded(const Ogre::String& groupName);
void resourceGroupLoadStarted(const Ogre::String& groupName, size_t resourceCount);
void resourceLoadStarted(const Ogre::ResourcePtr& resource);
void resourceLoadEnded();
void resourcePrepareStarted(const ResourcePtr& resource);
void resourceCreated(const ResourcePtr& resource);
void worldGeometryStageStarted(const Ogre::String& description);
void worldGeometryStageEnded();
void resourceGroupLoadEnded(const Ogre::String& groupName);
};
CResourceGroupListener::CResourceGroupListener()
{
}
CResourceGroupListener::~CResourceGroupListener()
{
}
void CResourceGroupListener::resourceGroupScriptingStarted(const Ogre::String& groupName, size_t scriptCount)
{
// Update loading screen
if (app->m_GUIManager->m_screen_loadingScreen)
app->m_GUIManager->m_screen_loadingScreen->UpdateLoading();
}
void CResourceGroupListener::scriptParseStarted(const Ogre::String& scriptName, bool& skipThisScript)
{
// Update loading screen
if (app->m_GUIManager->m_screen_loadingScreen)
app->m_GUIManager->m_screen_loadingScreen->UpdateLoading();
}
void CResourceGroupListener::scriptParseEnded(const Ogre::String& scriptName, bool skipped)
{
// Update loading screen
if (app->m_GUIManager->m_screen_loadingScreen)
app->m_GUIManager->m_screen_loadingScreen->UpdateLoading();
}
void CResourceGroupListener::resourceGroupScriptingEnded(const Ogre::String& groupName)
{
// Update loading screen
if (app->m_GUIManager->m_screen_loadingScreen)
app->m_GUIManager->m_screen_loadingScreen->UpdateLoading();
}
void CResourceGroupListener::resourceGroupLoadStarted(const Ogre::String& groupName, size_t resourceCount)
{
// Update loading screen
if (app->m_GUIManager->m_screen_loadingScreen)
app->m_GUIManager->m_screen_loadingScreen->UpdateLoading();
}
void CResourceGroupListener::resourceLoadStarted(const Ogre::ResourcePtr& resource)
{
// Update loading screen
if (app->m_GUIManager->m_screen_loadingScreen)
app->m_GUIManager->m_screen_loadingScreen->UpdateLoading();
}
void CResourceGroupListener::resourceLoadEnded()
{
// Update loading screen
if (app->m_GUIManager->m_screen_loadingScreen)
app->m_GUIManager->m_screen_loadingScreen->UpdateLoading();
}
void CResourceGroupListener::resourcePrepareStarted(const ResourcePtr& resource)
{
// Update loading screen
if (app->m_GUIManager->m_screen_loadingScreen)
app->m_GUIManager->m_screen_loadingScreen->UpdateLoading();
}
void CResourceGroupListener::resourceCreated(const ResourcePtr& resource)
{
// Update loading screen
if (app->m_GUIManager->m_screen_loadingScreen)
app->m_GUIManager->m_screen_loadingScreen->UpdateLoading();
}
void CResourceGroupListener::worldGeometryStageStarted(const Ogre::String& description)
{
// Update loading screen
if (app->m_GUIManager->m_screen_loadingScreen)
app->m_GUIManager->m_screen_loadingScreen->UpdateLoading();
}
void CResourceGroupListener::worldGeometryStageEnded()
{
// Update loading screen
if (app->m_GUIManager->m_screen_loadingScreen)
app->m_GUIManager->m_screen_loadingScreen->UpdateLoading();
}
void CResourceGroupListener::resourceGroupLoadEnded(const Ogre::String& groupName)
{
// Update loading screen
if (app->m_GUIManager->m_screen_loadingScreen)
app->m_GUIManager->m_screen_loadingScreen->UpdateLoading();
}
Then, you add it to your resource groups that you load before they are actually loaded
Code: Select all
CResourceGroupListener* tmpListener = new CResourceGroupListener();
tmpResourceGroupManager.addResourceGroupListener(tmpListener);
tmpResourceGroupManager.initialiseResourceGroup(m_groupName);
tmpResourceGroupManager.loadResourceGroup(m_groupName, true, true);
tmpResourceGroupManager.removeResourceGroupListener(tmpListener);
delete tmpListener;
My project: https://imagindar.com/
-
- Bronze Sponsor
- Posts: 146
- Joined: Fri May 23, 2025 5:04 pm
- x 5
Re: What is easiest way to implement animated startup/load screen?
Thanks a lot for examples, I see the idea. But I need help with actual screen implementation. I need example with something which will be drawn over 3D
scene and hide it, and it would be nice to be able to draw some text and animate it for user to not think something hung...
I tried with ImGUI but it requires drawing each frame which is not possible in this case as I want to actually let the main thread freezes at that moment,
I need something I'd draw and keep at that until I update it and destroy it later.
-
- Orc Shaman
- Posts: 752
- Joined: Wed Mar 18, 2009 3:03 am
- x 421
Re: What is easiest way to implement animated startup/load screen?
I guess this is then a UI issue?
For my loading screen, I simply render a UI with text, which hides the 3D scene behind (but there is no reason for me to hide the 3D scene since there is nothing there anyway most of the time, since the loading screen is mostly used while loading resources, not much while creating them, since creating them is almost done instantly anyway).
To render the loading screen, I simply use renderOneFrame on the Ogre root object, like any other render.
My project: https://imagindar.com/
-
- Bronze Sponsor
- Posts: 146
- Joined: Fri May 23, 2025 5:04 pm
- x 5
Re: What is easiest way to implement animated startup/load screen?
I think there should be a way to do it in GUI-independent way...
-
- Bronze Sponsor
- Posts: 519
- Joined: Sun Jan 18, 2015 4:20 pm
- Location: Buenos Aires, Argentina
- x 188
Re: What is easiest way to implement animated startup/load screen?
Well you either give the user a static screen with text (like Dark Souls where they show item descriptions for you to read) or you make something animated but choppy, so that the background thread is able to update.
-
- OGRE Team Member
- Posts: 2204
- Joined: Sun Mar 30, 2014 2:51 pm
- x 1188