mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-24 22:43:47 +00:00
Restore the "transparent" loading screen
This commit is contained in:
parent
f3cbe7b9da
commit
0330d3d61e
@ -2,6 +2,8 @@
|
||||
|
||||
#include <osgViewer/Viewer>
|
||||
|
||||
#include <osg/Texture2D>
|
||||
|
||||
#include <MyGUI_RenderManager.h>
|
||||
#include <MyGUI_ScrollBar.h>
|
||||
#include <MyGUI_Gui.h>
|
||||
@ -9,6 +11,8 @@
|
||||
|
||||
#include <components/misc/rng.hpp>
|
||||
|
||||
#include <components/myguiplatform/myguitexture.hpp>
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/vfs/manager.hpp>
|
||||
|
||||
@ -96,6 +100,28 @@ namespace MWGui
|
||||
mBackgroundImage->setVisible(visible);
|
||||
}
|
||||
|
||||
class CopyFramebufferToTextureCallback : public osg::Camera::DrawCallback
|
||||
{
|
||||
public:
|
||||
CopyFramebufferToTextureCallback(osg::Texture2D* texture, int w, int h)
|
||||
: mTexture(texture), mWidth(w), mHeight(h)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void operator () (osg::RenderInfo& renderInfo) const
|
||||
{
|
||||
mTexture->copyTexImage2D(*renderInfo.getState(), 0, 0, mWidth, mHeight);
|
||||
|
||||
// Callback removes itself when done
|
||||
if (renderInfo.getCurrentCamera())
|
||||
renderInfo.getCurrentCamera()->setInitialDrawCallback(NULL);
|
||||
}
|
||||
|
||||
private:
|
||||
osg::ref_ptr<osg::Texture2D> mTexture;
|
||||
int mWidth, mHeight;
|
||||
};
|
||||
|
||||
void LoadingScreen::loadingOn()
|
||||
{
|
||||
mLoadingOnTime = mTimer.time_m();
|
||||
@ -114,29 +140,30 @@ namespace MWGui
|
||||
|
||||
if (!showWallpaper)
|
||||
{
|
||||
// TODO
|
||||
/*
|
||||
mBackgroundImage->setImageTexture("");
|
||||
int width = mWindow->getWidth();
|
||||
int height = mWindow->getHeight();
|
||||
const std::string textureName = "@loading_background";
|
||||
Ogre::TexturePtr texture;
|
||||
texture = Ogre::TextureManager::getSingleton().getByName(textureName);
|
||||
if (texture.isNull())
|
||||
// Copy the current framebuffer onto a texture and display that texture as the background image
|
||||
// Note, we could also set the camera to disable clearing and have the background image transparent,
|
||||
// but then we get shaking effects on buffer swaps.
|
||||
|
||||
if (!mTexture)
|
||||
{
|
||||
texture = Ogre::TextureManager::getSingleton().createManual(textureName,
|
||||
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||
Ogre::TEX_TYPE_2D,
|
||||
width, height, 0, mWindow->suggestPixelFormat(), Ogre::TU_DYNAMIC_WRITE_ONLY);
|
||||
mTexture = new osg::Texture2D;
|
||||
mTexture->setInternalFormat(GL_RGB);
|
||||
mTexture->setResizeNonPowerOfTwoHint(false);
|
||||
}
|
||||
texture->unload();
|
||||
texture->setWidth(width);
|
||||
texture->setHeight(height);
|
||||
texture->createInternalResources();
|
||||
mWindow->copyContentsToMemory(texture->getBuffer()->lock(Ogre::Image::Box(0,0,width,height), Ogre::HardwareBuffer::HBL_DISCARD));
|
||||
texture->getBuffer()->unlock();
|
||||
mBackgroundImage->setBackgroundImage(texture->getName(), false, false);
|
||||
*/
|
||||
|
||||
int width = mViewer->getCamera()->getViewport()->width();
|
||||
int height = mViewer->getCamera()->getViewport()->height();
|
||||
mViewer->getCamera()->setInitialDrawCallback(new CopyFramebufferToTextureCallback(mTexture, width, height));
|
||||
|
||||
if (!mGuiTexture.get())
|
||||
{
|
||||
mGuiTexture.reset(new osgMyGUI::OSGTexture(mTexture));
|
||||
}
|
||||
|
||||
mBackgroundImage->setBackgroundImage("");
|
||||
|
||||
mBackgroundImage->setRenderItemTexture(mGuiTexture.get());
|
||||
mBackgroundImage->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 1.f, 1.f, 0.f));
|
||||
}
|
||||
|
||||
setVisible(true);
|
||||
|
@ -12,6 +12,12 @@ namespace osgViewer
|
||||
{
|
||||
class Viewer;
|
||||
}
|
||||
|
||||
namespace osg
|
||||
{
|
||||
class Texture2D;
|
||||
}
|
||||
|
||||
namespace VFS
|
||||
{
|
||||
class Manager;
|
||||
@ -67,6 +73,11 @@ namespace MWGui
|
||||
|
||||
std::vector<std::string> mSplashScreens;
|
||||
|
||||
// TODO: add releaseGLObjects() for mTexture
|
||||
|
||||
osg::ref_ptr<osg::Texture2D> mTexture;
|
||||
std::auto_ptr<MyGUI::ITexture> mGuiTexture;
|
||||
|
||||
void changeWallpaper();
|
||||
|
||||
void draw();
|
||||
|
Loading…
x
Reference in New Issue
Block a user